Fix Bedrock thinking effort mapping for Claude models (#851) - #855
Open
Edilbek wants to merge 2 commits into
Open
Fix Bedrock thinking effort mapping for Claude models (#851)#855Edilbek wants to merge 2 commits into
Edilbek wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #855 +/- ##
==========================================
+ Coverage 83.18% 83.30% +0.12%
==========================================
Files 173 175 +2
Lines 8461 8798 +337
Branches 1373 1423 +50
==========================================
+ Hits 7038 7329 +291
- Misses 925 941 +16
- Partials 498 528 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
justwiebe
reviewed
Jul 29, 2026
justwiebe
reviewed
Jul 29, 2026
|
Looks good, although I'm not a reviewer on the project |
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 this does
Fixes #851.
Extended thinking on Bedrock Claude models (Sonnet 5, and every other Claude on Bedrock) raised
RubyLLM::BadRequestError: The model returned the following errors: reasoning_effort: Extra inputs are not permittedwheneverwith_thinking(effort:)was used.The Converse protocol branched on
reasoningSupported.embeddedmetadata to decide how to send thinking params. That flag is unrelated to how a model accepts reasoning input, and it'sfalsefor every Bedrock Claude, so effort-based thinking always fell into a{ reasoning_effort: ... }branch. Bedrock forwardsadditionalModelRequestFieldsstraight to Anthropic, which rejects the unknownreasoning_effortkey.Bedrock actually publishes each model's accepted fields in
converse.additionalRequestFieldsSchema. Claude models expose areasoningConfig.budgetTokensschema and only accept a token budget, never an effort level. This PR:reasoning_embedded?check withreasoning_budget_schema, which reads that published schema.effortonto a budget: enumerated schemas use the token value they name for each level (e.g. Sonnet 5low → 1024,medium → 40000,high → 63999); integer-range schemas spread low/medium/high across the range; efforts a schema doesn't enumerate clamp to its maximum.reasoning_effortfor models whose schema advertises no budget (e.g.openai.gpt-oss-120b).budget:overeffort:, and clamps a derived budget belowmax_output_tokenswhen one is set so it can't consume the whole output allowance.eu./global./bareanthropic.ids still failed.Type of change
Scope check
Required for new features
N/A — bug fix.
Quality check
overcommit --installand all hooks passbundle exec rake vcr:record[provider_name]bundle exec rspecmodels.json,aliases.json)AI-generated code
API changes
Notes for the maintainer:
spec/ruby_llm/protocols/converse/chat_spec.rbasserting the emitted payload, plus a WebMock-stubbed end-to-end reproduction. The derived payload shape matches what the existing budget-based Bedrock cassettes already send, but you may want to add{ provider: :bedrock, model: 'claude-sonnet-5' }to the thinking models and record one.