Skip to content

[Bug]: /model picker shows triple entries for the same provider (Built-in, User-defined, and Compatibility view) #9545

@zackzmai

Description

@zackzmai

Bug Description

The /model provider picker lists the same provider three times when it is defined in the providers: section of config.yaml. For example, a provider named NVIDIA appears as NVIDIA (2), NVIDIA (1), and Nvidia (0). This creates a misleading and cluttered UI.

Steps to Reproduce

  1. In config.yaml, define a provider under the providers: section:

    providers:
    NVIDIA:
    name: "NVIDIA"
    api: "https://integrate.api.nvidia.com/v1"
    models:
    - "model-1"
    - "model-2"

  2. Ensure the custom_providers list is empty: custom_providers: [].

  3. Start the Hermes Agent Gateway.

  4. Execute the /model command in the messaging platform (e.g., Telegram).

  5. Observe that NVIDIA is listed three times with different model counts.

Expected Behavior

The /model picker should only show one single entry per provider. Regardless of whether the provider is a built-in one from models.dev, a user-defined one in providers:, or a legacy custom_providers entry, the system should deduplicate them using a consistent, case-insensitive identifier (slug). The entry shown should prioritize the most complete definition (i.e., the one with the full models list).

Actual Behavior

The provider is listed three times due to inconsistent slugging and missing deduplication across different loading sections:

  1. Nvidia (0): Loaded from PROVIDER_TO_MODELS_DEV (Built-in) with slug "nvidia".
  2. NVIDIA (2): Loaded from providers: config (User-defined) with slug "NVIDIA".
  3. NVIDIA (1): Loaded from the compatibility view via get_compatible_custom_providers with slug "custom:nvidia".

Affected Component

Gateway (Telegram/Discord/Slack/WhatsApp)

Messaging Platform (if gateway-related)

Telegram

Debug Report

Report       https://paste.rs/fxoLg
  agent.log    https://paste.rs/2RZ9l
  gateway.log  https://paste.rs/gBloB

Operating System

Ubuntu 24.04

Python Version

3.11.15

Hermes Version

0.9.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

The bug is in hermes_cli/model_switch.py within the list_authenticated_providers function. The duplication occurs because of three overlapping loading paths with inconsistent slugging:

  1. Path 1 (Built-in): Uses lowercase slugs from PROVIDER_TO_MODELS_DEV (e.g., "nvidia").
  2. Path 2 (User-defined): Uses the raw key from providers: config (e.g., "NVIDIA"). Crucially, this section fails to check or update the seen_slugs set, allowing subsequent paths to add the same provider again.
  3. Path 3 (Compatibility View): get_compatible_custom_providers in hermes_cli/config.py converts providers: entries into a legacy list. The slug is then generated via custom_provider_slug(), which adds a "custom:" prefix (e.g., "custom:nvidia").

Because "nvidia" $\neq$ "NVIDIA" $\neq$ "custom:nvidia", the deduplication logic fails completely, and all three entries are appended to the results.

Proposed Fix (optional)

  1. Normalize Slugs: Ensure all provider slugs are converted to lowercase before being checked or added to the seen_slugs set.
  2. Fix Section 3: In hermes_cli/model_switch.py, add the missing seen_slugs check and update inside the user_providers loop:
if ep_name.lower() in seen_slugs:
    continue
... (append to results) ...
seen_slugs.add(ep_name.lower())
  1. Unify Compatibility Slugs: Ensure that the compatibility layer does not introduce redundant prefixes (like custom:) when the provider is already defined in the primary providers: section.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions