Skip to content

The agent that grows with you

fix(models): TokenHub's saved endpoint is not a relay, so /model keeps the curated Hy list

kshitijk4poordd7ee8600495
diff --git a/hermes_cli/models.py b/hermes_cli/models.py
index 9439070d23e..8cb3f7f9087 100644
--- a/hermes_cli/models.py
+++ b/hermes_cli/models.py
@@ -1753,19 +1753,18 @@ def _configured_relay_base_url(provider: str) -> str:
base_url = str(model_cfg.get("base_url") or "").strip().rstrip("/")
if not base_url:
return ""
- # A base_url equal to the provider's own endpoint is not a relay (setup persists canonical
- # URLs too): keep native discovery, which OAuth providers such as Codex need because the
- # generic relay probe only speaks api_key. Profiles cover providers PROVIDER_REGISTRY lacks
- # (OpenRouter).
+ # A base_url equal to the provider's own endpoint (profile's, or the registry row's when the
+ # profile leaves it empty: TokenHub; profiles cover OpenRouter, absent from the registry) is
+ # not a relay: setup persists canonical URLs, and OAuth providers (Codex) need native discovery.
try:
+ from hermes_cli.auth import PROVIDER_REGISTRY
from providers import get_provider_profile
- canonical = getattr(get_provider_profile(normalized), "base_url", "") or ""
+ canonical = {normalize_route_base_url(u) for u in (getattr(get_provider_profile(normalized), "base_url", ""),
+ getattr(PROVIDER_REGISTRY.get(normalized), "inference_base_url", "")) if u}
except Exception:
return base_url # lookup failed: stay a relay, never widening where credentials go
- if canonical and normalize_route_base_url(base_url) == normalize_route_base_url(canonical):
- return ""
- return base_url
+ return "" if normalize_route_base_url(base_url) in canonical else base_url
def _relay_model_catalog(normalized: str, relay: str) -> Optional[list[str]]:
diff --git a/tests/hermes_cli/test_models_relay_base_url.py b/tests/hermes_cli/test_models_relay_base_url.py
index e83e4944f13..2bbeebfb7f9 100644
--- a/tests/hermes_cli/test_models_relay_base_url.py
+++ b/tests/hermes_cli/test_models_relay_base_url.py
@@ -47,6 +47,23 @@ def test_canonical_url_preserves_native_catalog_but_other_paths_stay_relays(monk
assert ("native-catalog-model" in catalog) == bool(expected)
+def test_registry_endpoint_is_canonical_when_the_profile_leaves_base_url_empty(monkeypatch):
+ """TokenHub's profile leaves ``base_url`` to its auth-registry row. A ``model.base_url`` that
+ ``hermes model`` saved as that endpoint is not a relay: the picker keeps the curated Hy list
+ instead of replacing it with a live probe of the same host."""
+ from hermes_cli.auth import PROVIDER_REGISTRY
+ from providers import get_provider_profile
+
+ assert get_provider_profile("tencent-tokenhub").base_url == ""
+ endpoint = PROVIDER_REGISTRY["tencent-tokenhub"].inference_base_url
+ monkeypatch.setattr(models, "_get_model_config_dict",
+ lambda: {"provider": "tencent-tokenhub", "base_url": endpoint + "/"})
+ assert models._configured_relay_base_url("tencent-tokenhub") == ""
+ monkeypatch.setattr(models, "_get_model_config_dict",
+ lambda: {"provider": "tencent-tokenhub", "base_url": endpoint + "/relay"})
+ assert models._configured_relay_base_url("tencent-tokenhub") == endpoint + "/relay"
+
+
def test_relay_base_url_is_probed_for_configured_provider(monkeypatch):
monkeypatch.setattr(
models,