Skip to content

[Bug] hermes model doesn't reset api_mode when switching providers #3685

@HenkDz

Description

@HenkDz

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

  1. Configure Hermes for Copilot:
    model:
      default: gpt-5.4
      provider: copilot
      base_url: https://api.githubcopilot.com
      api_mode: codex_responses
  2. Run hermes model and select Z.AI → GLM-5-turbo
  3. 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
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions