Skip to content

fix(anthropic): use token thinking for effort levels on models without adaptive support#3381

Merged
Sayt-0 merged 1 commit into
mainfrom
fix/3362-adaptive-thinking-unsupported-models
Jul 1, 2026
Merged

fix(anthropic): use token thinking for effort levels on models without adaptive support#3381
Sayt-0 merged 1 commit into
mainfrom
fix/3362-adaptive-thinking-unsupported-models

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Switching the active model to Haiku 4.5 (or any model without adaptive-thinking support) and setting a reasoning level via Shift+Tab made every subsequent request fail with HTTP 400. The Shift+Tab cycle stores the level as an effort-based thinking_budget, and the Anthropic provider routed any effort budget into the adaptive-thinking API (thinking.type=adaptive with output_config.effort) regardless of model.

Issue expectations

Expectation (#3362) Handled by Status
Do not set adaptive thinking on models that do not support it resolveThinkingBudget converts effort/adaptive budgets to token budgets on unsupported models yes
Use the regular thinking options instead thinking.type=enabled with budget_tokens derived from the effort level (effort.BedrockTokens) yes
Reasoning should work properly verified end to end (see Testing) yes

Change

  • pkg/modelinfo: add SupportsAdaptiveThinking (Opus 4.6/4.7/4.8, Sonnet 4.6, the Claude 5 families, Fable, Mythos). It is a superset of RejectsTokenThinking, so a model that rejects token budgets always reports adaptive support.
  • pkg/model/provider/anthropic: replace coerceAdaptiveThinking with resolveThinkingBudget, which resolves both directions: token to adaptive for Opus 4.6+ (unchanged), and effort/adaptive to a token budget for models without adaptive support (new). adjustMaxTokensForThinking now operates on the resolved budget so a converted token budget gets the correct max_tokens headroom.

Testing

Unit tests (added/updated) cover the effort-to-token fallback, the adaptive path on supported models, the previously untested plain effort level, and the SupportsAdaptiveThinking superset invariant. lint, vet, and gofmt are clean.

Verified against a live gateway (provider: anthropic, proxied to Bedrock):

Case Path taken Before After
Haiku 4.5 + effort high token 16384 HTTP 400 passes, reasoning works
Haiku 4.5 + effort medium / low token 8192 / 2048 not applicable passes
Sonnet 4.6 + effort high adaptive (no regression) not applicable passes

Notes

The Bedrock provider (provider: amazon-bedrock) already routes plain effort levels to token thinking for non-Opus-4.6+ models and is not affected by this issue. It retains a narrower edge case (an explicit thinking_budget: adaptive on a non-adaptive model), which is out of scope here and can be addressed as a follow-up. If a different resolution seems more appropriate, it can always be changed.

…ls without adaptive support

Setting a reasoning level via the TUI Shift+Tab cycle produces an
effort-based thinking budget. applyThinkingConfig routed any effort
budget into the adaptive-thinking API (thinking.type=adaptive plus
output_config.effort) regardless of model, so switching to Haiku 4.5
(or Sonnet 4.5 and earlier) and setting a reasoning level made every
request fail with HTTP 400.

Add modelinfo.SupportsAdaptiveThinking and resolve the thinking budget
against it: effort or adaptive budgets on models that do not support
adaptive thinking are converted to a token-based budget
(thinking.type=enabled) via effort.BedrockTokens, while models that do
support it keep using adaptive thinking. The predicate is a superset of
RejectsTokenThinking, so models that reject token budgets still use
adaptive.

Fixes #3362
@Sayt-0 Sayt-0 requested a review from a team as a code owner July 1, 2026 14:27
@aheritier aheritier added kind/fix PR fixes a bug (maps to fix:). Use on PRs only. area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/models LLM model integrations and model providers labels Jul 1, 2026
@Sayt-0 Sayt-0 merged commit d36ff77 into main Jul 1, 2026
13 checks passed
@Sayt-0 Sayt-0 deleted the fix/3362-adaptive-thinking-unsupported-models branch July 1, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/models LLM model integrations and model providers area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants