Skip to content

The agent that grows with you

fix(tools): don't pre-check keyless local backends in Tool Gateway checklist

chelsealong4edb24276fb3
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.py
index 3ef724b3503..a6fe82ac0ef 100644
--- a/hermes_cli/nous_subscription.py
+++ b/hermes_cli/nous_subscription.py
@@ -1034,16 +1034,34 @@ _GATEWAY_DIRECT_LABELS = {
_ALL_GATEWAY_KEYS = ("web", "image_gen", "video_gen", "tts", "stt", "browser")
+# Config section + selection field for each gateway key, matching the
+# field names ``apply_gateway_defaults`` writes and
+# ``get_nous_subscription_features`` reads (web uses "backend", browser
+# uses "cloud_provider", everything else uses "provider").
+_GATEWAY_SECTION_FIELDS = {
+ "web": ("web", "backend"),
+ "image_gen": ("image_gen", "provider"),
+ "video_gen": ("video_gen", "provider"),
+ "tts": ("tts", "provider"),
+ "stt": ("stt", "provider"),
+ "browser": ("browser", "cloud_provider"),
+}
+
def get_gateway_eligible_tools(
config: Optional[Dict[str, object]] = None,
*,
force_fresh: bool = False,
-) -> tuple[list[str], list[str], list[str]]:
- """Return (unconfigured, has_direct, already_managed) tool key lists.
+) -> tuple[list[str], list[str], list[str], list[str]]:
+ """Return (unconfigured, has_direct, explicit_configured, already_managed)
+ tool key lists.
- - unconfigured: tools with no direct credentials (easy switch)
+ - unconfigured: tools with no direct credentials and no explicit
+ non-nous selection (easy switch, safe to pre-check)
- has_direct: tools where the user has their own API keys
+ - explicit_configured: tools with an explicit non-nous selection stored
+ (e.g. ``web.backend: searxng``), including keyless backends that would
+ otherwise look unconfigured
- already_managed: tools already routed through the gateway
All lists are empty when the user is not a paid Nous subscriber or
@@ -1084,6 +1102,7 @@ def get_gateway_eligible_tools(
unconfigured: list[str] = []
has_direct: list[str] = []
+ explicit_configured: list[str] = []
already_managed: list[str] = []
for key in _ALL_GATEWAY_KEYS:
# Only offer tools the user's entitlement actually covers. For a free
@@ -1093,13 +1112,20 @@ def get_gateway_eligible_tools(
MANAGED_FEATURE_COVERAGE_CATEGORY[key]
):
continue
+ section_key, field = _GATEWAY_SECTION_FIELDS[key]
+ selected = _selected_provider(config.get(section_key), field)
if opted_in.get(key):
already_managed.append(key)
+ elif selected is not None and selected != "nous":
+ # An explicit non-nous selection (e.g. a keyless local backend
+ # like SearXNG or Camofox) is configured on purpose, even
+ # though it has no direct credentials to detect.
+ explicit_configured.append(key)
elif direct.get(key):
has_direct.append(key)
else:
unconfigured.append(key)
- return unconfigured, has_direct, already_managed
+ return unconfigured, has_direct, explicit_configured, already_managed
def apply_gateway_defaults(
@@ -1193,7 +1219,10 @@ def prompt_enable_tool_gateway(
Returns the set of tools that were enabled, or empty set if the user
declined or no tools were eligible.
"""
- unconfigured, has_direct, already_managed = get_gateway_eligible_tools(
+ # explicit_configured tools (e.g. an explicit `web.backend: searxng`) are
+ # configured on purpose and are never offered here — same treatment as
+ # already_managed, just for a non-nous vendor.
+ unconfigured, has_direct, _explicit_configured, already_managed = get_gateway_eligible_tools(
config,
force_fresh=force_fresh,
)
diff --git a/tests/hermes_cli/test_nous_subscription.py b/tests/hermes_cli/test_nous_subscription.py
index db602ff42cc..7a83150113c 100644
--- a/tests/hermes_cli/test_nous_subscription.py
+++ b/tests/hermes_cli/test_nous_subscription.py
@@ -206,6 +206,46 @@ def test_prompt_enable_tool_gateway_pool_offers_covered_tools_only(monkeypatch):
assert "free" in captured["title"].lower() and "pool" in captured["title"].lower()
+def test_get_gateway_eligible_tools_treats_explicit_backend_as_configured(monkeypatch):
+ """A keyless local backend (e.g. searxng) has no credentials to detect,
+ but an explicit non-nous selection must still keep it out of
+ 'unconfigured' — regression for #92647, where it was pre-checked and a
+ single Enter during `hermes model` overwrote it to `web.backend: nous`.
+ """
+ monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _account(logged_in=True, paid=True))
+ monkeypatch.setattr(
+ ns,
+ "_get_gateway_direct_credentials",
+ lambda: {"web": False, "image_gen": False, "video_gen": False, "tts": False, "browser": False},
+ )
+
+ config = {"model": {"provider": "nous"}, "web": {"backend": "searxng"}}
+ unconfigured, has_direct, explicit_configured, already_managed = ns.get_gateway_eligible_tools(config)
+
+ assert "web" not in unconfigured
+ assert "web" not in has_direct
+ assert "web" in explicit_configured
+ assert "web" not in already_managed
+
+
+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
+ by an accidental Enter."""
+ monkeypatch.setattr(ns, "get_nous_portal_account_info", lambda **kw: _account(logged_in=True, paid=True))
+ monkeypatch.setattr(
+ ns,
+ "_get_gateway_direct_credentials",
+ lambda: {"web": False, "image_gen": False, "video_gen": False, "tts": False, "browser": False},
+ )
+ captured = _capture_checklist(monkeypatch, selected_idx=[])
+
+ config = {"model": {"provider": "nous"}, "web": {"backend": "searxng"}}
+ ns.prompt_enable_tool_gateway(config)
+
+ blob = " ".join(captured["items"]).lower()
+ assert "firecrawl" not in blob # web (searxng-configured) NOT offered
+ assert "image" in blob # other unconfigured tools still offered
def test_apply_nous_managed_defaults_writes_video_gen_config(monkeypatch):