hermes - ✅(Solved) Fix [Bug]: model switch can persist models.dev kimi-for-coding alias instead of Hermes kimi-coding provider [2 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#25105Fetched 2026-05-14 03:48:57
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4cross-referenced ×2

Root Cause

Provider aliases from external catalog metadata are not normalized consistently before persistence/runtime handoff.

Fix Action

Fixed

PR fix notes

PR #25131: fix(agent): persist complete model runtime state on /model switch

Description (problem / solution / changelog)

Summary

Both gateway /model and CLI /model --global now persist the complete runtime tuple to config.yaml:

model.default
model.provider
model.base_url      # NEW: was missing or conditionally written
model.api_mode      # NEW: was never persisted

Before

Gateway /model (gateway/run.py):

model_cfg["default"] = result.new_model
model_cfg["provider"] = result.target_provider
if result.base_url:                    # ← only writes when truthy
    model_cfg["base_url"] = result.base_url
# api_mode: never persisted

CLI /model --global (cli.py, 2 locations):

save_config_value("model.default", result.new_model)
if result.provider_changed:
    save_config_value("model.provider", result.target_provider)
# base_url: never persisted
# api_mode: never persisted

After

Gateway — unconditional with empty-string clearing:

model_cfg["base_url"] = result.base_url or ""
model_cfg["api_mode"] = result.api_mode or ""

CLI — two additional save_config_value calls:

save_config_value("model.base_url", result.base_url or "")
save_config_value("model.api_mode", result.api_mode or "")

Impact

Fixes the class of bugs where switching models leaves stale endpoint/protocol state:

ScenarioBeforeAfter
Switch from custom → built-in providerOld base_url survivesCleared to ""
Switch from anthropic_messages → openaiOld api_mode survivesCleared to ""
Switch to a provider with explicit base_urlNot persisted (CLI)Persisted correctly
Restart gateway after /model switchMay use stale endpointUses correct state

Testing

  • 5 new tests covering all persistence paths
  • 29 existing model-switch tests passing (0 regressions)

Files changed

FileChange
gateway/run.pyPersist base_url + api_mode unconditionally
cli.pyAdd save_config_value for base_url + api_mode (2 locations)
tests/gateway/test_model_switch_config_persistence.pyNew: 5 tests

Closes #25107 Closes #25106 See also #25105 (kimi-for-coding alias normalization — separate issue)

Changed files

  • cli.py (modified, +6/-0)
  • gateway/run.py (modified, +3/-2)
  • tests/gateway/test_model_switch_config_persistence.py (added, +209/-0)

PR #25136: fix: canonicalize Kimi provider alias

Description (problem / solution / changelog)

Bug

Hermes uses kimi-coding / kimi-coding-cn for runtime, auth, and config, but models.dev may identify the endpoint family as kimi-for-coding. Persisting the models.dev alias leaves downstream runtime/config paths with an unknown or wrong provider id.

Fixes #25105

Summary

Canonicalize kimi-for-coding during model switching to the correct Hermes provider id before resolving credentials or persisting config. The fix preserves the China Kimi variant when the user requested kimi-coding-cn / kimi-cn / moonshot-cn.

TDD / ATDD coverage

  • Added a focused regression test that reproduces the reported behavior.
  • Implemented the minimal production change needed to satisfy the regression.
  • Re-ran the targeted test file to guard nearby behavior.

Test plan

  • /Users/mudrii/src/hermes/hermes-agent/venv/bin/python -m pytest tests/hermes_cli/test_model_switch_custom_providers.py -q -o 'addopts=' -> 20 passed

Review notes

  • Kept the change scoped to the issue-specific runtime path.
  • No secrets are persisted or logged.

Changed files

  • hermes_cli/model_switch.py (modified, +11/-0)
  • hermes_cli/providers.py (modified, +2/-0)
  • tests/hermes_cli/test_model_switch_custom_providers.py (modified, +97/-0)

Code Example

kimi
kimi-coding
kimi-for-coding
moonshot

---

model:
  provider: kimi-coding
RAW_BUFFERClick to expand / collapse

Bug Description

Hermes uses kimi-coding as the canonical provider ID for Kimi Coding runtime/auth/config paths, while models.dev exposes the endpoint family as kimi-for-coding.

During model switching, Hermes can resolve/persist the models.dev provider alias instead of the Hermes-native provider ID. That creates inconsistent config/runtime state and can lead downstream code to treat kimi-for-coding as an unknown provider or fall back to the wrong default provider.

Expected Behavior

If a user requests any of these aliases:

kimi
kimi-coding
kimi-for-coding
moonshot

and the selected endpoint is Kimi Coding, Hermes should persist the canonical Hermes provider ID:

model:
  provider: kimi-coding

Model IDs can still come from the catalog, but the provider ID used by Hermes runtime/auth/config should be canonical.

Actual Behavior

Current model switch paths can allow kimi-for-coding to leak into provider state, while other runtime/auth paths expect kimi-coding.

This causes confusing behavior such as:

  • provider resolver warnings for unknown provider 'kimi-for-coding'
  • fallback to default provider/model
  • inconsistent behavior between CLI, gateway, auxiliary, and runtime code

Reproduction

  1. Configure Kimi Coding credentials.
  2. Use model switch / model picker to select a Kimi Coding model exposed via models.dev.
  3. Inspect the persisted provider/config or runtime provider resolution.
  4. Observe kimi-for-coding can appear where Hermes expects kimi-coding.

Root Cause

Provider aliases from external catalog metadata are not normalized consistently before persistence/runtime handoff.

Suggested Fix

Normalize kimi-for-coding to kimi-coding before saving or passing provider IDs into Hermes runtime/auth/config paths.

A minimal guard in model switching should canonicalize when the explicit requested provider is Kimi-related and the detected provider is kimi-for-coding.

Related Existing Reports / PRs

This is a focused current-main report related to:

  • #12296
  • #12338

It is also related to the Kimi base URL transport issue:

  • #21297
  • #24462

Environment

  • Hermes Agent current main around commit 4fdfdf674
  • Provider family: Kimi Coding / Moonshot

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: model switch can persist models.dev kimi-for-coding alias instead of Hermes kimi-coding provider [2 pull requests, 1 participants]