Skip to content

fix(model-picker): dedupe user providers and enrich live OpenAI counts#13190

Closed
BigDon86 wants to merge 3 commits into
NousResearch:mainfrom
BigDon86:fix/model-picker-openai-live-counts
Closed

fix(model-picker): dedupe user providers and enrich live OpenAI counts#13190
BigDon86 wants to merge 3 commits into
NousResearch:mainfrom
BigDon86:fix/model-picker-openai-live-counts

Conversation

@BigDon86

Copy link
Copy Markdown

Problem

The CLI /model picker had two regressions that were reproducible in the user's live environment:

  1. OpenAI and OpenAI Direct showed 0 models in the picker even though provider_model_ids() returned the live catalog (122 models).
  2. Duplicate provider rows appeared in the picker for providers expanded from providers: config entries into compatibility custom_providers entries.

Examples seen live before the fix included duplicate Ollama (local) / Ollama style rows and duplicate OpenAI Direct rows with inconsistent counts.

Root cause

1. OpenAI/OpenAI Direct zero-count rows

list_authenticated_providers() built picker rows from curated/static/config-only counts, while the actual model-selection flow consulted live catalogs later at selection time. That meant providers with dynamic catalogs, especially openai and openai-direct, rendered with total_models=0 until the user selected them.

2. Duplicate provider rows in CLI picker

The CLI path calls get_compatible_custom_providers(), which expands providers: config entries into legacy custom_providers shape. This created two duplication paths:

  • Section 3 emitted user-defined providers using their config dict key as the slug.
  • Section 4 later re-emitted the same logical provider using a slug derived from the display name.

Because those slugs differed, the existing seen_slugs check did not catch the duplicate.

Fix

  • Add _resolve_openai_catalog_credentials() and use live /v1/models probing in provider_model_ids() for openai and openai-direct.
  • In list_authenticated_providers():
    • skip Section 3 entries whose slug is already claimed by a built-in/overlay/canonical provider
    • skip Section 4 entries whose provider_key was already emitted in Section 3
    • add a unified final enrichment pass that fills picker counts from live catalogs where available
    • preserve explicit models: configured by the user instead of overwriting them with live probes
  • Add regression tests for both the live enrichment and duplicate-row cases.

Verification

Automated

Targeted picker/model tests on the rebased branch:

  • tests/hermes_cli/test_picker_section3_dedupe_and_enrichment.py
  • tests/hermes_cli/test_model_validation.py
  • tests/hermes_cli/test_model_switch_custom_providers.py
  • tests/hermes_cli/test_user_providers_model_switch.py
  • tests/hermes_cli/test_overlay_slug_resolution.py
  • tests/hermes_cli/test_model_picker_viewport.py
  • tests/hermes_cli/test_codex_cli_model_picker.py

Result:

  • 112 passed

Live verification in user environment

Observed picker rows after the fix:

  • Ollama19
  • OpenAI122
  • OpenAI Direct122
  • OpenRouter31
  • GitHub Copilot14
  • Anthropic9

No duplicate rows remained in the live picker.

Notes

This PR keeps the CLI picker behavior aligned with the TUI/gateway path, which was already enriching model options from live catalogs.

Don added 3 commits April 20, 2026 16:20
…talog counts

Two related bugs in `hermes_cli.model_switch.list_authenticated_providers`
caused the /model picker to show duplicate provider rows and zero-count
OpenAI / OpenAI Direct rows.

1. Section 3 (user-defined providers from config.yaml `providers:`)
   appended rows without checking `seen_slugs`, producing duplicate
   entries when a config provider name overlapped with a built-in
   (e.g. "Nous Portal (27)" plus "nous (0)").  Now skips and registers
   the slug, matching Sections 1, 2, 2b, and 4.

2. Provider rows were built from curated/config-only counts while model
   selection used live catalogs, so OpenAI / OpenAI Direct displayed
   `total_models=0` until the user entered the row.  A new enrichment
   pass at the end of `list_authenticated_providers` calls
   `provider_model_ids()` (and a direct `/v1/models` probe via
   `fetch_api_models` for user-defined providers that supply only
   `base_url` + `key_env`) so the CLI picker matches what the TUI
   gateway already produced.  Explicit config `models:` lists are
   preserved — live data only fills empty rows.

Closes NousResearch#7524 for the Section 3 dedupe path.
…providers

The CLI picker calls get_compatible_custom_providers() which expands
config.providers entries into legacy custom_providers shape (tagged with
provider_key). Section 3 already emits a row for each user_provider, but
Section 4 was processing the expanded copies separately and generating
*different* slugs from the display name (e.g. user_provider key 'custom'
named 'Ollama (local)' → Section 3 emits slug=custom, Section 4 emits
slug=ollama-local), so the existing seen_slugs check missed them.

Section 4 now skips entries whose provider_key is already in seen_slugs.

The TUI gateway path was unaffected because it passes raw custom_providers
(usually empty) rather than the expanded compatibility view.
@alt-glitch alt-glitch added comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API type/bug Something isn't working labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #7524 — same duplicate provider rows bug in /model picker.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related: #7524 — same duplicate provider rows bug in /model picker.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as partially-redundant. The dedup half is already on main via _section3_emitted_pairs — the picker no longer emits duplicate rows when providers: entries get expanded into the compat-layer custom_providers list.

The live OpenAI count enrichment half (calling provider_model_ids() for OpenAI/OpenAI Direct) is not on main, but that's a narrower polish issue worth tracking separately if it's still affecting you — the current behavior shows the curated static count, not zero. If you still see OpenAI (0) rows on latest main, please open a focused issue and we'll revisit.

Thanks for the detailed root-cause analysis.

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 P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants