-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[Bug] hermes model doesn't reset api_mode when switching providers #3685
Description
Bug Description
When switching providers via hermes model, the api_mode field in ~/.hermes/config.yaml is not updated for API-key providers (Z.AI, MiniMax, Kimi). The previous provider's api_mode value persists, causing requests to hit the wrong API endpoint path.
Steps to Reproduce
- Configure Hermes for Copilot:
model: default: gpt-5.4 provider: copilot base_url: https://api.githubcopilot.com api_mode: codex_responses
- Run
hermes modeland select Z.AI → GLM-5-turbo - Config is updated to:
model: default: glm-5-turbo provider: zai base_url: https://api.z.ai/api/coding/paas/v4 api_mode: codex_responses # stale - should be chat_completions
- Run any query → Hermes sends POST to
/v4/responses→ HTTP 404
Expected Behavior
hermes model should set api_mode appropriately for each provider when switching. At minimum, the generic API-key provider flow (_model_flow_api_key_provider) should either set api_mode: chat_completions (the correct default for Z.AI, MiniMax, Kimi) or clear the existing api_mode so Hermes falls back to its default.
Actual Behavior
api_mode is left untouched from the previous provider. Only model.default, model.provider, and model.base_url are written.
Root Cause
In hermes_cli/main.py, the _model_flow_api_key_provider() function (line ~2091) writes:
model["provider"] = provider_id
model["base_url"] = effective_base
save_config(cfg)But never touches model["api_mode"]. Compare with the Copilot flow (line ~1771) which correctly calls copilot_model_api_mode() to determine the right api_mode.
This affects all providers that go through _model_flow_api_key_provider: Z.AI, MiniMax, Kimi.
Environment
- OS: Ubuntu/WSL2
- Python: 3.11
- Hermes Agent: v0.4.0+
Related
- Fix OpenCode model selection, normalization, and mixed API-surface routing #3014 — Similar
api_modeissue but specific to OpenCode providers - Discovered when debugging Paperclip agent runs that routed GPT-5.4 to Z.AI due to provider mismatch, which then hit
/v4/responsesbecauseapi_mode: codex_responseswas left over from a Copilot session