Skip to content

The agent that grows with you

fix: recognize browser.backend as a configured provider signal

obtituse6ae3d4a9ea1
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.py
index e9abd1e9001..5830b8946aa 100644
--- a/hermes_cli/tools_config_providers.py
+++ b/hermes_cli/tools_config_providers.py
@@ -224,7 +224,16 @@ def _toolset_needs_configuration_prompt(ts_key: str, config: dict, *, force_fres
selection_key = {"tts": "provider", "web": "backend", "browser": "cloud_provider"}.get(ts_key)
if selection_key:
section = config.get(ts_key, {})
- return not isinstance(section, dict) or selection_key not in section
+ if not isinstance(section, dict):
+ 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
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
@@ -409,10 +418,26 @@ 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_active(provider: dict, config: dict) -> bool:
- backend = cfg_get(config, "browser", "backend")
- if backend is False:
- backend = "off" # YAML 1.1: unquoted `off` parses as boolean False
+ """Check if a provider entry matches the currently active config."""
+ backend = _browser_cfg(config, "backend")
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 036e872abde..d6c403aa16a 100644
--- a/tests/hermes_cli/test_post_setup_gating.py
+++ b/tests/hermes_cli/test_post_setup_gating.py
@@ -57,3 +57,47 @@ class TestPostSetupGate:
monkeypatch.setitem(tools_config._POST_SETUP_INSTALLED, "cua_driver", _boom)
assert tools_config._post_setup_already_installed("cua_driver") is True
+
+class TestBrowserBackendPrompt:
+ """Regression: `_toolset_needs_configuration_prompt` for the browser toolset
+ only checked `browser.cloud_provider` (set by `browser_provider` rows),
+ ignoring `browser.backend` (set by the `browser_backend` "Browser Use" row).
+ This made the provider picker re-appear every time `hermes tools` was
+ opened, even when Browser Use was already configured.
+ """
+
+ def test_browser_backend_set_skips_provider_picker(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ config = {"browser": {"backend": "browser-use"}}
+ assert tools_config._toolset_needs_configuration_prompt("browser", config) is False
+
+ def test_browser_cloud_provider_set_skips_provider_picker(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ config = {"browser": {"cloud_provider": "local"}}
+ assert tools_config._toolset_needs_configuration_prompt("browser", config) is False
+
+ def test_browser_unconfigured_still_prompts(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ assert tools_config._toolset_needs_configuration_prompt("browser", {}) is True
+
+ def test_browser_empty_still_prompts(self, monkeypatch, tmp_path):
+ from hermes_cli import tools_config
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ config = {"browser": None}
+ assert tools_config._toolset_needs_configuration_prompt("browser", config) is True
+
+ def test_browser_backend_off_still_skips_prompt(self, monkeypatch, tmp_path):
+ """YAML 1.1 parses unquoted `off` as boolean False — the helper must
+ normalise it, and the gate should still treat it as 'configured'."""
+ from hermes_cli import tools_config
+
+ 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