Repository navigation
fix(ai): fit Claude thinking budgets on Bedrock Converse - #51190
Merged
Merged
Conversation
4 of 6 tasks
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.
Issue for this PR
N/A. Found while testing default output limits for #51021.
Type of change
What does this PR do?
Claude thinking budgets on Bedrock Converse now reach the protocol as a typed option, so they get fitted to half the output limit like Anthropic's own API does since #51157.
Bedrock enforces the same rule as Anthropic:
Our Claude budget variants sent the budget as a raw body overlay (
additionalModelRequestFields.thinking). That overlay is merged after the protocol builds the body, so the protocol could not fit it. Automatic compaction starts when the summary's output limit is below about 28k. So on Claude 4.5 models, themaxvariant (31,999) was always rejected at automatic compaction, andhigh(16,000) was rejected once the limit fell below 16k.packages/ai: Bedrock Converse reads a typedthinking: { type: "enabled", budgetTokens }option. It writesadditionalModelRequestFields.thinking, fitting the budget with a 1,024 minimum. The Bedrock provider passes athinkingsetting through as that option.packages/core: Claude budget variants on Bedrock Converse now use thethinkingsetting. The AI SDK Bedrock config mapping does the same forreasoningConfig: { type: "enabled", budgetTokens }on Claude.Other Bedrock fields (adaptive thinking, effort, Grok, Nova, OpenAI) keep using the body overlay.
How did you verify your code works?
Unit tests:
top_k: 31,999 stays under a 64,000 limit, becomes 10,000 under 20,000, and becomes 1,024 under 1,500.thinkingsetting.Checks: the affected
packages/aiandpackages/coresuites pass, andbun run checkpasses with feat(core): fit output limits to the context window #51021 applied.Direct Bedrock checks on
us.anthropic.claude-haiku-4-5:maxTokensmax_tokensmust be greater thanthinking.budget_tokens"Live through opencode, with feat(core): fit output limits to the context window #51021 applied and a 20,000 summary limit to simulate automatic compaction on a nearly full context:
maxTokens: 64000withthinking.budget_tokens: 31999.maxTokens: 20000withthinking.budget_tokens: 10000. The summary completed.Screenshots / recordings
N/A
Checklist