fix(core): honor the -1 sentinels for max_turns and max_tokens (#56)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-24 16:18:38 +08:00
committed by GitHub
parent 6bbdac132f
commit c7465625a4
10 changed files with 66 additions and 10 deletions
+3 -2
View File
@@ -155,10 +155,11 @@ export function effectiveMaxContextLength(configured: number, contextWindow: unk
* Output cap for meta requests (title generation / vision describing): these carry their own
* small hardcoded budget, tightened further by the entry's per-model `max_tokens` when that is
* smaller — a cap the user pinned below the budget must bind every request to that model. The
* budget is never raised.
* budget is never raised. A non-positive cap (-1 = uncapped) never tightens: Math.min against
* it would send max_tokens -1 on the wire, and meta requests must keep their small budget.
*/
export function metaMaxTokens(budget: number, modelCap: number | undefined): number {
return modelCap !== undefined ? Math.min(budget, modelCap) : budget;
return modelCap !== undefined && modelCap > 0 ? Math.min(budget, modelCap) : budget;
}
/** Create or load an Agent. */