Skip to content

fix(model_switch): group custom_providers by endpoint in /model picker (#9210)#14505

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-6cf13b49
Apr 23, 2026
Merged

fix(model_switch): group custom_providers by endpoint in /model picker (#9210)#14505
teknium1 merged 2 commits into
mainfrom
hermes/hermes-6cf13b49

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Four custom_providers: entries pointing at the same Ollama host with per-model display names ("Ollama — GLM 5.1", "Ollama — Qwen3-coder", ...) now collapse into one "Ollama" picker row with four models instead of four near-duplicate rows.

Salvaged from @davidvv's PR #9210. The code had diverged ~1400 commits since that PR was opened, so this is a reconstruction of the same approach on current main rather than a clean cherry-pick — authorship preserved via --author on the substantive commit.

Changes

  • hermes_cli/model_switch.py: grouping key changed from slug-by-name to (base_url, api_key). Per-model suffix stripped from display name ("Ollama — X" → "Ollama"). When grouped endpoint matches current_base_url, the row's slug becomes current_provider so picker-driven switches route through the live credential pipeline.
  • gateway/run.py: current_base_url plumbed through both list_authenticated_providers() call sites.
  • Slug-collision disambiguation: two groups with different api_keys at the same base_url (or otherwise colliding on cleaned name) get numeric-suffixed slugs (custom:openai, custom:openai-2) so both stay visible.
  • tests/hermes_cli/test_model_switch_custom_providers.py: 5 new tests covering grouping, current_base_url / is_current wiring, distinct-endpoints-stay-separate, same-url-different-keys disambiguation, grouped total_models accounting.

Validation

Before After
4 Ollama rows (shared endpoint, per-model suffixes) 4 separate rows, 1 model each 1 "Ollama" row, 4 models
current_base_url matches group is_current=False, opaque slug is_current=True, slug=current_provider
Distinct endpoints separate rows still separate rows
Same URL, different api_keys, identical cleaned names collapsed to 1 row 2 rows (custom:openai, custom:openai-2)

Regression coverage preserved: #8216 (models dict), #11499 (providers: + compat dedup), #13509 (list-format models via normalize) all still work — verified E2E.

Tests: tests/hermes_cli/test_model_switch_custom_providers.py 13/13 passing. Broader tests/hermes_cli/ 2575 passing + 1 unrelated failure (test_tips.py::test_max_length_reasonable — not my code). tests/gateway/ model-related 34/34 passing.

Closes #9210

David VV and others added 2 commits April 23, 2026 03:05
#9210)

Multiple custom_providers entries sharing the same base_url + api_key
are now grouped into a single picker row. A local Ollama host with
per-model display names ("Ollama — GLM 5.1", "Ollama — Qwen3-coder",
"Ollama — Kimi K2", "Ollama — MiniMax M2.7") previously produced four
near-duplicate picker rows that differed only by suffix; now it appears
as one "Ollama" row with four models.

Key changes:
- Grouping key changed from slug-by-name to (base_url, api_key). Names
  frequently differ per model while the endpoint stays the same.
- When the grouped endpoint matches current_base_url, the row's slug is
  set to current_provider so picker-driven switches route through the
  live credential pipeline (no re-resolution needed).
- Per-model suffix is stripped from the display name ("Ollama — X" →
  "Ollama") via em-dash / " - " separators.
- Two groups with different api_keys at the same base_url (or otherwise
  colliding on cleaned name) are disambiguated with a numeric suffix
  (custom:openai, custom:openai-2) so both stay visible.
- current_base_url parameter plumbed through both gateway call sites.

Existing #8216, #11499, #13509 regressions covered (dict/list shapes
of models:, section-3/section-4 dedup, normalized list-format entries).

Salvaged from @davidvv's PR #9210 — the underlying code had diverged
~1400 commits since that PR was opened, so this is a reconstruction of
the same approach on current main rather than a clean cherry-pick.
Authorship preserved via --author on this commit.

Closes #9210
@teknium1 teknium1 merged commit 627abbb into main Apr 23, 2026
11 of 12 checks passed
@teknium1 teknium1 deleted the hermes/hermes-6cf13b49 branch April 23, 2026 10:10
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants