fix(model-picker): dedupe user providers and enrich live OpenAI counts#13190
fix(model-picker): dedupe user providers and enrich live OpenAI counts#13190BigDon86 wants to merge 3 commits into
Conversation
…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.
|
Related: #7524 — same duplicate provider rows bug in /model picker. |
1 similar comment
|
Related: #7524 — same duplicate provider rows bug in /model picker. |
|
Closing as partially-redundant. The dedup half is already on main via The live OpenAI count enrichment half (calling Thanks for the detailed root-cause analysis. |
Problem
The CLI
/modelpicker had two regressions that were reproducible in the user's live environment:OpenAIandOpenAI Directshowed0models in the picker even thoughprovider_model_ids()returned the live catalog (122models).providers:config entries into compatibilitycustom_providersentries.Examples seen live before the fix included duplicate
Ollama (local)/Ollamastyle rows and duplicateOpenAI Directrows 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, especiallyopenaiandopenai-direct, rendered withtotal_models=0until the user selected them.2. Duplicate provider rows in CLI picker
The CLI path calls
get_compatible_custom_providers(), which expandsproviders:config entries into legacycustom_providersshape. This created two duplication paths:Because those slugs differed, the existing
seen_slugscheck did not catch the duplicate.Fix
_resolve_openai_catalog_credentials()and use live/v1/modelsprobing inprovider_model_ids()foropenaiandopenai-direct.list_authenticated_providers():provider_keywas already emitted in Section 3models:configured by the user instead of overwriting them with live probesVerification
Automated
Targeted picker/model tests on the rebased branch:
tests/hermes_cli/test_picker_section3_dedupe_and_enrichment.pytests/hermes_cli/test_model_validation.pytests/hermes_cli/test_model_switch_custom_providers.pytests/hermes_cli/test_user_providers_model_switch.pytests/hermes_cli/test_overlay_slug_resolution.pytests/hermes_cli/test_model_picker_viewport.pytests/hermes_cli/test_codex_cli_model_picker.pyResult:
112 passedLive verification in user environment
Observed picker rows after the fix:
Ollama—19OpenAI—122OpenAI Direct—122OpenRouter—31GitHub Copilot—14Anthropic—9No 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.