Skip to content

fix: clear api_mode on provider switch instead of hardcoding chat_completions#3857

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-deb3d2ef
Mar 30, 2026
Merged

fix: clear api_mode on provider switch instead of hardcoding chat_completions#3857
teknium1 merged 1 commit intomainfrom
hermes/hermes-deb3d2ef

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Fixes a regression from PR #3726 (merged today) that broke MiniMax, MiniMax-CN, and Alibaba provider switching.

Problem

PR #3726 fixed stale codex_responses persisting after switching from Codex by hardcoding api_mode = "chat_completions" in 5 model flows. But MiniMax uses https://api.minimax.io/anthropic which needs anthropic_messages — the hardcoded value overrides the URL-based auto-detection in runtime_provider.py, causing the OpenAI SDK to hit POST .../anthropic/chat/completions → 404.

Affected providers: MiniMax, MiniMax-CN, Alibaba (all use /anthropic endpoints).

Fix

Replace model["api_mode"] = "chat_completions" with model.pop("api_mode", None) in 3 URL-dependent flows:

  • _model_flow_custom — user could enter an /anthropic URL
  • _model_flow_kimi — safe to auto-detect
  • _model_flow_api_key_provider — MiniMax/Alibaba use /anthropic

The runtime resolver in runtime_provider.py already 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_completions since their api_mode is always known.

E2E Verified

Switch api_mode Status
Codex → MiniMax (/anthropic) anthropic_messages
Codex → Z.AI (/v4) chat_completions
Codex → Custom /anthropic anthropic_messages
Codex → Alibaba /anthropic anthropic_messages
Codex → MiniMax-CN /anthropic anthropic_messages
Codex → Kimi (/v1) chat_completions
Codex → HuggingFace (/v1) chat_completions
OpenRouter (explicit) chat_completions
resolve_runtime_provider(requested="minimax") anthropic_messages

754 hermes_cli tests pass.

Reported by stefan171.

…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 teknium1 merged commit 981e140 into main Mar 30, 2026
5 checks passed
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.

1 participant