Skip to content

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

Closed
HenkDz wants to merge 1 commit intoNousResearch:mainfrom
HenkDz:fix/api-mode-reset-on-provider-switch
Closed

fix: set api_mode when switching providers via hermes model#3686
HenkDz wants to merge 1 commit intoNousResearch:mainfrom
HenkDz:fix/api-mode-reset-on-provider-switch

Conversation

@HenkDz
Copy link
Copy Markdown
Contributor

@HenkDz HenkDz commented Mar 29, 2026

Summary

hermes model does not update api_mode in ~/.hermes/config.yaml when switching to most providers. The previous provider's api_mode persists, causing requests to the wrong endpoint.

The bug

Switching from Copilot (api_mode: codex_responses) to Z.AI leaves the stale api_mode: codex_responses in config. Z.AI doesn't support /v4/responses, so every request fails with 404.

The fix

Set model.api_mode = "chat_completions" in all provider flows that use the chat completions API surface:

Flow Before After
OpenRouter no api_mode set chat_completions
Custom endpoint no api_mode set chat_completions
Kimi / Moonshot no api_mode set chat_completions
Z.AI / MiniMax no api_mode set chat_completions
Copilot already correct unchanged
Copilot-ACP already correct unchanged

Testing

  • Verified that resolveProvider() in the Paperclip adapter correctly falls back to model-name inference when config model doesn't match requested model
  • Confirmed the 4 new lines match the existing pattern used by Copilot-ACP (line 1887)

Fixes #3685

When switching providers with 'hermes model', the api_mode field in
config.yaml was not updated for most providers (Z.AI, MiniMax, Kimi,
OpenRouter, Custom). The previous provider's api_mode persisted,
causing requests to hit the wrong API endpoint path.

For example, switching from Copilot (codex_responses) to Z.AI left
api_mode: codex_responses, causing 404 on /v4/responses.

Set api_mode: chat_completions for all chat-completions-based providers:
- OpenRouter
- Custom endpoints
- Kimi / Moonshot
- Z.AI / MiniMax (generic API-key provider flow)

Copilot and Copilot-ACP flows already correctly set api_mode.

Fixes NousResearch#3685
@HenkDz
Copy link
Copy Markdown
Contributor Author

HenkDz commented Mar 29, 2026

@teknium1 I do not think the Failed test is realted to our changes, it checks for the string "remote environment" in a skill invocation message that was apparently reworded in a prior commit.

@teknium1
Copy link
Copy Markdown
Contributor

Merged via #3726 — cherry-picked onto current main with authorship preserved, live tested. Thanks @HenkDz!

@teknium1 teknium1 closed this Mar 29, 2026
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