Skip to content

fix: use adaptive thinking for Anthropic models that reject extended-thinking budgets#433

Merged
mrubens merged 1 commit into
developfrom
fix/anthropic-adaptive-thinking
Jul 16, 2026
Merged

fix: use adaptive thinking for Anthropic models that reject extended-thinking budgets#433
mrubens merged 1 commit into
developfrom
fix/anthropic-adaptive-thinking

Conversation

@mrubens

@mrubens mrubens commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Tasks running on the direct anthropic/ provider (or bedrock-mantle/) with a newer Claude model fail on the first model call:

The provider returned an error: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.

buildOpenCodeModelReasoningOptions maps every Anthropic-provider model's reasoning effort to thinking: { type: 'enabled', budgetTokens }. Opus 4.7+, Sonnet 5+, and Fable/Mythos removed that parameter from the API and reject it with a 400, so any deployment whose configured role model is one of those (which is what the provider defaults and suggestions now recommend) fails on every task.

This is easy to miss in ad-hoc testing: a per-task model override only has a reasoning effort attached when it matches the deployment's configured coding model, so picking an Anthropic model in the task launcher works fine while the same model configured as the default coding model fails. Reproduced both ways locally.

Fix

Resolve a per-model thinking mode for the anthropic/bedrock-mantle providers (both register OpenCode's @ai-sdk/anthropic provider, so they share one option shape):

  • Opus 4.7+, Sonnet 5+, Fable/Mythos{ thinking: { type: 'adaptive', display: 'summarized' }, effort }. display: 'summarized' is forced because these models default thinking display to omitted (empty thinking blocks). This matches the shape OpenCode 1.17.8's own variant builder emits for adaptive-capable models, so the pinned CLI's bundled AI SDK supports it.
  • Opus 4.6 / Sonnet 4.6 → adaptive without the display override (already defaults to summarized), with xhigh clamped to high (no xhigh on the 4.6 family) — mirroring the existing OpenRouter clamp.
  • Older models (Sonnet 4.5, Haiku 4.5, Opus 4.5, ...) → unchanged extended-thinking budgets, which they still require.

Version parsing accepts ./- separators, dated suffixes (claude-sonnet-4-5-20250929), Bedrock's anthropic. prefix, and the inverted legacy ordering (claude-3-5-sonnet).

Validation

  • New unit tests for the adaptive mapping, 4.6 clamp, Bedrock Mantle ids, dated legacy ids, and the unchanged budget path; full @roomote/types suite (575) and worker agent-home tests pass; pnpm lint + pnpm check-types clean.
  • Reproduced end-to-end locally: configured the deployment coding model to an Anthropic-provider Sonnet 5 and hit the exact 400 above on the first model call of a task.

…kens

Newer Claude models (Opus 4.7+, Sonnet 5+, Fable) return a 400 for
thinking.type 'enabled' with budgetTokens. Map reasoning effort to
thinking.type 'adaptive' plus effort for those models (forcing
display 'summarized' where thinking text defaults to omitted, and
clamping xhigh to high on the 4.6 family), keeping extended-thinking
budgets for models that predate adaptive thinking.
@roomote-roomote

roomote-roomote Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

Reviewed 9197cce

@mrubens
mrubens merged commit 8c27ea6 into develop Jul 16, 2026
17 checks passed
@mrubens
mrubens deleted the fix/anthropic-adaptive-thinking branch July 16, 2026 17:23
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.

1 participant