Skip to content

The agent that grows with you

fix(auth): honour openrouter mirror base_url in boot inventory

Everson Menezes Santosa74a25864257
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..b378e581261
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1,2 @@
+Everson-s8
+# PR #114351
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.py
index 4e2a3442bdb..755523ccec9 100644
--- a/hermes_cli/auth.py
+++ b/hermes_cli/auth.py
@@ -31,7 +31,6 @@ from urllib.parse import urlparse
from hermes_constants import OPENROUTER_BASE_URL, hermes_home_key, secure_parent_dir
from agent.credential_persistence import sanitize_borrowed_credential_payload
from 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-exported
KIMI_CODE_BASE_URL, ZAI_ENDPOINTS, _normalize_lmstudio_runtime_base_url, _resolve_kimi_base_url,
_resolve_zai_base_url, detect_zai_endpoint)
@@ -1322,12 +1321,12 @@ def _config_model_provider() -> Tuple[Any, Optional[str]]:
# 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.
+ # A non-openrouter ``base_url`` under the openrouter pin is NOT contradictory: the runtime
+ # treats it as a deliberate mirror/proxy (runtime_provider_backends.py #10622, pinned by
+ # test_explicit_openrouter_honors_config_base_url_mirror), so carry that intent forward
+ # regardless of the mirror host.
if provider == "openrouter":
- if not base_url or base_url_host_matches(base_url, "openrouter.ai"):
- return model_cfg, "openrouter"
- return model_cfg, None
+ return model_cfg, "openrouter"
if provider in PROVIDER_REGISTRY:
return model_cfg, provider
# No provider pin but a base_url the bare-custom runtime rung would honour (a loopback
diff --git a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py b/tests/hermes_cli/test_resolve_provider_custom_endpoint.py
index 792ab1d27e4..afbb3896d82 100644
--- a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py
+++ b/tests/hermes_cli/test_resolve_provider_custom_endpoint.py
@@ -48,6 +48,11 @@ def isolated_home(tmp_path, monkeypatch):
"model:\n default: openrouter/auto\n provider: openrouter\n",
id="provider-openrouter",
),
+ pytest.param(
+ "model:\n default: openrouter/auto\n provider: openrouter\n"
+ " base_url: https://openrouter-mirror.example.com/api/v1\n",
+ id="provider-openrouter-mirror",
+ ),
],
)
def test_configured_custom_endpoint_resolves_as_a_provider(isolated_home, model_block):
@@ -84,10 +89,11 @@ def test_configured_openrouter_pin_resolves_as_a_provider(isolated_home):
def test_stale_remote_base_url_without_a_custom_pin_is_not_a_provider(isolated_home):
"""The URL rung follows the runtime's own trust rule: a non-loopback ``base_url`` left behind
- under another provider's pin is not custom intent (#14676), so a blank machine still reads
- as unconfigured."""
+ under a bare (unpinned) provider is not custom intent (#14676), so a blank machine still reads
+ as unconfigured. (A ``provider: openrouter`` pin is excluded from this guard — a non-openrouter
+ ``base_url`` under it is a deliberate mirror/proxy, #10622/#109397.)"""
(isolated_home / "config.yaml").write_text(
- "model:\n default: some/model\n provider: openrouter\n base_url: https://api.z.ai/v1\n",
+ "model:\n default: some/model\n base_url: https://api.z.ai/v1\n",
encoding="utf-8",
)
from hermes_cli.auth import AuthError, resolve_provider