fix(anthropic): narrow dot→hyphen normalization to Claude models only (#17171)#17454
Merged
Conversation
The normalize_model_name() function unconditionally converted dots to hyphens in all model names. This caused non-Anthropic models (e.g. gpt-5.4) to be mangled to gpt-5-4 when routed through the Anthropic adapter path, resulting in HTTP 404 from the backend. Now only applies dot-to-hyphen conversion for models starting with "claude-" or "anthropic/", which are the actual Anthropic model IDs. Fixes #17171 Related: #7421, #13061, #16417
This was referenced Apr 29, 2026
5 tasks
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.
Salvage of #17290 by @vominh1919 onto current main.
Summary
The Anthropic adapter no longer hyphen-mangles non-Claude model names.
gpt-5.4routed through the Anthropic adapter now reaches the wire asgpt-5.4instead ofgpt-5-4.Root cause
normalize_model_name()inagent/anthropic_adapter.pyunconditionally didmodel.replace('.', '-')on every non-Bedrock model. This is only correct for Anthropic's ownclaude-*IDs — any other model ID with dots (gpt-5.4,gemini-2.5-pro,z-ai/glm-5.1,qwen3.5-plus) got mangled when it landed on this code path (e.g. a customanthropic_messagesendpoint, or a webui session where provider auto-detection falls back to Anthropic without inferring openai-codex fromgpt-*).Fix
Guard the replacement with a Claude/Anthropic prefix check (case-insensitive). Everything else passes through unchanged. Bedrock guard unchanged.
Validation
claude-opus-4.6claude-opus-4-6✓claude-opus-4-6✓anthropic/claude-sonnet-4.5claude-sonnet-4-5✓claude-sonnet-4-5✓gpt-5.4gpt-5-4✗gpt-5.4✓gemini-2.5-progemini-2-5-pro✗gemini-2.5-pro✓z-ai/glm-5.1z-ai/glm-5-1✗z-ai/glm-5.1✓us.anthropic.claude-sonnet-4-6tests/agent/test_anthropic_adapter.py: 138/138 pass.Fixes #17171
Fixes #13061
Related: #16417 (partial — helps non-Claude IDs on custom anthropic_messages endpoints; does not help Claude IDs whose upstream wants the dot form)