Skip to content

The agent that grows with you

fix(gateway): fix 3-tuple/4-tuple arity crash in get_gateway_eligible_tools

chelsealongce9ddd35e792
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.py
index a6fe82ac0ef..115865ea8b5 100644
--- a/hermes_cli/nous_subscription.py
+++ b/hermes_cli/nous_subscription.py
@@ -1073,9 +1073,9 @@ def get_gateway_eligible_tools(
try:
account_info = get_nous_portal_account_info(force_fresh=force_fresh)
except Exception:
- return [], [], []
+ return [], [], [], []
if not (account_info and account_info.logged_in and account_info.tool_gateway_entitled):
- return [], [], []
+ return [], [], [], []
if config is None:
config = load_config() or {}
@@ -1083,7 +1083,7 @@ def get_gateway_eligible_tools(
# Quick provider check without the heavy get_nous_subscription_features call
model_cfg = config.get("model")
if not isinstance(model_cfg, dict) or str(model_cfg.get("provider") or "").strip().lower() != "nous":
- return [], [], []
+ return [], [], [], []
direct = _get_gateway_direct_credentials()
diff --git a/tests/hermes_cli/test_nous_subscription.py b/tests/hermes_cli/test_nous_subscription.py
index 7a83150113c..5ba44836d69 100644
--- a/tests/hermes_cli/test_nous_subscription.py
+++ b/tests/hermes_cli/test_nous_subscription.py
@@ -228,6 +228,29 @@ def test_get_gateway_eligible_tools_treats_explicit_backend_as_configured(monkey
assert "web" not in already_managed
+def test_get_gateway_eligible_tools_not_entitled_returns_four_empty_lists(monkeypatch):
+ """A logged-in Nous account with no paid access and no free tool pool
+ must fail closed with a 4-tuple, not a 3-tuple — regression for a crash
+ where the early 'not entitled' return still had the pre-refactor arity
+ while the happy path and every caller had moved to 4 values."""
+ monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _account(logged_in=True, paid=False))
+
+ config = {"model": {"provider": "nous"}}
+ result = ns.get_gateway_eligible_tools(config)
+
+ assert result == ([], [], [], [])
+
+
+def test_prompt_enable_tool_gateway_not_entitled_does_not_crash(monkeypatch):
+ """The unconditional call site in model_setup_flows (no try/except) must
+ not raise when a Nous account is logged in but not entitled to the Tool
+ Gateway (i.e. an ordinary non-paid, non-pool account)."""
+ monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _account(logged_in=True, paid=False))
+
+ config = {"model": {"provider": "nous"}}
+ assert ns.prompt_enable_tool_gateway(config) == set()
+
+
def test_prompt_enable_tool_gateway_never_offers_explicit_backend(monkeypatch):
"""The checklist itself must not list (let alone pre-check) a tool with
an explicit non-nous selection, so it can never be silently overwritten