The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): honor per-capability web backend keys when highlighting picker rows
kokhlo6b6976e7cd83
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.pyindex a1721524440..1a3556b9371 100644--- a/hermes_cli/tools_config_providers.py+++ b/hermes_cli/tools_config_providers.py@@ -348,6 +348,30 @@ def _web_tier_matches(provider: dict, config: dict) -> bool:return row_tier == ("paid" if has_key else "free")+def _web_backend_active(provider: dict, config: dict) -> bool:+ """True when a web row's ``web_backend`` serves either capability as configured.++ ``web_search``/``web_extract`` resolve their own ``web.search_backend`` /+ ``web.extract_backend`` override first and only then fall back to the shared+ ``web.backend`` (``tools/web_tools.py``: ``_get_search_backend`` /+ ``_get_extract_backend``), so a vendor serving one capability through its+ override is in use even when the shared key names a different one. Managed Nous+ rows never reach here — they answer in ``_managed_provider_active``.+ """+ backend = provider.get("web_backend")+ if not backend:+ return False+ raw_web_cfg = config.get("web")+ web_cfg = raw_web_cfg if isinstance(raw_web_cfg, dict) else {}+ # Dispatch lower-cases and strips the configured name; compare the same way.+ selected = set()+ for key in ("backend", "search_backend", "extract_backend"):+ value = web_cfg.get(key)+ if isinstance(value, str) and value.strip():+ selected.add(value.lower().strip())+ return backend in selected and _web_tier_matches(provider, config)++# Managed-row marker -> (config section, key) the pick writes, in check order._MANAGED_SELECTION_KEYS: tuple[tuple[str, str, str], ...] = (("tts_provider", "tts", "provider"), ("stt_provider", "stt", "provider"),@@ -458,7 +482,7 @@ _ACTIVE_CHECKS: tuple[tuple[str, Callable[[dict, dict], bool]], ...] = (("stt_provider", lambda p, c: (cfg_get(c, "stt", "provider") or "local") == p["stt_provider"]),("browser_provider", _browser_provider_active),("browser_backend", _browser_backend_active),- ("web_backend", lambda p, c: cfg_get(c, "web", "backend") == p["web_backend"] and _web_tier_matches(p, c)),+ ("web_backend", _web_backend_active),("computer_use_backend", lambda p, c: cfg_get(c, "computer_use", "backend") == p["computer_use_backend"]),("imagegen_backend", _imagegen_backend_active))diff --git a/tests/tools/test_web_picker_active_rows.py b/tests/tools/test_web_picker_active_rows.pynew file mode 100644index 00000000000..d50889b7269--- /dev/null+++ b/tests/tools/test_web_picker_active_rows.py@@ -0,0 +1,104 @@+"""Picker row highlighting for per-capability web backends.++``web_search``/``web_extract`` resolve ``web.search_backend`` / ``web.extract_backend``+first and only then fall back to the shared ``web.backend`` (tools/web_tools.py+``_get_search_backend`` / ``_get_extract_backend``). The picker row's ``is_active``+must follow the same precedence, otherwise a vendor that is genuinely serving one+capability is displayed as inactive.+"""++import pytest++from hermes_cli.tools_config_providers import _is_provider_active++[email protected](autouse=True)+def _no_web_env(monkeypatch):+ """Keep tier auto-detection out of the picture: no web credentials present."""+ for var in (+ "EXA_API_KEY",+ "PARALLEL_API_KEY",+ "TAVILY_API_KEY",+ "FIRECRAWL_API_KEY",+ "FIRECRAWL_API_URL",+ ):+ monkeypatch.delenv(var, raising=False)+ monkeypatch.setattr(+ "agent.web_search_provider.get_provider_env", lambda name: "", raising=True+ )+++def _row(backend: str, **extra) -> dict:+ return {"name": backend, "web_backend": backend, "env_vars": [], **extra}+++class TestSplitCapabilityRowsAreActive:+ def test_extract_only_backend_is_active(self):+ """The reported config: search on firecrawl, extract on tavily."""+ config = {+ "web": {+ "search_backend": "firecrawl",+ "extract_backend": "tavily",+ "backend": "firecrawl",+ }+ }+ assert _is_provider_active(_row("tavily"), config) is True++ def test_search_only_backend_is_active(self):+ config = {+ "web": {+ "search_backend": "searxng",+ "extract_backend": "firecrawl",+ "backend": "firecrawl",+ }+ }+ assert _is_provider_active(_row("searxng"), config) is True++ def test_shared_key_fallback_still_highlights(self):+ """Neither per-capability key set → shared ``web.backend`` decides, as before."""+ config = {"web": {"backend": "tavily"}}+ assert _is_provider_active(_row("tavily"), config) is True+ assert _is_provider_active(_row("firecrawl"), config) is False++ def test_unrelated_backend_stays_inactive(self):+ config = {+ "web": {+ "search_backend": "firecrawl",+ "extract_backend": "tavily",+ "backend": "firecrawl",+ }+ }+ assert _is_provider_active(_row("ddgs"), config) is False+ assert _is_provider_active(_row("searxng"), config) is False++ def test_backend_naming_one_capability_does_not_claim_the_other(self):+ """``search_backend: tavily`` alone: tavily serves search, not extract."""+ config = {"web": {"search_backend": "tavily", "backend": "firecrawl"}}+ assert _is_provider_active(_row("tavily"), config) is True+ assert _is_provider_active(_row("firecrawl"), config) is True++ def test_empty_capability_keys_fall_back_to_shared(self):+ """Blank overrides are what a cleared selection leaves behind."""+ config = {"web": {"search_backend": "", "extract_backend": None, "backend": "searxng"}}+ assert _is_provider_active(_row("searxng"), config) is True++ def test_case_and_whitespace_match_dispatch(self):+ """The dispatchers lower-case and strip the config value; highlighting must agree."""+ config = {"web": {"search_backend": " FireCrawl ", "backend": "tavily"}}+ assert _is_provider_active(_row("firecrawl"), config) is True++ def test_tier_gate_still_applies_to_capability_keys(self):+ """Tiered rows (exa/parallel free vs paid) keep the tier discriminator."""+ config = {+ "web": {+ "search_backend": "parallel",+ "provider_tier": {"parallel": "paid"},+ }+ }+ assert _is_provider_active(_row("parallel", web_tier="paid"), config) is True+ assert _is_provider_active(_row("parallel", web_tier="free"), config) is False+++class TestNonWebProvidersUnaffected:+ def test_row_without_web_backend_is_never_active(self):+ assert _is_provider_active({"name": "openai", "env_vars": []}, {"web": {}}) is False\ No newline at end of file