The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(model): validate Nebius relay models against base URL
Xuezhao Lane6eab8c6eb7c
diff --git a/hermes_cli/models_validate.py b/hermes_cli/models_validate.pyindex 662a860f576..6dbcf4a424c 100644--- a/hermes_cli/models_validate.py+++ b/hermes_cli/models_validate.py@@ -589,7 +589,7 @@ def _validate_managed_local(req: _Request) -> Optional[dict[str, Any]]:return None-def _profile_catalog(normalized: str) -> tuple[list[str], bool]:+def _profile_catalog(normalized: str, base_url: Optional[str] = None) -> tuple[list[str], bool]:"""``(catalog, authoritative)`` for a profile whose catalog is not the generic``{base_url}/models`` listing — it overrides ``fetch_models`` or points ``models_url``elsewhere — so that listing is not authoritative for it (a relay may 200 with a different@@ -604,6 +604,10 @@ def _profile_catalog(normalized: str) -> tuple[list[str], bool]:profile = get_provider_profile(normalized)if profile is None:return [], False+ # A non-default runtime base_url is a user-configured relay/proxy; its own /models listing+ # decides validation, not the provider profile's canonical catalog endpoint.+ if base_url and (base_url.rstrip("/") != (profile.base_url or "").rstrip("/")):+ return [], Falsegeneric = (profile.base_url or "").rstrip("/") + "/models"own_endpoint = bool(profile.models_url) and profile.models_url.rstrip("/") != genericif not own_endpoint and type(profile).fetch_models is ProviderProfile.fetch_models:@@ -618,7 +622,7 @@ def _validate_live_listing(req: _Request) -> Optional[dict[str, Any]]:against that catalog (``provider_model_ids`` — the picker's list) before the generic listing."""from hermes_cli import models as _m- catalog, authoritative = _profile_catalog(req.normalized)+ catalog, authoritative = _profile_catalog(req.normalized, req.base_url)if catalog:match = _match_in_catalog(req.lookup, catalog, suggest_query=req.requested)if match.exact:diff --git a/tests/hermes_cli/test_model_validation.py b/tests/hermes_cli/test_model_validation.pyindex 9e0a2c5cf2c..4b2bd170fdc 100644--- a/tests/hermes_cli/test_model_validation.py+++ b/tests/hermes_cli/test_model_validation.py@@ -823,6 +823,25 @@ class TestProfileCatalogAuthoritative:assert result["accepted"] is Trueassert result["recognized"] is True+ def test_nebius_relay_base_url_validates_against_relay_listing(self, monkeypatch):+ """A configured relay base URL must decide Nebius Token Factory validation (#121388)."""+ relay_base_url = "https://relay.example.invalid/v1"+ calls = []++ def fetch_relay_models(_api_key, base_url, **_kwargs):+ calls.append(base_url)+ return ["relay-only/model"] if base_url == relay_base_url else ["canonical-only/model"]++ monkeypatch.setattr("hermes_cli.models.provider_model_ids", lambda _provider: ["canonical-only/model"])+ monkeypatch.setattr("hermes_cli.models.fetch_api_models", fetch_relay_models)++ result = validate_requested_model(+ "relay-only/model", "nebius-token-factory", api_key="k", base_url=relay_base_url)++ assert result["accepted"] is True+ assert result["recognized"] is True+ assert calls == [relay_base_url]+# -- validate — whitespace in self-hosted / user-configured ids --------------