The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(models): close final provider discovery edge cases
Vadelmaf70e9abce9bd
diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.pyindex c6f4a1e31c2..e2a7baeaf90 100644--- a/hermes_cli/model_switch.py+++ b/hermes_cli/model_switch.py@@ -1926,7 +1926,11 @@ def switch_model(if configured_key.startswith("${") and configured_key.endswith("}"):configured_key = os.environ.get(configured_key[2:-1], "").strip()if not configured_key:- key_env = str(_ollama_cfg.get("key_env") or "").strip()+ key_env = str(+ _ollama_cfg.get("key_env")+ or _ollama_cfg.get("api_key_env")+ or ""+ ).strip()if key_env:configured_key = os.environ.get(key_env, "").strip()if configured_key:@@ -3338,7 +3342,7 @@ def list_authenticated_providers(has_explicit_models,headers=_extra_headers_from_config(ep_cfg) or None,timeout=(1.5 if for_picker else 5.0),- api_mode=ep_cfg.get("api_mode"),+ api_mode=grp.get("api_mode"),)if isinstance(live_models, _NativePickerModelList):native_catalog_empty = not live_models@@ -3360,7 +3364,7 @@ def list_authenticated_providers(cache_only=True,timeout=(1.5 if for_picker else 5.0),headers=_extra_headers_from_config(ep_cfg) or None,- api_mode=ep_cfg.get("api_mode"),+ api_mode=grp.get("api_mode"),)if cached_models:models_list = cached_models@@ -3721,7 +3725,7 @@ def list_authenticated_providers(live_models = _fetch_picker_live_models(api_key,api_url,- slug,+ native_catalog_provider,bool(grp.get("has_explicit_models")),headers=grp.get("extra_headers") or None,timeout=(1.5 if for_picker else 5.0),diff --git a/hermes_cli/models.py b/hermes_cli/models.pyindex 04311e07616..44896263e13 100644--- a/hermes_cli/models.py+++ b/hermes_cli/models.py@@ -2439,6 +2439,28 @@ _KNOWN_PROVIDER_NAMES: set[str] = ()+def _configured_custom_provider_ids() -> set[str]:+ """Return routable custom-provider IDs configured by the user."""+ ids = {"custom"}+ try:+ from hermes_cli.config import load_config+ from hermes_cli.providers import custom_provider_slug++ config = load_config()+ providers = config.get("providers", {})+ if isinstance(providers, dict):+ for key, entry in providers.items():+ if isinstance(entry, dict):+ ids.add(custom_provider_slug(str(entry.get("name") or key), str(key)))+ legacy = config.get("custom_providers", [])+ if isinstance(legacy, list):+ for entry in legacy:+ if isinstance(entry, dict):+ ids.add(custom_provider_slug(str(entry.get("name") or "")))+ except (ImportError, OSError, RuntimeError, TypeError, ValueError, AttributeError):+ pass+ return ids+def list_available_providers() -> list[dict[str, str]]:"""Return info about all providers the user could use with ``provider:model``.@@ -2506,6 +2528,16 @@ def parse_model_input(raw: str, current_provider: str) -> tuple[str, str]:provider_part = stripped[:colon].strip().lower()model_part = stripped[colon + 1:].strip()if provider_part and model_part and provider_part in _KNOWN_PROVIDER_NAMES:+ if provider_part == "custom":+ lowered = stripped.lower()+ for custom_id in sorted(+ _configured_custom_provider_ids() - {"custom"},+ key=len,+ reverse=True,+ ):+ prefix = f"{custom_id.lower()}:"+ if lowered.startswith(prefix):+ return custom_id, stripped[len(custom_id) + 1 :].strip()# Support custom:name:model triple syntax for named custom# providers. ``custom:local:qwen`` → ("custom:local", "qwen").# Single colon ``custom:qwen`` → ("custom", "qwen") as before.@@ -2804,6 +2836,14 @@ def probe_ollama_local_models(continueseen.add(model_id)models.append(model_id)+ if raw_models and not models:+ _remember_ollama_cache(+ _OLLAMA_LOCAL_PROBE_REACHABLE, cache_key, False+ )+ _remember_ollama_cache(+ _OLLAMA_LOCAL_PROBE_FAILURE_CACHE, failure_key, time.monotonic()+ )+ return None_remember_ollama_cache(_OLLAMA_LOCAL_PROBE_REACHABLE, cache_key, True)_OLLAMA_LOCAL_PROBE_FAILURE_CACHE.pop(failure_key, None)_remember_ollama_cache(diff --git a/tests/acp/test_named_provider_catalogs.py b/tests/acp/test_named_provider_catalogs.pyindex d7a0ca903b9..f79b8baf769 100644--- a/tests/acp/test_named_provider_catalogs.py+++ b/tests/acp/test_named_provider_catalogs.py@@ -249,3 +249,22 @@ class TestModelStateIncludesNamedProviders:provider, model = parse_model_input(choice_id, "bedrock")assert provider == "custom:bedrock-mantle"assert model == "openai.gpt-5.5"++ def test_selector_choice_id_round_trips_colon_bearing_custom_identity(self):+ """Configured provider and model IDs may both contain colons."""+ from hermes_cli.models import parse_model_input++ cfg = {+ "providers": {+ "local-127.0.0.1:11434": {+ "name": "Local Ollama",+ "base_url": "http://127.0.0.1:11434/v1",+ }+ }+ }+ with patch("hermes_cli.config.load_config", return_value=cfg):+ provider, model = parse_model_input(+ "custom:local-127.0.0.1:11434:qwen3:1.7b", "custom"+ )+ assert provider == "custom:local-127.0.0.1:11434"+ assert model == "qwen3:1.7b"