fix: prevent double-prefixing of Bedrock cross-region inference models #12056
+215
−2
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.
Summary
Problem
Models from models.dev may already include cross-region inference profile prefixes like:
us.anthropic.claude-opus-4-5-20251101-v1:0→ "Claude Opus 4.5 (US)"eu.anthropic.claude-opus-4-5-20251101-v1:0→ "Claude Opus 4.5 (EU)"global.anthropic.claude-opus-4-5-20251101-v1:0→ "Claude Opus 4.5 (Global)"Previously, only
global.andjp.prefixes were checked, causing models withus.,eu.,apac., orau.prefixes to be double-prefixed (e.g.,us.us.anthropic.claude-...), which AWS rejects as invalid.Solution
Expanded the prefix check to include all cross-region inference profile prefixes:
global.us.eu.jp.apac.au.Models that already have a regional prefix are now passed through to the SDK without modification, while models without prefixes continue to get prefixed based on the user's region.
Backward Compatibility
This fix is backward compatible:
anthropic.claude-opus-4-5-20251101-v1:0) will continue to be prefixed based on the user's AWS regionus.anthropic.claude-opus-4-5-20251101-v1:0) will be used as-isFixes #12052