anthropic: switch opus 4.6/4.7 token thinking budgets to adaptive#2563
Merged
dgageot merged 3 commits intodocker:mainfrom Apr 28, 2026
Merged
Conversation
Without this guard, opus 4.6/4.7 would silently flip thinking_budget: 0, thinking_budget: none, or negative token budgets into adaptive thinking, enabling thinking when the user disabled it.
rumpl
approved these changes
Apr 28, 2026
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.
Anthropic's API rejects
thinking.type=enabled(token-based extended thinking) for Claude Opus 4.6 and 4.7. When a user configures a token-basedthinking_budgetfor those models, the request now fails at the provider.This change makes the Anthropic provider transparently switch a token-based budget to adaptive thinking (default
higheffort) on Opus 4.6 / 4.7 (including dated variants likeclaude-opus-4-6-20251101), with aslog.Warnso the substitution is visible. Other models keep the existing token-based path unchanged.Behavior
claude-opus-4-6/claude-opus-4-7(and*-<date>) +thinking_budget: <tokens>→thinking.type=adaptive,output_config.effort=high.thinking_budget: adaptive(oradaptive/<level>) → preserved as-is.thinking_budget: 0,thinking_budget: none, negative tokens) → passed through untouched, so thinking stays off. (Important: without this guard, those would have been silently flipped to adaptive thinking.)max_tokensauto-adjustment is skipped when the budget will be coerced, so an oversized token budget on Opus 4.6/4.7 no longer errors out or inflatesmax_tokens.Tests
TestRequiresAdaptiveThinkingcovers prefix matching, dated variants, case/whitespace, and non-matches likeclaude-opus-4-60, sonnet/haiku models, etc.TestCoerceAdaptiveThinkingcovers the coercion path, the no-op paths (already adaptive, non-affected model), and the disabled/non-positive guards.TestApplyThinkingConfigandTestApplyBetaThinkingConfiggain Opus 4.6/4.7 cases verifying both SDK type families end up withOfAdaptiveset, the right effort, andthinking_displaypreserved.TestAdjustMaxTokensForThinkinggains Opus 4.6/4.7 cases verifying no error / no auto-adjust.golangci-lint run ./...→ 0 issues.go test ./...→ all packages pass.