Skip to content

The agent that grows with you

fix(nous): apply the on-sale union in the post-login picker too

Steve Dalonzo1daf6eb077ec
diff --git a/hermes_cli/auth_nous.py b/hermes_cli/auth_nous.py
index 23d3489587f..bca4a7e3d61 100644
--- a/hermes_cli/auth_nous.py
+++ b/hermes_cli/auth_nous.py
@@ -1480,6 +1480,7 @@ def _pick_nous_model_after_login(
get_curated_nous_model_ids,
check_nous_free_tier,
partition_nous_models_by_tier,
+ union_with_nous_on_sale_models,
union_with_portal_free_recommendations,
union_with_portal_paid_recommendations,
)
@@ -1509,6 +1510,9 @@ def _pick_nous_model_after_login(
union_with_portal_free_recommendations if free_tier
else union_with_portal_paid_recommendations)
model_ids, pricing = union(model_ids, pricing, _portal)
+ if not free_tier:
+ # Paid users also see every model on sale right now (same rule as `hermes model`).
+ model_ids = union_with_nous_on_sale_models(model_ids, pricing)
_before_policy = model_ids
model_ids = restrict_to_nous_policy(model_ids, _policy_allowed, rescue_empty=True)
_policy_narrowed = model_ids != _before_policy
diff --git a/hermes_cli/models.py b/hermes_cli/models.py
index 99a89fbd872..c0af28e942e 100644
--- a/hermes_cli/models.py
+++ b/hermes_cli/models.py
@@ -285,13 +285,14 @@ def union_with_nous_on_sale_models(curated_ids: list[str], pricing: dict[str, di
discount first. A sale lives only in ``/v1/models`` ``pricing.original``, so without this the
picker badges discounts on curated rows but never shows a discounted model the curated list and
Portal recommendations omit. Free rows stay with ``freeRecommendedModels``; rows the gateway
- marks tool-less (``"tools": False``) are skipped because Hermes is tool-calling-first."""
+ marks tool-less (``"tools": False``) are skipped because Hermes is tool-calling-first, and
+ image/video generation rows are skipped because they are not chat models."""
from hermes_cli.models_pricing import compute_sale_discount
seen = set(curated_ids)
on_sale: list[tuple[int, str]] = []
for mid, entry in (pricing or {}).items():
- if mid in seen or not isinstance(entry, dict) or entry.get("tools") is False:
+ if mid in seen or not isinstance(entry, dict) or entry.get("tools") is False or entry.get("generation"):
continue
sale = compute_sale_discount(entry.get("prompt", ""), entry.get("completion", ""), entry.get("original"))
if sale is not None and isinstance(entry.get("original"), dict) and sale[0] < 100:
diff --git a/hermes_cli/models_pricing.py b/hermes_cli/models_pricing.py
index 01ec36202f0..95f4f60b284 100644
--- a/hermes_cli/models_pricing.py
+++ b/hermes_cli/models_pricing.py
@@ -224,6 +224,7 @@ def fetch_models_with_pricing(
...}}``, cached per *base_url* and per credential so one caller's catalog never answers
another's read. *include_sale_original* (Nous Portal only) copies the gateway's pre-discount
``pricing.original`` rates through as a nested ``original`` dict for sale chrome."""
+ from hermes_cli.chat_catalog import catalog_item_is_generation
from hermes_cli.models import _HERMES_USER_AGENT, _openrouter_model_supports_tools
url_root = (base_url or "").rstrip("/")
cache_key = url_root + _pricing_auth_fingerprint(api_key)
@@ -262,6 +263,9 @@ def fetch_models_with_pricing(
# Nous Portal-only: on-sale rows join the picker, which must not offer a tool-less model.
if include_sale_original and not _openrouter_model_supports_tools(item):
entry["tools"] = False
+ # ...nor an image/video generation model (the chat-catalog rule, applied to the row itself).
+ if include_sale_original and catalog_item_is_generation(item):
+ entry["generation"] = True
result[mid] = entry
return _cache_catalog(cache_key, result, cache_ttl_seconds)
diff --git a/tests/hermes_cli/test_nous_picker_on_sale.py b/tests/hermes_cli/test_nous_picker_on_sale.py
index dd9b8a5cca1..53579732b65 100644
--- a/tests/hermes_cli/test_nous_picker_on_sale.py
+++ b/tests/hermes_cli/test_nous_picker_on_sale.py
@@ -106,3 +106,63 @@ def test_cli_setup_flow_and_gui_picker_agree(monkeypatch):
cli = model_setup_flows._nous_model_catalog(False, "", ["nous/a"], pricing)
assert cli is not None
assert cli[0] == msp._nous_picker_model_ids({"nous": ["nous/a"]}, False)
+
+
+def _login_picker_ids(monkeypatch, *, free_tier: bool, pricing: dict, allowed=None) -> list:
+ """Model ids the post-login picker (``hermes auth add nous`` / re-auth) offers."""
+ from hermes_cli import auth_nous
+
+ _stub_portal(monkeypatch, free_tier=free_tier, pricing=pricing, allowed=allowed)
+ monkeypatch.setattr("hermes_cli.models.get_curated_nous_model_ids", lambda *a, **kw: ["curated/only"])
+ monkeypatch.setattr(auth_nous, "_portal_entitlement_message", lambda *a, **kw: "")
+ offered: dict = {}
+
+ def _prompt(model_ids, **kw):
+ offered["ids"] = list(model_ids)
+ offered["unavailable"] = list(kw.get("unavailable_models") or [])
+ return model_ids[0] if model_ids else None
+
+ monkeypatch.setattr("hermes_cli.auth._prompt_model_selection", _prompt)
+ auth_nous._pick_nous_model_after_login({"agent_key": "k", "portal_base_url": ""}, "https://x.test/v1")
+ return offered.get("ids", []) + offered.get("unavailable", []) # selectable, then greyed-out
+
+
+def test_post_login_picker_paid_tier_shows_on_sale_model(monkeypatch):
+ """The sign-in picker applies the same on-sale union as ``hermes model`` (review on #121906)."""
+ pricing = {"curated/only": dict(_LIST), "vendor/sale": _sale(80)}
+ assert _login_picker_ids(monkeypatch, free_tier=False, pricing=pricing) == ["curated/only", "vendor/sale"]
+
+
+def test_post_login_picker_free_tier_does_not_list_paid_sales(monkeypatch):
+ """Not even greyed out: free accounts get freeRecommendedModels, as in the other pickers."""
+ pricing = {"curated/only": {"prompt": "0", "completion": "0"}, "vendor/sale": _sale(80)}
+ assert "vendor/sale" not in _login_picker_ids(monkeypatch, free_tier=True, pricing=pricing)
+
+
+def test_post_login_picker_org_policy_still_narrows_on_sale_models(monkeypatch):
+ pricing = {"curated/only": dict(_LIST), "vendor/sale": _sale(80)}
+ ids = _login_picker_ids(monkeypatch, free_tier=False, pricing=pricing, allowed={"curated/only"})
+ assert ids == ["curated/only"]
+
+
+def test_all_three_paid_pickers_agree(monkeypatch):
+ """Sign-in picker, ``hermes model`` and the GUI/in-chat picker list the same paid Nous models."""
+ pricing = {"curated/only": dict(_LIST), "sale/x": _sale(80), "sale/y": _sale(30)}
+ login = _login_picker_ids(monkeypatch, free_tier=False, pricing=pricing)
+ cli = model_setup_flows._nous_model_catalog(False, "", ["curated/only"], pricing)
+ gui = msp._nous_picker_model_ids({"nous": ["curated/only"]}, False)
+ assert cli is not None
+ assert login == cli[0] == gui == ["curated/only", "sale/x", "sale/y"]
+
+
+def test_skips_generation_models_on_sale(monkeypatch):
+ """Image/video generation rows stay out of the chat picker even when discounted."""
+ mp._pricing_cache.clear()
+ _serve(monkeypatch, {"data": [
+ {"id": "chat/ok", "pricing": _sale(50)},
+ {"id": "gen/typed", "capabilities": {"type": "image"}, "pricing": _sale(90)},
+ {"id": "vendor/flux-pro", "pricing": _sale(90)}, # generation by name shape alone
+ ]})
+ nous = fetch_models_with_pricing(api_key="sk-test", base_url="https://example.test",
+ force_refresh=True, include_sale_original=True)
+ assert union_with_nous_on_sale_models([], nous) == ["chat/ok"]