fix: handle Claude 4 Sonnet model identifier with cross-region inference #9183
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.
Description
This PR attempts to address Issue #9182 where AWS Bedrock's Claude 4 Sonnet model identifier becomes invalid when using cross-region inference in Roo Code 3.30.2 and above.
Problem
When using the model
anthropic.claude-sonnet-4-20250514-v1:0with AWS Bedrock, users were getting "The provided model identifier is invalid" errors. This was happening because when cross-region inference is enabled, the model ID gets prefixed (e.g.,us.anthropic.claude-sonnet-4-20250514-v1:0), but the prefixed ID wasn't being properly handled when looking up model information.Solution
getModelByIdmethod to use the base model ID (without prefix) when looking up unknown models inguessModelInfoFromIdguessModelInfoFromIdto recognize Claude 4 Sonnet and Claude 4.5 Sonnet model patternsTesting
bedrock-claude-4-sonnet.spec.tswith 11 test cases covering various scenariosRelated Issue
Fixes #9182
Feedback and guidance are welcome!
Important
Fixes handling of Claude 4 Sonnet model identifiers in AWS Bedrock for cross-region inference by updating model ID processing and adding tests.
getModelByIdinbedrock.tsto use base model ID without prefix for unknown models.guessModelInfoFromIdinbedrock.tsto recognize Claude 4 Sonnet and Claude 4.5 Sonnet patterns.bedrock-claude-4-sonnet.spec.tswith 11 test cases for cross-region, global inference, and 1M context scenarios.This description was created by
for 191a026. You can customize this summary. It will automatically update as commits are pushed.