Skip to content

fix(anthropic): narrow dot→hyphen normalization to Claude models only (#17171)#17454

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-d4496357
Apr 29, 2026
Merged

fix(anthropic): narrow dot→hyphen normalization to Claude models only (#17171)#17454
teknium1 merged 1 commit into
mainfrom
hermes/hermes-d4496357

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #17290 by @vominh1919 onto current main.

Summary

The Anthropic adapter no longer hyphen-mangles non-Claude model names. gpt-5.4 routed through the Anthropic adapter now reaches the wire as gpt-5.4 instead of gpt-5-4.

Root cause

normalize_model_name() in agent/anthropic_adapter.py unconditionally did model.replace('.', '-') on every non-Bedrock model. This is only correct for Anthropic's own claude-* 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 custom anthropic_messages endpoint, or a webui session where provider auto-detection falls back to Anthropic without inferring openai-codex from gpt-*).

Fix

Guard the replacement with a Claude/Anthropic prefix check (case-insensitive). Everything else passes through unchanged. Bedrock guard unchanged.

Validation

Input Before After
claude-opus-4.6 claude-opus-4-6 claude-opus-4-6
anthropic/claude-sonnet-4.5 claude-sonnet-4-5 claude-sonnet-4-5
gpt-5.4 gpt-5-4 gpt-5.4
gemini-2.5-pro gemini-2-5-pro gemini-2.5-pro
z-ai/glm-5.1 z-ai/glm-5-1 z-ai/glm-5.1
us.anthropic.claude-sonnet-4-6 preserved ✓ preserved ✓

tests/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)

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
@teknium1 teknium1 merged commit 7141cda into main Apr 29, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-d4496357 branch April 29, 2026 13:35
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

3 participants