fix: set api_mode when switching providers via hermes model#3726
Merged
fix: set api_mode when switching providers via hermes model#3726
Conversation
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When switching providers via
hermes model, the previous provider'sapi_modepersisted 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: addmodel["api_mode"] = "chat_completions"in 4 provider flows (OpenRouter, custom, Kimi, api_key_provider)Live test
Verified with isolated HERMES_HOME: stale
codex_responsescorrectly overwritten tochat_completionsafter provider switch, runtime resolver picks up the new value.