fix(bedrock): clamp top_p >= 0.95 for adaptive thinking, not just legacy budget#3472
Open
resrever wants to merge 1 commit into
Open
fix(bedrock): clamp top_p >= 0.95 for adaptive thinking, not just legacy budget#3472resrever wants to merge 1 commit into
resrever wants to merge 1 commit into
Conversation
…acy budget Anthropic-on-Bedrock enforces the top_p >= 0.95-or-unset constraint for both thinking.enabled (legacy budget) and thinking.adaptive modes. The previous code only applied the clamp for emits_legacy_thinking, leaving top_p unconstrained for Opus 4.6 / Sonnet 4.6 in adaptive mode. The direct Anthropic and Vertex AI paths were already correct (ReasoningTransform strips top_p to None whenever is_reasoning_supported()). Opus 4.7/4.8 on Bedrock were also fine (ModelSpecificReasoning strips top_p before conversion). The only broken combo was AdaptiveFriendly models (Opus 4.6, Sonnet 4.6) on Bedrock where top_p was passed through untouched alongside thinking.adaptive. Fix: change the adjusted_top_p guard from emits_legacy_thinking to reasoning_on. Update the test that previously asserted adaptive thinking left top_p untouched.
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.
What
ModelSpecificReasoningnormalizesreasoningper model family before the Bedrock conversion runs. Previously thetop_p >= 0.95clamp inConverseStreamInput::from_domainfired only when the legacythinking.enabled(budget) shape was being emitted. This change applies the clamp whenever any thinking shape is active (reasoning_on), coveringthinking.adaptive(Opus 4.6 / Sonnet 4.6) as well.The only broken combo was AdaptiveFriendly models (Opus 4.6, Sonnet 4.6) on Bedrock, where
top_pwas passed through untouched alongsidethinking.adaptive. Opus 4.7 / 4.8 are unaffected (ModelSpecificReasoningstripstop_ptoNonefor them before conversion), and the direct Anthropic / Vertex paths were already correct.Why
Anthropic-on-Bedrock rejects
top_p < 0.95for adaptive thinking, not just the legacy budget shape. Confirmed against the live endpoint — without this fix, an adaptive-thinking request withtop_p < 0.95returns:With the fix applied, the request succeeds (no error).
Test
test_from_domain_context_adaptive_thinking_does_not_clamp_top_p->..._clamps_top_pand inverted the assertion (top_p >= 0.95). This reverses the earlier assumption that adaptive thinking should leavetop_puntouched.cargo test -p forge_repopasses.