fix: clear api_mode on provider switch instead of hardcoding chat_completions#3857
Merged
fix: clear api_mode on provider switch instead of hardcoding chat_completions#3857
Conversation
…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.
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
Fixes a regression from PR #3726 (merged today) that broke MiniMax, MiniMax-CN, and Alibaba provider switching.
Problem
PR #3726 fixed stale
codex_responsespersisting after switching from Codex by hardcodingapi_mode = "chat_completions"in 5 model flows. But MiniMax useshttps://api.minimax.io/anthropicwhich needsanthropic_messages— the hardcoded value overrides the URL-based auto-detection inruntime_provider.py, causing the OpenAI SDK to hitPOST .../anthropic/chat/completions→ 404.Affected providers: MiniMax, MiniMax-CN, Alibaba (all use
/anthropicendpoints).Fix
Replace
model["api_mode"] = "chat_completions"withmodel.pop("api_mode", None)in 3 URL-dependent flows:_model_flow_custom— user could enter an/anthropicURL_model_flow_kimi— safe to auto-detect_model_flow_api_key_provider— MiniMax/Alibaba use/anthropicThe runtime resolver in
runtime_provider.pyalready correctly auto-detects api_mode from the base_url suffix. Clearing the config value lets it work.OpenRouter and Copilot ACP flows keep the explicit
chat_completionssince their api_mode is always known.E2E Verified
/anthropic)anthropic_messages/v4)chat_completions/anthropicanthropic_messages/anthropicanthropic_messages/anthropicanthropic_messages/v1)chat_completions/v1)chat_completionschat_completionsresolve_runtime_provider(requested="minimax")anthropic_messages754 hermes_cli tests pass.
Reported by stefan171.