Skip to content

fix: narrow Anthropic adapter dot-mangling to Claude models only (#17171)#17290

Closed
vominh1919 wants to merge 1 commit into
NousResearch:mainfrom
vominh1919:fix/anthropic-adapter-dot-mangling
Closed

fix: narrow Anthropic adapter dot-mangling to Claude models only (#17171)#17290
vominh1919 wants to merge 1 commit into
NousResearch:mainfrom
vominh1919:fix/anthropic-adapter-dot-mangling

Conversation

@vominh1919

Copy link
Copy Markdown
Contributor

Problem

normalize_model_name() in agent/anthropic_adapter.py unconditionally converts dots to hyphens in all model names (line 1117). This causes non-Anthropic models to be mangled when routed through the Anthropic adapter path:

  • gpt-5.4gpt-5-4 → HTTP 404 from Codex backend
  • gemini-2.5-progemini-2-5-pro → would fail similarly

This affects the webui session route when resolve_model_provider() doesn't infer the provider from the model name, and the Anthropic adapter is auto-selected as default.

Fix

Added a guard in normalize_model_name() to only apply dot→hyphen conversion for models that look like Anthropic models (claude-* or anthropic/*). Non-Anthropic models pass through unchanged.

Before:

model = model.replace(".", "-")  # ALL models

After:

_lower = model.lower()
if _lower.startswith("claude-") or _lower.startswith("anthropic/"):
    model = model.replace(".", "-")  # Only Anthropic models

Before vs After

Model 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
Bedrock IDs preserved (existing guard) preserved (unchanged)

Tests

All existing tests pass — they all use Claude model names which still get dot→hyphen conversion.

Fixes #17171
Related: #7421, #13061, #16417

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 NousResearch#17171
Related: NousResearch#7421, NousResearch#13061, NousResearch#16417
@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
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing PR with #17282 — both fix normalize_model_name() dot-mangling for non-Claude models (#17171). #17282 includes test updates; this PR is more minimal.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #17454 (commit 7141cda). Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for the clean fix and the clear before/after table!

@teknium1 teknium1 closed this 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

Development

Successfully merging this pull request may close these issues.

openai-codex fallback sends 'gpt-5-4' instead of 'gpt-5.4' to Codex backend, returning HTTP 404

3 participants