Skip to content

Commit 0b5200b

Browse files
committed
fix: calculate max output tokens based on budget thinking tokens
1 parent 97a4106 commit 0b5200b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/opencode/src/session/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,13 @@ export namespace Session {
10071007
: undefined,
10081008
maxRetries: 3,
10091009
activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
1010-
maxOutputTokens: outputLimit,
1010+
maxOutputTokens: Math.max(
1011+
1,
1012+
outputLimit -
1013+
(input.providerID === "anthropic"
1014+
? ((params.options as { thinking?: { budgetTokens?: number } } | undefined)?.thinking?.budgetTokens ?? 0)
1015+
: 0),
1016+
),
10111017
abortSignal: abort.signal,
10121018
stopWhen: async ({ steps }) => {
10131019
if (steps.length >= 1000) {

0 commit comments

Comments
 (0)