Skip to content

[Bug] zai provider ignores config.yaml base_url and always probes endpoints in hardcoded order — standard endpoint always wins over coding endpoint #58071

Description

@wyl1988

Bug Description

The zai provider's _resolve_zai_base_url() function in hermes_cli/auth.py completely ignores the base_url configured in config.yaml. Instead, it probes a hardcoded list of 4 endpoints in order:

ZAI_ENDPOINTS = [
    ("global",        "https://api.z.ai/api/paas/v4"),
    ("cn",            "https://open.bigmodel.cn/api/paas/v4"),
    ("coding-global", "https://api.z.ai/api/coding/paas/v4"),
    ("coding-cn",     "https://open.bigmodel.cn/api/coding/paas/v4"),
]

The same API key works on both standard and coding endpoints. Since probing takes the first endpoint that succeeds, standard endpoints always win — coding endpoints (positions 3-4) are unreachable.

Related issue #51229 addresses cache persistence but not the core problem: config.yaml's base_url field is ignored entirely.

Impact

Zhipu AI offers separate Coding Plan endpoints (/coding/paas/v4) with different quota/pricing. Users who configure base_url: https://open.bigmodel.cn/api/coding/paas/v4 in config.yaml expect all requests to go through that endpoint. Instead:

  1. config.yaml's base_url is silently ignored
  2. Every gateway restart triggers endpoint probing
  3. Each probe sends a glm-5, max_tokens=1 test request to the standard endpoint — wasting tokens
  4. The standard endpoint is always selected first
  5. All subsequent requests burn standard-endpoint quota

In a 20-profile deployment, switching from hindsight to openviking required gateway restarts that triggered mass re-probing, accidentally routing all traffic to standard endpoints for days before detection.

Workaround

Set environment variable GLM_BASE_URL (source line 670-671 in auth.py). This bypasses probing entirely:

if env_override:
    return env_override

But this requires setting GLM_BASE_URL in every .env file, every systemd Environment= directive, AND every EnvironmentFile — because EnvironmentFile silently overrides Environment for same-named variables.

Expected Behavior

config.yaml's base_url should be respected as the authoritative endpoint. Probing should only be a fallback when base_url is not explicitly configured.

# Proposed priority:
# 1. GLM_BASE_URL env var (current — keep)
# 2. config.yaml base_url (NEW — currently ignored!)
# 3. auth.json cached detection (current — keep)
# 4. Live probing (current — last resort only)

Environment

  • Hermes Agent: 0.18.0
  • Provider: zai (Zhipu AI / Z.AI)
  • Deployment: 20 profiles, all using GLM-5.2 via coding endpoint
  • Issue discovered: 2026-06-27, affecting all 20 profiles

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/cliCLI entry point, hermes_cli/, setup wizardprovider/zaiZAI providertype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions