Problem
Claude Sonnet 4.5 supports 64k output tokens, but OpenCode has a hardcoded limit
that prevents using the full capacity when extended thinking is enabled.
Current Behavior
In src/session/prompt.ts:
export const OUTPUT_TOKEN_MAX = 32_000
const outputLimit = Math.min(model.info.limit.output, OUTPUT_TOKEN_MAX) ||
OUTPUT_TOKEN_MAX
This caps outputLimit at 32k even when the model config specifies 64k:
"claude-sonnet-4-20250514": {
"limit": {
"output": 64000,
"context": 200000
}
}
When using extended thinking with a 32k budget:
thinking:
type: enabled
budgetTokens: 32000
The calculation becomes: 32000 - 32000 = 0, causing:
AI_InvalidArgumentError: maxOutputTokens must be >= 1
Expected Behavior
OUTPUT_TOKEN_MAX should be at least 64k to support Claude Sonnet 4.5's full output
capacity with extended thinking enabled.
Workaround
Reduce thinking budgets to fit within 32k total (e.g., budgetTokens: 20000 leaves
12k for output).
Problem
Claude Sonnet 4.5 supports 64k output tokens, but OpenCode has a hardcoded limit
that prevents using the full capacity when extended thinking is enabled.
Current Behavior
In
src/session/prompt.ts:This caps outputLimit at 32k even when the model config specifies 64k:
When using extended thinking with a 32k budget:
The calculation becomes: 32000 - 32000 = 0, causing:
AI_InvalidArgumentError: maxOutputTokens must be >= 1
Expected Behavior
OUTPUT_TOKEN_MAX should be at least 64k to support Claude Sonnet 4.5's full output
capacity with extended thinking enabled.
Workaround
Reduce thinking budgets to fit within 32k total (e.g., budgetTokens: 20000 leaves
12k for output).