Skip to content

The agent that grows with you

fix(tools): gate the browser picker on an actual backend choice

kshitijk4poore10934b03e11
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.py
index 5830b8946aa..09ffe32bfaa 100644
--- a/hermes_cli/tools_config_providers.py
+++ b/hermes_cli/tools_config_providers.py
@@ -228,12 +228,9 @@ def _toolset_needs_configuration_prompt(ts_key: str, config: dict, *, force_fres
return True
if selection_key in section:
return False
- # Browser's "Browser Use" provider row writes config[ts_key]["backend"]
- # (via the browser_backend marker), not "cloud_provider" — recognize
- # an already-set backend so the provider picker doesn't re-appear.
- if ts_key == "browser" and _browser_cfg(config, "backend") is not None:
- return False
- return True
+ # Browser's "Browser Use" row writes browser.backend and leaves cloud_provider unset. Presence is no
+ # test of a choice here: browser.backend exists on every install after the defaults merge ("" = unset).
+ return not (ts_key == "browser" and _browser_backend(config))
if ts_key == "image_gen": # in-tree FAL backend OR any available plugin image gen provider satisfies
return not fal_key_is_configured() and not _any_plugin_provider_available("agent.image_gen_registry")
if ts_key == "video_gen": # no in-tree fallback — every video backend is a plugin
@@ -418,26 +415,14 @@ def _browser_provider_active(provider: dict, config: dict) -> bool:
return True
-def _browser_cfg(config: dict, key: str):
- """Safely read a value from the ``browser`` config section.
-
- Returns ``None`` when the section or key is absent, or when the section
- is not a dict. Normalises YAML 1.1's quirk where an unquoted ``off``
- in ``browser.backend`` parses as boolean ``False`` — this keeps the
- single place that needs the workaround.
- """
- section = config.get("browser")
- if not isinstance(section, dict):
- return None
- value = section.get(key)
- if key == "backend" and value is False:
- return "off"
- return value
+def _browser_backend(config: dict) -> str:
+ """``browser.backend`` as a string; ``""`` when unset or empty (YAML 1.1 parses an unquoted ``off`` as False)."""
+ backend = cfg_get(config, "browser", "backend")
+ return "off" if backend is False else (backend or "")
def _browser_backend_active(provider: dict, config: dict) -> bool:
- """Check if a provider entry matches the currently active config."""
- backend = _browser_cfg(config, "backend")
+ backend = _browser_backend(config)
if backend == provider["browser_backend"]:
return True
if backend:
diff --git a/tests/hermes_cli/test_post_setup_gating.py b/tests/hermes_cli/test_post_setup_gating.py
index d6c403aa16a..9f1826d080f 100644
--- a/tests/hermes_cli/test_post_setup_gating.py
+++ b/tests/hermes_cli/test_post_setup_gating.py
@@ -101,3 +101,33 @@ class TestBrowserBackendPrompt:
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
config = {"browser": {"backend": False}} # what YAML `off` becomes
assert tools_config._toolset_needs_configuration_prompt("browser", config) is False
+
+
+class TestBrowserBackendPromptThroughLoader:
+ """The browser gate must hold through the real config loader.
+
+ `load_config()` merges ``DEFAULT_CONFIG``, where ``browser.backend`` is ``""`` — so the key is
+ present on every install and a presence test would suppress the picker everywhere. These pin the
+ behaviour against the merged dict a real ``hermes tools`` run feeds the gate.
+ """
+
+ def _home(self, tmp_path, body: str):
+ (tmp_path / "config.yaml").write_text(body, encoding="utf-8")
+ return tmp_path
+
+ def test_unset_browser_still_prompts(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+ from hermes_cli.config import load_config
+
+ monkeypatch.setenv("HERMES_HOME", str(self._home(tmp_path, "cli: {}\n")))
+ config = load_config()
+ assert config["browser"]["backend"] == "" # defaults merge fills the key
+ assert tools_config._toolset_needs_configuration_prompt("browser", config) is True
+
+ def test_explicit_backend_skips_prompt(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+ from hermes_cli.config import load_config
+
+ monkeypatch.setenv("HERMES_HOME", str(self._home(tmp_path, "browser:\n backend: browser-use\n")))
+ config = load_config()
+ assert tools_config._toolset_needs_configuration_prompt("browser", config) is False