Skip to content

fix(custom-providers): preserve multi-model entries and group by provider name#9275

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-0af660b3
Apr 13, 2026
Merged

fix(custom-providers): preserve multi-model entries and group by provider name#9275
teknium1 merged 3 commits into
mainfrom
hermes/hermes-0af660b3

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvages PRs #9233 and #8011 by @akhater (Tony365's feature request).

When a user configures multiple custom_providers entries sharing the same provider name (e.g. 4 Ollama Cloud entries for different models), two bugs prevented them from appearing correctly in the /model picker:

Bug 1 (data layer): get_compatible_custom_providers() deduplicates by (name, base_url), collapsing entries with different models into one. Fix: include model in the dedup key.

Bug 2 (display layer): list_authenticated_providers() creates one row per entry, and the seen_slugs guard drops all entries after the first for each slug. Fix: two-pass grouping via OrderedDict — first collect all models per provider slug, then emit one grouped row per provider.

Before

1. Ollama Cloud      qwen3-coder:480b-cloud
(other 3 entries silently dropped)

After

1. Ollama Cloud      qwen3-coder:480b-cloud, glm-5.1:cloud, kimi-k2.5, minimax-m2.7:cloud
2. Moonshot          kimi-k2-thinking

Changes

  • hermes_cli/config.py — Add model to dedup tuple in _append_if_new() (+2/-1)
  • hermes_cli/model_switch.py — Two-pass grouping in section 4 of list_authenticated_providers() (+25/-10)
  • Tests: 3 new regression tests covering grouping, dedup, and multi-model preservation

Test plan

  • Unit tests pass (10/10 in custom_providers + config tests)
  • E2E test with real config file, real imports, isolated HERMES_HOME

Closes #8011, closes #9233.

akhater and others added 3 commits April 13, 2026 16:31
get_compatible_custom_providers() deduplicates by (name, base_url) which
collapses multiple models under the same provider into a single entry.
For example, 7 Ollama Cloud entries with different models become 1.
Adding model to the tuple preserves all entries.
…per provider

The /model picker currently renders one row per ``custom_providers``
entry. When several entries share the same provider name (e.g. four
``ollama-cloud`` entries for ``qwen3-coder``, ``glm-5.1``, ``kimi-k2``,
``minimax-m2.7``), users see four separate "Ollama Cloud" rows in the
picker, which is confusing UX — there is only one Ollama Cloud
provider, so there should be one row containing four models.

This PR groups ``custom_providers`` entries that share the same provider
name into a single picker row while keeping entries with distinct names
as separate rows. So:

* Four entries named ``Ollama Cloud`` → one "Ollama Cloud" row with
  four models inside.
* One entry named ``Ollama Cloud`` and one named ``Moonshot`` → two
  separate rows, one model each.

Implementation
--------------
Replaces the single-pass loop in ``list_authenticated_providers()`` with
a two-pass approach:

1. First pass: build an ``OrderedDict`` keyed by ``custom_provider_slug(name)``,
   accumulating ``models`` per group while preserving discovery order.
2. Second pass: iterate the groups and append one result row per group,
   skipping any slug that already appeared in an earlier provider source
   (the existing ``seen_slugs`` guard).

Insertion order is preserved via ``OrderedDict``, so providers and
their models still appear in the order the user listed them in
``custom_providers``. No new dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Supply Chain Risk Detected

This PR contains patterns commonly associated with supply chain attacks. This does not mean the PR is malicious — but these patterns require careful human review before merging.

⚠️ WARNING: Install hook files modified

These files can execute code during package installation or interpreter startup.

Files:

hermes_cli/setup.py

Automated scan triggered by supply-chain-audit. If this is a false positive, a maintainer can approve after manual review.

@teknium1 teknium1 merged commit ac80bd6 into main Apr 13, 2026
5 of 6 checks passed
@teknium1 teknium1 deleted the hermes/hermes-0af660b3 branch April 13, 2026 23:41
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.

2 participants