Skip to content

[Bug] normalize_model_name rewrites custom provider model IDs, breaking models with dots (e.g. z-ai/glm-5.1 via zenmux) #13061

@EurFelux

Description

@EurFelux

Bug Description

When using a custom provider with an Anthropic-compatible endpoint, Hermes still applies normalize_model_name(), which blindly converts dots to dashes in the model identifier. This breaks providers whose model IDs legitimately contain dots.

For example, with a custom provider configured for zenmux (https://zenmux.ai/api/anthropic) and model z-ai/glm-5.1:

  • User-configured model ID: z-ai/glm-5.1
  • After normalize_model_name(): z-ai/glm-5-1
  • zenmux API response: HTTP 404 — Requested model is not valid

The root cause is _anthropic_preserve_dots(), which only returns True for a hardcoded allowlist of built-in providers (alibaba, minimax, opencode-go, opencode-zen, zai, bedrock) or specific URL substrings. A custom provider like zenmux is not in that list, so its model name gets mangled even though the user explicitly configured the exact ID the upstream expects.

Steps to Reproduce

  1. Add a custom provider in ~/.hermes/config.yaml:
    custom_providers:
      - name: zenmux
        base_url: https://zenmux.ai/api/anthropic
        api_key: ""
        api_mode: anthropic_messages
        key_env: ZENMUX_API_KEY
    model:
      default: z-ai/glm-5.1
      provider: zenmux
  2. Start a chat (hermes).
  3. Observe fallback to another provider with:
    HTTP 404: Requested model is not valid
    
  4. Verify via direct SDK call that z-ai/glm-5.1 works, but z-ai/glm-5-1 returns the same 404.

Expected Behavior

For custom providers, Hermes should respect the user-configured model ID exactly as written. The user has already told Hermes what string the upstream expects; Hermes should not second-guess it with normalize_model_name().

Actual Behavior

normalize_model_name() converts z-ai/glm-5.1z-ai/glm-5-1, causing a 404 from the upstream.

Related Issues

Proposed Fix

Option A (preferred): Skip normalize_model_name() entirely when the provider is a custom provider, or at least default preserve_dots=True for custom providers and let the user opt into normalization if needed.

Option B: Extend _anthropic_preserve_dots() to detect custom providers and inspect the configured model name. If the original model string contains dots, preserve them.

Affected Component

CLI / Agent (agent/anthropic_adapter.py, run_agent.py)

Hermes Version

v0.8.0+

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions