Skip to content

fix(agent): preserve dots in model names for custom providers#16429

Open
vominh1919 wants to merge 1 commit into
NousResearch:mainfrom
vominh1919:fix/anthropic-custom-preserve-dots
Open

fix(agent): preserve dots in model names for custom providers#16429
vominh1919 wants to merge 1 commit into
NousResearch:mainfrom
vominh1919:fix/anthropic-custom-preserve-dots

Conversation

@vominh1919

Copy link
Copy Markdown
Contributor

Problem

When using a custom provider with the anthropic_messages protocol, normalize_model_name() converts dots to hyphens in model names (e.g. claude-sonnet-4.6claude-sonnet-4-6). This is correct for the Anthropic API but wrong for custom endpoints that expect the model name unchanged.

_anthropic_preserve_dots() has an allowlist of providers that preserve dots, but "custom" is not included.

Fix

Add "custom" to the provider set in _anthropic_preserve_dots(). When the provider is "custom", the user has explicitly configured an external endpoint with a specific model name — dot-to-hyphen conversion is Anthropic-specific and must not be applied.

Affected model names: claude-sonnet-4.6, glm-4.7, qwen3.5-plus, MiniMax-M2.7, etc.

Tests

New regression test in tests/agent/test_custom_preserve_dots.py:

  • Custom provider preserves dots
  • Custom with base_url preserves dots
  • Anthropic provider still converts dots (no regression)
  • Known allowlist providers still work

Fixes #16417
Fixes #13061

Custom providers point at user-configured endpoints. The dot-to-hyphen
conversion in normalize_model_name() is specific to the Anthropic API
(claude-opus-4.6 -> claude-opus-4-6) and must not be applied when the
user explicitly configured a model name on a custom provider.

Add custom to _anthropic_preserve_dots() so model names like
claude-sonnet-4.6, glm-4.7, qwen3.5-plus are sent unchanged.

Fixes NousResearch#16417
Fixes NousResearch#13061
@EurFelux

Copy link
Copy Markdown

Personal opinion: At the end of the day, adopting a whitelist mechanism is a very poor design. The user-configured model should be trusted as valid, rather than applying such conversions by default. The default should be to not convert dots to hyphens, and only perform the replacement for providers that are known to require hyphens instead of dots.

@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 area/config Config system, migrations, profiles labels Apr 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13068 — same fix: add 'custom' to _anthropic_preserve_dots() provider set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles 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