fix(ai): bind Bedrock Claude thinking blocks by default - #51959
Merged
Merged
Conversation
Claude 5.1+ binds each thinking signature to the system prompt, tools, and messages above it. Bedrock Converse never sent block_binding or its beta, so a rebuilt prefix (prompt rebuild, tool change, compaction) fails the request on accounts and models that enforce the check. Mirror the Anthropic route: default to prefix_mismatch_behavior drop_block for Claude 5.1+ with adaptive thinking where none is set, honor explicit thinking settings from providerOptions or http.body, and send the thinking-binding-controls beta in additionalModelRequestFields.anthropic_beta, unioned with betas the caller already set because http.body replaces arrays.
Apply the default through a helper that mirrors the Anthropic route so fromRequest keeps a single thinking value, and skip binding only for disabled thinking instead of decoding the overlay type.
Converse takes Anthropic betas in additionalModelRequestFields, so set anthropic_beta in fromRequest whenever the body carries block_binding instead of rewriting http.body in a transport wrapper. Like any other http.body field, a caller-supplied anthropic_beta replaces it.
rekram1-node
enabled auto-merge (squash)
September 29, 2026 04:38
rekram1-node
disabled auto-merge
September 29, 2026 04:38
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
No linked issue.
Type of change
What does this PR do?
Claude 5.1+ binds each thinking signature to the system prompt, tools, and messages above it. The Anthropic route already asks the API to drop affected blocks instead of failing (
block_binding.prefix_mismatch_behavior: "drop_block"plus thethinking-binding-controls-2026-08-01beta, #47884), and v1 did the same for Bedrock through its patched SDK (#46653, #46848). The v2 Bedrock Converse protocol never sent either, so a rebuilt prefix (prompt rebuild, tool change, compaction) fails the request on any account and model that enforces the check.Bedrock supports this on Converse: AWS documents passing the beta and
thinking.block_bindingthroughadditionalModelRequestFields. It is on by default the same way it is for Anthropic:compatibility.supportsThinkingBlockBindingas an override in both directions. The detection moves intoprotocols/utils/claude-model.tsso both protocols share it; Anthropic behavior is unchanged.drop_block, injecting adaptive thinking where none is configured. Explicit settings fromproviderOptionsorhttp.bodywin field by field, anddisabledthinking is left alone. This mirrorsapplyThinkingBindingDefaultin the Anthropic route.additionalModelRequestFields.anthropic_beta, so it is set in the request body whenever the body carriesblock_binding(Bedrock rejectsblock_bindingwithout it). Like any otherhttp.bodyfield, a caller-suppliedanthropic_betareplaces it, so someone who sets their own betas on a Claude 5.1+ model must include this one or setthinkingthemselves. I could not find anyone doing this today; the documented betas users set on Bedrock (1M context) target Claude 4.x.Not covered: I could not exercise Fable 5.1 itself because my Bedrock account has no data-retention access to it. Opus 5.5, which enforces the same check, is what the live tests use. Converse does not return
input_transformations, so dropped blocks are not reported.How did you verify your code works?
top_k,disabled, and compatibility overrides. 9 of the 19 fail against the base source; the rest are negative controls.errorgets Bedrock's 400bound to a different conversation. The recorded requests include thehighvariant's display and effort merged beside the default. Both fail against the base source with the missingblock_bindingandanthropic_betain the diff.highvariant. Both requests, including a tool-loop continuation replaying signed thinking, carriedblock_bindingand the beta and returned 200. After denying tools mid-session (system hash changed and tools went 13 to 10) the default still returned 200, while forcingerrorin config returned 400The system prompt and the tools list both differ.packages/aifull suite (1625 pass), the Bedrock, variant and provider tests inpackages/core, andbun run checkat the root.Screenshots / recordings
Not applicable.
Checklist