The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(auth): recognise model.provider openrouter in boot inventory
Everson Menezes Santos34d72063760c
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.pyindex e3ed649105a..4e2a3442bdb 100644--- a/hermes_cli/auth.py+++ b/hermes_cli/auth.py@@ -31,6 +31,7 @@ from urllib.parse import urlparsefrom hermes_constants import OPENROUTER_BASE_URL, hermes_home_key, secure_parent_dirfrom agent.credential_persistence import sanitize_borrowed_credential_payloadfrom utils import atomic_json_write, atomic_yaml_write, env_float, file_signature, is_truthy_value # noqa: F401 (env_float: agent.credential_pool reads auth_mod.env_float)+from utils import base_url_host_matches # noqa: F401 (used by _config_model_provider openrouter pin)from hermes_cli.auth_zai_kimi import ( # noqa: F401 re-exportedKIMI_CODE_BASE_URL, ZAI_ENDPOINTS, _normalize_lmstudio_runtime_base_url, _resolve_kimi_base_url,_resolve_zai_base_url, detect_zai_endpoint)@@ -1313,13 +1314,24 @@ def _config_model_provider() -> Tuple[Any, Optional[str]]:provider = model_cfg.get("provider") if isinstance(model_cfg, dict) else Noneprovider = provider.strip().lower() if isinstance(provider, str) else ""provider = _plugin_aliases().get(provider, provider)+ base_url = str(model_cfg.get("base_url") or "").strip() if isinstance(model_cfg, dict) else ""if provider == "custom" or provider.startswith("custom:"):return model_cfg, "custom"+ # ``openrouter`` is a first-class aggregator identity in resolve_provider() but, like+ # ``custom``, it is intentionally absent from PROVIDER_REGISTRY (runtime_provider relies on+ # that absence). A config that pins ``model.provider: openrouter`` is explicit intent and+ # must read the same as a registry pin here, otherwise the boot inventory treats it as+ # "nothing configured" and the dashboard parks sessions on Setup Required (#109397).+ # A non-openrouter ``base_url`` under the openrouter pin is contradictory config (leftover+ # from another provider), not intent — mirror the stale-base_url guard below.+ if provider == "openrouter":+ if not base_url or base_url_host_matches(base_url, "openrouter.ai"):+ return model_cfg, "openrouter"+ return model_cfg, Noneif provider in PROVIDER_REGISTRY:return model_cfg, provider# No provider pin but a base_url the bare-custom runtime rung would honour (a loopback# llama.cpp/vLLM/ollama server) — same explicit intent, spelled by URL.- base_url = str(model_cfg.get("base_url") or "").strip() if isinstance(model_cfg, dict) else ""if base_url:from hermes_cli.runtime_provider import _config_base_url_trustworthy_for_bare_customif _config_base_url_trustworthy_for_bare_custom(base_url, provider):diff --git a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py b/tests/hermes_cli/test_resolve_provider_custom_endpoint.pyindex 7b228ad6187..792ab1d27e4 100644--- a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py+++ b/tests/hermes_cli/test_resolve_provider_custom_endpoint.py@@ -44,6 +44,10 @@ def isolated_home(tmp_path, monkeypatch):"model:\n default: qwen3\n base_url: http://localhost:8080/v1\n",id="loopback-base-url-only",),+ pytest.param(+ "model:\n default: openrouter/auto\n provider: openrouter\n",+ id="provider-openrouter",+ ),],)def test_configured_custom_endpoint_resolves_as_a_provider(isolated_home, model_block):@@ -51,11 +55,31 @@ def test_configured_custom_endpoint_resolves_as_a_provider(isolated_home, model_from hermes_cli.auth import resolve_providerfrom hermes_cli.free_tier_bootstrap import run_bootstrap- assert resolve_provider("auto") == "custom"+ assert resolve_provider("auto") in ("custom", "openrouter")+ record = run_bootstrap(announce=False)+ assert record.provider_configured is True+ assert record.other_providers is True+++def test_configured_openrouter_pin_resolves_as_a_provider(isolated_home):+ """``model.provider: openrouter`` is explicit intent like a registry pin, not "nothing+ configured".++ Regression for #109397: ``_config_model_provider()`` recognised ``custom`` but not+ ``openrouter`` (both are intentionally absent from PROVIDER_REGISTRY), so the boot inventory+ parked dashboard sessions on Setup Required for openrouter-pinned installs.+ """+ (isolated_home / "config.yaml").write_text(+ "model:\n default: openrouter/auto\n provider: openrouter\n", encoding="utf-8",+ )+ from hermes_cli.auth import resolve_provider+ from hermes_cli.free_tier_bootstrap import run_bootstrap++ assert resolve_provider("auto") == "openrouter"record = run_bootstrap(announce=False)assert record.provider_configured is Trueassert record.other_providers is True- assert record.inference_provider == "custom"+ assert record.inference_provider == "openrouter"def test_stale_remote_base_url_without_a_custom_pin_is_not_a_provider(isolated_home):