fix(bedrock): preserve dots in Bedrock model IDs during normalization - #12778
Closed
chhanz wants to merge 1 commit into
Closed
fix(bedrock): preserve dots in Bedrock model IDs during normalization#12778chhanz wants to merge 1 commit into
chhanz wants to merge 1 commit into
Conversation
normalize_model_name() unconditionally replaces all dots with hyphens, which breaks Bedrock model IDs where dots are structural separators (e.g. global.anthropic.claude-opus-4-6-v1 becomes the invalid global-anthropic-claude-opus-4-6-v1). This causes all Claude models on Bedrock to fail with "The provided model identifier is invalid" while Nova models (which use the bedrock_converse path) work fine. Add _is_bedrock_model_id() helper to detect Bedrock-native IDs by their regional/vendor prefixes and skip dot-to-hyphen conversion for them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
13 tasks
Contributor
|
Thanks for the contribution @chhanz! This fix has been implemented on This is an automated hermes-sweeper review. The same bug was fixed by a parallel PR (#12295) which merged on 2026-04-23 as commit
Member @alt-glitch also flagged the competing PRs (#13821, #13112, #11700) in their review comment. Your analysis and test cases were solid — they just arrived slightly after another fix landed. Closing as implemented on main. |
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 does this PR do?
normalize_model_name()unconditionally replaces all dots with hyphens, which breaks Bedrock model IDs where dots are structural separators (e.g.global.anthropic.claude-opus-4-6-v1becomes the invalidglobal-anthropic-claude-opus-4-6-v1). This causes all Claude models on Bedrock to fail withValidationException: The provided model identifier is invalid, while Nova models (which use thebedrock_conversepath) work fine.This PR adds a
_is_bedrock_model_id()helper to detect Bedrock-native IDs by their regional/vendor prefixes and skips dot-to-hyphen conversion for them.Root Cause
normalize_model_name()was designed for OpenRouter-style names (claude-opus-4.6→claude-opus-4-6) but did not account for Bedrock-native IDs where dots delimitregion/vendor/model hierarchy.
Related Issue
Type of Change
Changes Made
agent/anthropic_adapter.py: Added_is_bedrock_model_id()helper that detects Bedrock model ID patterns by regional prefixes (global.,us.,eu.,ap.,apac.,jp.) andfoundation model prefix (
anthropic.claude)agent/anthropic_adapter.py: Modifiednormalize_model_name()to return early (preserving dots) when_is_bedrock_model_id()returns Truetests/agent/test_anthropic_adapter.py: AddedTestIsBedrockModelIdclass andtest_preserves_dots_in_bedrock_model_idstest method (6 new test cases)How to Test
ap-northeast-2)global.anthropic.claude-opus-4-6-v1)Before fix:
ValidationException: The provided model identifier is invalid.After fix: Normal response from Claude via AnthropicBedrock SDK
Affected Model ID Patterns
global.anthropic.claude-opus-4-6-v1apac.anthropic.claude-sonnet-4-20250514-v1:0anthropic.claude-opus-4-6-v1claude-opus-4.6claude-opus-4-6✓)anthropic/claude-sonnet-4.6claude-sonnet-4-6✓)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/Aguide — or N/A
Screenshots / Logs
Error log (before fix)
ERROR root: API call failed after 3 retries. An error occurred (ValidationException)
when calling the ConverseStream operation: The provided model identifier is invalid.
| provider=bedrock model=global.anthropic.claude-opus-4-7 msgs=2 tokens=~3,106
Test results (after fix)
$ venv/bin/python -m pytest tests/agent/test_anthropic_adapter.py -q
126 passed in 5.12s
Verification