Skip to content

The agent that grows with you

fix(aux): seed the shared Nous catalog entry with the pickers' arguments

Mariano Nicolinid7520b2822e0
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index a85fb257312..7e2c3824940 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -865,6 +865,7 @@ def _fast_model_from_catalog(provider_id: str) -> str:
network path — the underlying fetch is memory+disk cached with a
last-known-good fallback.
"""
+ is_nous = provider_id.strip().lower() == "nous"
try:
from hermes_cli.auth import resolve_api_key_provider_credentials
from hermes_cli.models import fetch_models_with_pricing
@@ -884,7 +885,7 @@ def _fast_model_from_catalog(provider_id: str) -> str:
# fetch below still works for the catalogs that allow it.
logger.debug("No credentials for %s catalog", provider_id, exc_info=True)
- if not api_key and provider_id.strip().lower() == "nous":
+ if not api_key and is_nous:
# Nous is OAuth, so the resolver above raises for it. An anonymous
# read returns the full catalog, and a model picked from it is
# refused at request time by the org's policy.
@@ -903,15 +904,26 @@ def _fast_model_from_catalog(provider_id: str) -> str:
# fetch_models_with_pricing appends its own /v1/models.
if base_url.endswith("/v1"):
base_url = base_url[:-3]
+ # Same entry the pickers use, so the Nous-only arguments must match
+ # theirs: seeding it here without them costs the picker its sale chrome
+ # and leaves the policy catalog with no expiry.
+ _nous_kwargs = {}
+ if is_nous:
+ from hermes_cli.models import _NOUS_CATALOG_TTL_SECONDS
+
+ _nous_kwargs = {
+ "include_sale_original": True,
+ "cache_ttl_seconds": _NOUS_CATALOG_TTL_SECONDS,
+ }
catalog = fetch_models_with_pricing(
- api_key=api_key or None, base_url=base_url, timeout=3.0
+ api_key=api_key or None, base_url=base_url, timeout=3.0, **_nous_kwargs
) or {}
except Exception:
logger.debug("Fast-model catalog lookup failed for %s", provider_id, exc_info=True)
return ""
ids = sorted((str(m) for m in catalog), key=_model_recency_key, reverse=True)
- if provider_id.strip().lower() == "nous":
+ if is_nous:
# The catalog's keys are a source of ids here, so the policy narrows
# them as it does the pickers' lists.
try:
diff --git a/tests/hermes_cli/test_nous_policy_surfaces.py b/tests/hermes_cli/test_nous_policy_surfaces.py
index 8e30f0efc88..04146a617f1 100644
--- a/tests/hermes_cli/test_nous_policy_surfaces.py
+++ b/tests/hermes_cli/test_nous_policy_surfaces.py
@@ -284,3 +284,26 @@ class TestAuxFallbackRespectsPolicy:
aux._get_aux_model_for_provider("nous", prefer_fast=True)
== "vendor/anything"
)
+
+
+def test_titling_seeds_the_shared_catalog_entry_like_the_pickers(monkeypatch):
+ """The aux catalog read shares the pickers' cache entry, so seeding it
+ without the Nous-only arguments costs the picker its sale chrome and leaves
+ the policy catalog with no expiry."""
+ import agent.auxiliary_client as aux
+
+ monkeypatch.setattr(
+ models_mod, "_resolve_nous_pricing_credentials",
+ lambda: ("tok", "https://inference.example.com"),
+ )
+ seen: dict = {}
+
+ def _fake_fetch(**kwargs):
+ seen.update(kwargs)
+ return {"vendor/haiku": {}}
+
+ monkeypatch.setattr(models_mod, "fetch_models_with_pricing", _fake_fetch)
+ aux._fast_model_from_catalog("nous")
+
+ assert seen.get("include_sale_original") is True
+ assert seen.get("cache_ttl_seconds") == models_mod._NOUS_CATALOG_TTL_SECONDS