diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py index 9e90cef9ead..a27292747be 100644 --- a/hermes_cli/model_switch.py +++ b/hermes_cli/model_switch.py @@ -1735,10 +1735,15 @@ def list_authenticated_providers( if fb: models_list = list(fb) - # Prefer the endpoint's live /models list when credentials are - # available, unless the provider explicitly opts out via - # discover_models: false (e.g. dedicated endpoints that expose - # the entire aggregator catalog via /models). + # Prefer the endpoint's live /models list when discoverable, + # unless the provider explicitly opts out via discover_models: false. + # Policy mirrors Section 4's should_probe logic: + # - With an api_key: always probe (user opted into the endpoint). + # - Without an api_key but with explicit models: skip — the user + # is narrowing a public endpoint to a specific subset. + # - Without an api_key AND no explicit models: probe anyway so + # bare-endpoint providers (local llama.cpp / Ollama servers) + # still show their full model catalog. api_key = str(ep_cfg.get("api_key", "") or "").strip() if not api_key: key_env = str(ep_cfg.get("key_env", "") or "").strip() @@ -1746,7 +1751,11 @@ def list_authenticated_providers( discover = ep_cfg.get("discover_models", True) if isinstance(discover, str): discover = discover.lower() not in {"false", "no", "0"} - if api_url and api_key and discover: + has_explicit_models = bool(models_list) + should_probe = bool(api_url) and discover and ( + bool(api_key) or not has_explicit_models + ) + if should_probe: try: from hermes_cli.models import fetch_api_models live_models = fetch_api_models(api_key, api_url)