Skip to content

[Feat] Expose configurable max output token slider for Anthropic models#942

Draft
zoomote[bot] wants to merge 3 commits into
mainfrom
feature/anthropic-max-output-override-27alivyqw93v6
Draft

[Feat] Expose configurable max output token slider for Anthropic models#942
zoomote[bot] wants to merge 3 commits into
mainfrom
feature/anthropic-max-output-override-27alivyqw93v6

Conversation

@zoomote

@zoomote zoomote Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Opened on behalf of Toray Altas. Follow up by mentioning @zoomote, in the web UI, or in Discord.

What changed

  • getModelMaxOutputTokens() in src/shared/api.ts now honors settings.modelMaxTokens for Anthropic hybrid models when reasoning is disabled, capping the override at the model's advertised maxTokens and falling back to the 8K default when the override is unset or non-positive.
  • The settings ThinkingBudget component now surfaces a standalone "Max Output Tokens" slider for Anthropic models in the binary-reasoning, reasoning-budget (reasoning off), and non-reasoning branches, so users can override the conservative 8K default from the UI.
  • The displayed slider value is clamped to the model's maxTokens ceiling so it never exceeds the slider's maximum.
  • Added unit tests for the Anthropic override, override cap, OpenRouter Anthropic format, and the modelMaxTokens: 0 edge case; added webview UI tests for Anthropic hybrid, binary, non-reasoning, and OpenRouter Anthropic slider rendering.

Why this change was made

Anthropic hybrid reasoning models currently always clamp output to 8K when reasoning is disabled, even though the API supports much larger outputs. Exposing modelMaxTokens as a configurable slider gives users control over the output budget without changing the safe default when no override is set.

Impact

Users can now raise the max output tokens for Anthropic models from the settings UI; the default behavior remains unchanged when the override is not set.

@zoomote

zoomote Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

All previously reported issues are resolved; no new code issues found. See task

  • webview-ui/src/components/settings/ThinkingBudget.tsx:80 — The new isAnthropicModel condition surfaces the "Max Output Tokens" slider for all Claude models with maxTokens, including non-reasoning ones (e.g. claude-3-5-sonnet-20241022, claude-3-5-haiku, claude-3-opus — codified by the new test at ThinkingBudget.spec.tsx:575). But getModelMaxOutputTokens (src/shared/api.ts:127-143) ignores settings.modelMaxTokens for those models: without supportsReasoningBudget or supportsMaxTokens they fall through to Math.min(model.maxTokens, 20% of contextWindow) regardless of the slider. The slider persists a value the runtime never honors. Either gate the UI on supportsMaxTokens || supportsReasoningBudget, or honor the override for every Anthropic context in getModelMaxOutputTokens.
  • webview-ui/src/components/settings/ThinkingBudget.tsx:213 — The standalone reasoning-off slider allows min=1024, but the reasoning-on branch's max-tokens slider has min=8192. A persisted value below 8192 (e.g. 1024) leaks across the toggle: the reasoning-on slider renders out of range, and the thinking-budget slider range inverts since modelMaxThinkingTokens = floor(0.8 * modelMaxTokens) (819) drops below its 1024 min. Consider clamping the standalone slider's min to 8192 for Anthropic hybrid models or reconciling modelMaxTokens when reasoning is enabled.
  • webview-ui/src/components/settings/ThinkingBudget.tsx:236 — The new maxOutputTokensMin = isAnthropicModel ? 8192 : 1024 applies the 8192 floor to every Claude model, but claude-3-opus-20240229 and claude-3-haiku-20240307 advertise maxTokens: 4096 (packages/types/src/providers/anthropic.ts:239,250). For those models the standalone slider renders with min=8192 > max=4096 and a value (≤4096) below its min — an inverted, unusable control (previously min=1024 was valid for them). The 8192 floor only matters for reasoning-budget hybrids (matching the useEffect guard at line 179), so gate it accordingly, e.g. const maxOutputTokensMin = isAnthropicModel && isReasoningBudgetSupported ? 8192 : 1024.

Reviewed 1049beb

@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/shared/api.ts 50.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@zoomote

zoomote Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Screenshot of the new Max Output Tokens slider in Settings > Providers with claude-sonnet-4-5 selected. The slider is shown while reasoning is disabled; the configured value is 8192 and the range is 8192–64000.

Anthropic Max Output Tokens slider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants