Skip to content

The agent that grows with you

test: trim the aggregator-twin tests to two invariants; drop the import guard

teknium12d1ccf447252
diff --git a/hermes_cli/inventory.py b/hermes_cli/inventory.py
index 76d1410e5a8..c0cc8126a4d 100644
--- a/hermes_cli/inventory.py
+++ b/hermes_cli/inventory.py
@@ -177,10 +177,8 @@ def _strip_aggregator_overlaps(rows: list[dict]) -> None:
)
if slug_suffix and slug_suffix in builtin_aggregators:
return True
- try:
- from agent.model_metadata import _infer_provider_from_url
- except Exception:
- return False
+ from agent.model_metadata import _infer_provider_from_url
+
inferred = _infer_provider_from_url(str(row.get("api_url") or ""))
return inferred is not None and inferred in builtin_aggregators
diff --git a/tests/hermes_cli/test_aggregator_overlap_twin_upstream.py b/tests/hermes_cli/test_aggregator_overlap_twin_upstream.py
index 0e923659ff1..4509985960f 100644
--- a/tests/hermes_cli/test_aggregator_overlap_twin_upstream.py
+++ b/tests/hermes_cli/test_aggregator_overlap_twin_upstream.py
@@ -1,4 +1,6 @@
-"""Aggregator overlap strip vs a user row that IS the same upstream as a built-in aggregator."""
+"""Aggregator overlap strip vs a user row that IS the same upstream as a built-in aggregator (#115623)."""
+
+import pytest
from hermes_cli import inventory
@@ -15,25 +17,27 @@ def _builtin_openrouter_row(models: list) -> dict:
}
-def _custom_openrouter_twin(models: list) -> dict:
+def _user_row(slug: str, api_url: str, models: list) -> dict:
return {
- "slug": "custom:openrouter",
- "name": "openrouter",
+ "slug": slug,
+ "name": slug.split(":", 1)[-1],
"is_current": False,
"is_user_defined": True,
- "api_url": "https://openrouter.ai/api/v1",
+ "api_url": api_url,
"models": list(models),
"total_models": len(models),
"source": "user-config",
}
-def test_built_in_row_keeps_models_when_twin_is_same_upstream():
[email protected]("twin_slug", ["custom:openrouter", "custom:my-or-relay"])
+def test_built_in_row_keeps_models_when_user_row_is_same_upstream(twin_slug):
# The twin's catalog is a superset of the built-in row's; counting it as "another provider
- # serves these ids" emptied the built-in row beside a live custom:openrouter row.
+ # serves these ids" emptied the built-in row beside a live twin row. The twin is detected by
+ # its custom:<aggregator> slug or, under any other name, by its upstream URL.
rows = [
_builtin_openrouter_row(["anthropic/claude-fable-5", "openai/gpt-6"]),
- _custom_openrouter_twin([
+ _user_row(twin_slug, "https://openrouter.ai/api/v1", [
"anthropic/claude-fable-5",
"openai/gpt-6",
"qwen/qwen-4-max",
@@ -44,68 +48,13 @@ def test_built_in_row_keeps_models_when_twin_is_same_upstream():
assert rows[0]["total_models"] == 2
-def test_same_upstream_twin_detected_by_url_when_slug_differs():
- # The twin registered under a different name still resolves to the built-in upstream by URL.
- rows = [
- _builtin_openrouter_row(["openai/gpt-6"]),
- {
- "slug": "custom:my-or-relay",
- "name": "my-or-relay",
- "is_current": False,
- "is_user_defined": True,
- "api_url": "https://openrouter.ai/api/v1",
- "models": ["openai/gpt-6"],
- "total_models": 1,
- "source": "user-config",
- },
- ]
- inventory._strip_aggregator_overlaps(rows)
- assert rows[0]["models"] == ["openai/gpt-6"]
-
-
def test_genuinely_different_upstream_still_strips_overlaps():
# A user proxy that is NOT the same upstream must still re-route picks away from aggregators
# (the dedup's original intent).
rows = [
_builtin_openrouter_row(["openai/gpt-6", "deepseek/deepseek-v4.1-flash"]),
- {
- "slug": "custom:proxy",
- "name": "proxy",
- "is_current": False,
- "is_user_defined": True,
- "api_url": "https://my-proxy.example.com/v1",
- "models": ["openai/gpt-6"],
- "total_models": 1,
- "source": "user-config",
- },
+ _user_row("custom:proxy", "https://my-proxy.example.com/v1", ["openai/gpt-6"]),
]
inventory._strip_aggregator_overlaps(rows)
assert rows[0]["models"] == ["deepseek/deepseek-v4.1-flash"]
assert rows[0]["total_models"] == 1
-
-
-def test_no_builtin_aggregator_rows_leaves_dedup_untouched():
- # Without a built-in aggregator in the payload there is no twin to exempt.
- rows = [
- {
- "slug": "custom:proxy-a",
- "name": "proxy-a",
- "is_current": False,
- "is_user_defined": True,
- "api_url": "https://a.example.com/v1",
- "models": ["m1", "m2"],
- "total_models": 2,
- },
- {
- "slug": "custom:proxy-b",
- "name": "proxy-b",
- "is_current": False,
- "is_user_defined": True,
- "api_url": "https://b.example.com/v1",
- "models": ["m1"],
- "total_models": 1,
- },
- ]
- inventory._strip_aggregator_overlaps(rows)
- assert rows[0]["models"] == ["m1", "m2"]
- assert rows[1]["models"] == ["m1"]