Skip to content

fix: prevent duplicate provider entries in /model picker (Section 3 dedup) - #7526

Closed
ShuaiHui wants to merge 1 commit into
NousResearch:mainfrom
ShuaiHui:fix/provider-picker-duplicate-entries
Closed

fix: prevent duplicate provider entries in /model picker (Section 3 dedup)#7526
ShuaiHui wants to merge 1 commit into
NousResearch:mainfrom
ShuaiHui:fix/provider-picker-duplicate-entries

Conversation

@ShuaiHui

Copy link
Copy Markdown

Summary

Fixes duplicate provider entries in the /model picker when a provider exists in both the built-in catalog and the user's config.yaml providers: section.

Problem

list_authenticated_providers() builds the provider list in 4 sections. Section 3 (user-defined providers from config.yaml providers:) is the only section that doesn't check seen_slugs before adding entries. This causes every provider defined in both the built-in catalog and user config to appear twice:

Built-in entry (Section 2) Duplicate (Section 3)
"Nous Portal (27)" "nous (0)"
"GitHub Copilot (14)" "copilot (0)"
"DeepSeek (2)" "deepseek (0)"
"MiniMax (7)" "minimax (0)"

The Section 3 entries always show 0 models because they use default_model (which is typically empty for built-in provider overrides) instead of the curated model list.

Root Cause

In hermes_cli/model_switch.py, list_authenticated_providers():

  • Section 1 (PROVIDER_TO_MODELS_DEV): ✅ checks seen_slugs, adds to seen_slugs
  • Section 2 (HERMES_OVERLAYS): ✅ checks seen_slugs, adds to seen_slugs
  • Section 3 (user_providers): ❌ no dedup at all
  • Section 4 (custom_providers): ✅ checks seen_slugs, adds to seen_slugs

Fix

Add seen_slugs check and tracking in Section 3, matching the pattern used by all other sections:

# Skip if this provider was already added by Sections 1/2
if ep_name in seen_slugs:
    continue
# ... existing logic ...
seen_slugs.add(ep_name)

Verification

from hermes_cli.model_switch import list_authenticated_providers

providers = list_authenticated_providers(
    current_provider="nous",
    user_providers={"nous": {}, "minimax-cn": {}, "copilot": {}, "deepseek": {}, "minimax": {}},
    max_models=50,
)

slugs = [p["slug"] for p in providers]
# Before fix: nous appears twice, copilot appears twice, etc.
# After fix: each provider appears exactly once
assert len(slugs) == len(set(slugs))

Related

…edup)

Section 3 of list_authenticated_providers() iterates over the user's
config.yaml `providers:` dict and adds each entry without checking
seen_slugs. This causes duplicate entries in the /model picker when a
provider exists in both the built-in catalog and the user config.

For example, with `nous` in providers: the picker shows both:
  - "Nous Portal (27)"  — from Section 2 (HERMES_OVERLAYS)
  - "nous (0)"          — from Section 3 (user_providers, duplicate)

Affected providers: nous, copilot, deepseek, minimax, minimax-cn, etc.

Fix: add seen_slugs check at the start of the Section 3 loop and
seen_slugs.add() after appending results, consistent with Sections 1/2/4.

Fixes #7524
Related: #5223, #7373, #7054
@ShuaiHui ShuaiHui closed this by deleting the head repository Apr 15, 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: /model provider picker shows duplicate entries when provider exists in both built-in catalog and config.yaml

1 participant