The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(nous): show the policy notice only when the filter narrowed the list
Mariano Nicolinif48e61bb9962
diff --git a/hermes_cli/auth.py b/hermes_cli/auth.pyindex e24bbe63555..c5e790b9569 100644--- a/hermes_cli/auth.py+++ b/hermes_cli/auth.py@@ -9395,6 +9395,7 @@ def _login_nous(args, pconfig: ProviderConfig) -> None:# Narrow before the tier split, so a rescued id still has to# pass the free/paid predicate._policy_allowed = nous_policy_allowed_ids()+ _policy_narrowed = Falseif free_tier:try:from hermes_cli.nous_account import (@@ -9420,9 +9421,11 @@ def _login_nous(args, pconfig: ProviderConfig) -> None:model_ids, pricing = union_with_portal_free_recommendations(model_ids, pricing, _portal_for_recs,)+ _before_policy = model_idsmodel_ids = restrict_to_nous_policy(model_ids, _policy_allowed, rescue_empty=True,)+ _policy_narrowed = model_ids != _before_policymodel_ids, unavailable_models = partition_nous_models_by_tier(model_ids, pricing, free_tier=True,)@@ -9434,14 +9437,16 @@ def _login_nous(args, pconfig: ProviderConfig) -> None:model_ids, pricing = union_with_portal_paid_recommendations(model_ids, pricing, _portal_for_recs,)+ _before_policy = model_idsmodel_ids = restrict_to_nous_policy(model_ids, _policy_allowed, rescue_empty=True,)+ _policy_narrowed = model_ids != _before_policy_portal = auth_state.get("portal_base_url", "")if model_ids:from hermes_cli.nous_account import nous_policy_notice- _policy_notice = nous_policy_notice()+ _policy_notice = nous_policy_notice(removed=_policy_narrowed)if _policy_notice:print(_policy_notice)print(f"Showing {len(model_ids)} curated models — use \"Enter custom model name\" for others.")diff --git a/hermes_cli/model_setup_flows.py b/hermes_cli/model_setup_flows.pyindex c24274591de..827caa43701 100644--- a/hermes_cli/model_setup_flows.py+++ b/hermes_cli/model_setup_flows.py@@ -538,6 +538,7 @@ def _model_flow_nous(config, current_model="", args=None):from hermes_cli.models import nous_policy_allowed_ids, restrict_to_nous_policy_policy_allowed = nous_policy_allowed_ids()+ _policy_narrowed = Falseif free_tier:try:@@ -559,9 +560,11 @@ def _model_flow_nous(config, current_model="", args=None):model_ids, pricing = union_with_portal_free_recommendations(model_ids, pricing, _nous_portal_url,)+ _before_policy = model_idsmodel_ids = restrict_to_nous_policy(model_ids, _policy_allowed, rescue_empty=True,)+ _policy_narrowed = model_ids != _before_policymodel_ids, unavailable_models = partition_nous_models_by_tier(model_ids, pricing, free_tier=True)@@ -569,9 +572,11 @@ def _model_flow_nous(config, current_model="", args=None):model_ids, pricing = union_with_portal_paid_recommendations(model_ids, pricing, _nous_portal_url,)+ _before_policy = model_idsmodel_ids = restrict_to_nous_policy(model_ids, _policy_allowed, rescue_empty=True,)+ _policy_narrowed = model_ids != _before_policyif not model_ids and not unavailable_models:print("No models available for Nous Portal after filtering.")@@ -588,7 +593,7 @@ def _model_flow_nous(config, current_model="", args=None):from hermes_cli.nous_account import nous_policy_notice- _policy_notice = nous_policy_notice()+ _policy_notice = nous_policy_notice(removed=_policy_narrowed)if _policy_notice:print(_policy_notice)print(diff --git a/hermes_cli/nous_account.py b/hermes_cli/nous_account.pyindex 6eba71c8315..30247ff6619 100644--- a/hermes_cli/nous_account.py+++ b/hermes_cli/nous_account.py@@ -421,14 +421,18 @@ def nous_policy_present() -> Optional[bool]:return None-def nous_policy_notice() -> str:- """A one-line notice for an org that restricts model choice, else ``""``.+def nous_policy_notice(*, removed: bool) -> str:+ """A one-line notice for a list the org's policy narrowed, else ``""``.A blocked model is omitted rather than marked, which reads as "Hermes doesnot support this". This says which it is without enumerating the blockedset, which under an allowlist is most of the catalog.++ *removed* is whether the filter actually dropped anything. The catalog read+ fails open — an anonymous or empty one narrows nothing — so the claim alone+ would label a full list as filtered."""- if nous_policy_present() is not True:+ if not removed or nous_policy_present() is not True:return ""return ("Your organization restricts which models are available — "diff --git a/tests/hermes_cli/test_nous_policy_filter.py b/tests/hermes_cli/test_nous_policy_filter.pyindex 5dc6c60d28f..948885603f8 100644--- a/tests/hermes_cli/test_nous_policy_filter.py+++ b/tests/hermes_cli/test_nous_policy_filter.py@@ -162,18 +162,24 @@ class TestNousPolicyNotice:def test_shows_a_line_for_a_governed_org(self, monkeypatch):self._patch(monkeypatch, True)- assert "restricts which models" in account_mod.nous_policy_notice()+ assert "restricts which models" in account_mod.nous_policy_notice(removed=True)@pytest.mark.parametrize("present", [False, None])def test_silent_otherwise(self, monkeypatch, present):"""Absent is an older mint, not an unrestricted org."""self._patch(monkeypatch, present)- assert account_mod.nous_policy_notice() == ""+ assert account_mod.nous_policy_notice(removed=True) == ""++ def test_silent_when_the_filter_removed_nothing(self, monkeypatch):+ """The catalog read fails open, so a governed org can still end up with+ a full list — saying it was filtered would be false."""+ self._patch(monkeypatch, True)+ assert account_mod.nous_policy_notice(removed=False) == ""def test_names_no_models(self, monkeypatch):"""The blocked set is most of the catalog under an allowlist."""self._patch(monkeypatch, True)- notice = account_mod.nous_policy_notice()+ notice = account_mod.nous_policy_notice(removed=True)assert "/" not in notice, f"looks like it names a model: {notice}"assert len(notice.splitlines()) == 1