fix: use adaptive thinking for Anthropic models that reject extended-thinking budgets#433
Merged
Merged
Conversation
…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.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tasks running on the direct
anthropic/provider (orbedrock-mantle/) with a newer Claude model fail on the first model call:buildOpenCodeModelReasoningOptionsmaps every Anthropic-provider model's reasoning effort tothinking: { 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-mantleproviders (both register OpenCode's@ai-sdk/anthropicprovider, so they share one option shape):{ thinking: { type: 'adaptive', display: 'summarized' }, effort }.display: 'summarized'is forced because these models default thinking display toomitted(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.xhighclamped tohigh(noxhighon the 4.6 family) — mirroring the existing OpenRouter clamp.Version parsing accepts
./-separators, dated suffixes (claude-sonnet-4-5-20250929), Bedrock'santhropic.prefix, and the inverted legacy ordering (claude-3-5-sonnet).Validation
@roomote/typessuite (575) and workeragent-hometests pass;pnpm lint+pnpm check-typesclean.