The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: provider-catalog listing: accept both exact listing paths under the Anthropic override; relay-id rendering only on control rows
teknium1f2acfa8e7b9e
diff --git a/tests/e2e/core/providers/_catalog_helpers.py b/tests/e2e/core/providers/_catalog_helpers.pyindex d2361740eec..2800bfe9270 100644--- a/tests/e2e/core/providers/_catalog_helpers.py+++ b/tests/e2e/core/providers/_catalog_helpers.py@@ -134,14 +134,15 @@ class Row:out = {p + ENDPOINT_OF_DIALECT[self.dialect]: self.dialect}if self.dialect == "responses" or self.host_mandated:out[p + ENDPOINT_OF_DIALECT["chat"]] = "chat"- # Listing: an unversioned canonical base (api.anthropic.com, …/anthropic) lists at- # ``/v1/models`` under the Anthropic override; a versioned one (…/v1) at ``/models``.- versioned = re.search(r"/v\d+[a-z0-9]*/?$", urlsplit(self.base_url).path or "")- out[p + ("/v1/models" if self.dialect == "anthropic" and not versioned else "/models")] = "listing"+ # Listing: ``/models`` under the configured base; under the Anthropic override also the+ # Anthropic API's own ``/v1/models`` (the SDK's versioned path).+ out[p + "/models"] = "listing"+ if self.dialect == "anthropic":+ out[p + "/v1/models"] = "listing"return out- def listing_route(self) -> str:- return next(p for p, d in self.routes().items() if d == "listing")+ def listing_routes(self) -> set[str]:+ return {p for p, d in self.routes().items() if d == "listing"}def vendor_host(self) -> str:return f"{urlsplit(self.base_url).hostname}:443" if self.base_url.startswith("https://") else ""diff --git a/tests/e2e/core/providers/test_catalog_listing.py b/tests/e2e/core/providers/test_catalog_listing.pyindex ab33949ce99..f6322d2b5bb 100644--- a/tests/e2e/core/providers/test_catalog_listing.py+++ b/tests/e2e/core/providers/test_catalog_listing.py@@ -5,8 +5,9 @@ provider-unique model ids at the EXACT listing path under that base; anything elprocesses per row call the real product functions:* listing — ``hermes_cli.models.provider_model_ids`` (the catalog the ``/model`` picker renders)- must query the CONFIGURED endpoint at its exact listing path and render the relay's models, never- the provider's canonical host (#120844 class): the relay's key must not be addressed to the vendor;+ must query the CONFIGURED endpoint at an exact listing path under it, never the provider's+ canonical host (#120844 class): the relay's key must not be addressed to the vendor; rows that+ already do so must also render the relay's own model ids;* switch — ``hermes_cli.model_switch.switch_model(explicit_provider=<row>)`` must resolve to thatprovider at its configured endpoint, not to an alias on another endpoint (#120295 class);* listing degradation — for the rows that already list from the configured endpoint, a 404 and a@@ -123,12 +124,19 @@ def _listing_facts(ls: dict) -> str:@pytest.mark.parametrize("row", [pytest.param(r, id=r.name) for r in ROWS])def test_listing_uses_configured_endpoint(row: Row, probes: dict) -> None:ls = probes[(row.name, "list")]- route = row.listing_route()+ routes = row.listing_routes()ok = (not row.supports_model_listing) or (- "error" not in ls and bool(ls["listing_paths"]) and all(bare_path(p) == route for p in ls["listing_paths"])- and not ls["canonical_host_hit"] and ls["unique"] in (ls.get("ids") or []))+ "error" not in ls and bool(ls["listing_paths"]) and all(bare_path(p) in routes for p in ls["listing_paths"])+ and not ls["canonical_host_hit"])with known_gate(LISTING_KNOWN.get(row.name)):- gate(ok, f"{_listing_facts(ls)}\n{row.name}: picker did not list the configured endpoint (want {route})")+ gate(ok, f"{_listing_facts(ls)}\n{row.name}: picker did not list the configured endpoint (want {sorted(routes)})")++[email protected]("row", [pytest.param(r, id=r.name) for r in CONTROL_ROWS])+def test_listing_renders_relay_models(row: Row, probes: dict) -> None:+ """The rows that list from the configured endpoint render the relay's own model ids."""+ ls = probes[(row.name, "list")]+ assert ls["unique"] in (ls.get("ids") or []), f"{row.name}: relay models not rendered\n{_listing_facts(ls)}"@pytest.mark.parametrize("row", [pytest.param(r, id=r.name) for r in ROWS])@@ -149,10 +157,10 @@ def test_listing_failure_degrades_without_vendor_host(row: Row, kind: str, probe"""A 404 or a hanging listing at the configured endpoint: the picker still returns (within``HANG_BOUND_S``), asked the exact listing path, never crashed and never fell back to the vendor."""ls = probes[(row.name, kind)]- route = row.listing_route()+ routes = row.listing_routes()assert "error" not in ls, f"{row.name} [{kind}]: listing crashed\n{_listing_facts(ls)}"assert ls["wall_s"] < HANG_BOUND_S, f"{row.name} [{kind}]: listing blocked the picker\n{_listing_facts(ls)}"- assert ls["listing_paths"] and all(bare_path(p) == route for p in ls["listing_paths"]), (- f"{row.name} [{kind}]: never asked {route}\n{_listing_facts(ls)}")+ assert ls["listing_paths"] and all(bare_path(p) in routes for p in ls["listing_paths"]), (+ f"{row.name} [{kind}]: never asked {sorted(routes)}\n{_listing_facts(ls)}")assert not ls["canonical_host_hit"], f"{row.name} [{kind}]: fell back to the vendor host\n{_listing_facts(ls)}"assert ls["unique"] not in (ls.get("ids") or []), f"{row.name} [{kind}]: fake ids without a listing?"diff --git a/tests/e2e/core/providers/test_catalog_oauth.py b/tests/e2e/core/providers/test_catalog_oauth.pyindex d244ac7af02..5ad67f5cc9a 100644--- a/tests/e2e/core/providers/test_catalog_oauth.py+++ b/tests/e2e/core/providers/test_catalog_oauth.py@@ -78,10 +78,10 @@ class Home:return self.hermes_home / "auth.json"def seed_auth(self, store: dict[str, Any]) -> None:- self.auth_path.write_text(json.dumps(store, indent=2))+ self.auth_path.write_text(json.dumps(store, indent=2), encoding="utf-8")def auth(self) -> dict[str, Any]:- return json.loads(self.auth_path.read_text())+ return json.loads(self.auth_path.read_text(encoding="utf-8"))def env(self, extra: dict[str, str] | None = None) -> dict[str, str]:env = {k: v for k, v in os.environ.items()