fix: calculate max output tokens based on budget thinking tokens

This commit is contained in:
snipeship 2025-08-18 21:21:56 -04:00
parent 50fb337270
commit bc85f92232
No known key found for this signature in database

View file

@ -947,7 +947,13 @@ export namespace Session {
},
maxRetries: 3,
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
maxOutputTokens: outputLimit,
maxOutputTokens: Math.max(
1,
outputLimit -
(input.providerID === "anthropic"
? ((params.options as { thinking?: { budgetTokens?: number } } | undefined)?.thinking?.budgetTokens ?? 0)
: 0),
),
abortSignal: abort.signal,
stopWhen: async ({ steps }) => {
if (steps.length >= 1000) {