Skip to content

fix: set api_mode when switching providers via hermes model#3726

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-ab59de22
Mar 29, 2026
Merged

fix: set api_mode when switching providers via hermes model#3726
teknium1 merged 1 commit intomainfrom
hermes/hermes-ab59de22

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

When switching providers via hermes model, the previous provider's api_mode persisted in config.yaml. Switching from Copilot (codex_responses) to a chat_completions provider like Z.AI would leave the stale api_mode, causing 404s.

Salvaged from #3686 by @HenkDz with authorship preserved. Fixes #3685.

Changes

  • hermes_cli/main.py: add model["api_mode"] = "chat_completions" in 4 provider flows (OpenRouter, custom, Kimi, api_key_provider)

Live test

Verified with isolated HERMES_HOME: stale codex_responses correctly overwritten to chat_completions after provider switch, runtime resolver picks up the new value.

When switching providers via 'hermes model', the previous provider's
api_mode persisted in config.yaml. Switching from Copilot
(codex_responses) to a chat_completions provider like Z.AI would send
requests to the wrong endpoint (404).

Set api_mode = chat_completions in the 4 provider flows that were
missing it: OpenRouter, custom endpoint, Kimi, and api_key_provider.

Co-authored-by: Nour Eddine Hamaidi <HenkDz@users.noreply.github.com>
@teknium1 teknium1 merged commit 909de72 into main Mar 29, 2026
5 checks passed
teknium1 added a commit that referenced this pull request Mar 30, 2026
…pletions

PR #3726 fixed stale codex_responses persisting when switching providers
by hardcoding api_mode=chat_completions in 5 model flows. This broke
MiniMax, MiniMax-CN, and Alibaba which use /anthropic endpoints that
need anthropic_messages — the hardcoded value overrides the URL-based
auto-detection in runtime_provider.py.

Fix: pop api_mode from config in the 3 URL-dependent flows (custom
endpoint, Kimi, api_key_provider) instead of hardcoding. The runtime
resolver already correctly auto-detects api_mode from the base_url
suffix (/anthropic -> anthropic_messages, else chat_completions).

OpenRouter and Copilot ACP flows keep the explicit value since their
api_mode is always known.

Reported by stefan171.
teknium1 added a commit that referenced this pull request Mar 30, 2026
…pletions (#3857)

PR #3726 fixed stale codex_responses persisting when switching providers
by hardcoding api_mode=chat_completions in 5 model flows. This broke
MiniMax, MiniMax-CN, and Alibaba which use /anthropic endpoints that
need anthropic_messages — the hardcoded value overrides the URL-based
auto-detection in runtime_provider.py.

Fix: pop api_mode from config in the 3 URL-dependent flows (custom
endpoint, Kimi, api_key_provider) instead of hardcoding. The runtime
resolver already correctly auto-detects api_mode from the base_url
suffix (/anthropic -> anthropic_messages, else chat_completions).

OpenRouter and Copilot ACP flows keep the explicit value since their
api_mode is always known.

Reported by stefan171.
itsXactlY pushed a commit to itsXactlY/hermes-agent that referenced this pull request Mar 30, 2026
…pletions (NousResearch#3857)

PR NousResearch#3726 fixed stale codex_responses persisting when switching providers
by hardcoding api_mode=chat_completions in 5 model flows. This broke
MiniMax, MiniMax-CN, and Alibaba which use /anthropic endpoints that
need anthropic_messages — the hardcoded value overrides the URL-based
auto-detection in runtime_provider.py.

Fix: pop api_mode from config in the 3 URL-dependent flows (custom
endpoint, Kimi, api_key_provider) instead of hardcoding. The runtime
resolver already correctly auto-detects api_mode from the base_url
suffix (/anthropic -> anthropic_messages, else chat_completions).

OpenRouter and Copilot ACP flows keep the explicit value since their
api_mode is always known.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants