The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): web picker stops marking unconfigured rows active or ready
Teknium4482505d18df
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.pyindex ce563de4f7e..217391ff025 100644--- a/hermes_cli/tools_config_providers.py+++ b/hermes_cli/tools_config_providers.py@@ -212,7 +212,20 @@ def provider_readiness_status(provider: dict, config: dict, *, features=None, isis_active = _is_provider_active(provider, config)return "ready" if is_active else "needs_setup"- return "ready"+ return _web_registry_readiness(provider)+++def _web_registry_readiness(provider: dict) -> str:+ """Keyless, untiered web rows are ready only when their registry provider is available: the only such+ row's ``is_available()`` is an account login (OpenAI Native = openai-codex), hence ``needs_auth``.+ Free-tier rows are exempt: they run on the public keyless ring, which ``is_available()`` ignores."""+ backend = provider.get("web_backend")+ if not backend or provider.get("web_tier"):+ return "ready"+ from agent.web_search_registry import get_provider++ registered = get_provider(backend)+ return "ready" if registered is None or registered.is_available() else "needs_auth"def _toolset_needs_configuration_prompt(ts_key: str, config: dict, *, force_fresh: bool = False) -> bool:@@ -372,7 +385,18 @@ def _web_backend_active(provider: dict, config: dict) -> bool:and a shared vendor shadowed by both overrides serves nothing. Managed Nous rows never reachhere — they answer in ``_managed_provider_active``."""backend = provider.get("web_backend")- return bool(backend) and backend in _web_serving_backends(config) and _web_tier_matches(provider, config)+ if not (backend and backend in _web_serving_backends(config) and _web_tier_matches(provider, config)):+ return False+ # Rows sharing one backend name (cloud "Firecrawl" vs the "Firecrawl Self-Hosted" setup row) differ only in+ # the env var they configure, and the one whose var is set is what serves the call. A setup row needs its+ # var; the registry row also stays active keyless (explicit ``firecrawl`` with no key = anonymous cloud)+ # unless a sibling setup row's var is set instead.+ from hermes_cli.tools_config import TOOL_CATEGORIES, _provider_env_ready+ if not provider.get("env_vars") or _provider_env_ready(provider):+ return True+ return bool(provider.get("web_search_plugin_name")) and not any(+ row.get("web_backend") == backend and row.get("env_vars") and _provider_env_ready(row)+ for row in TOOL_CATEGORIES["web"]["providers"])# Managed-row marker -> (config section, key) the pick writes, in check order.diff --git a/tests/tools/test_web_picker_active_rows.py b/tests/tools/test_web_picker_active_rows.pyindex 046275b24c7..46f300ec32d 100644--- a/tests/tools/test_web_picker_active_rows.py+++ b/tests/tools/test_web_picker_active_rows.py@@ -58,3 +58,43 @@ def test_managed_row_active_for_a_nous_capability_pin(monkeypatch):assert _is_provider_active(nous, split) is Trueassert _is_provider_active(_row("firecrawl"), split) is Trueassert _is_provider_active(nous, {"web": {"search_backend": "firecrawl", "extract_backend": "tavily"}}) is False+++def _web_rows():+ from hermes_cli.tools_config import TOOL_CATEGORIES, _visible_providers++ return {p["name"]: p for p in _visible_providers(TOOL_CATEGORIES["web"], {"web": {}})}++[email protected]("env,active", [+ ({"FIRECRAWL_API_KEY": "fc-x"}, {"Firecrawl"}),+ ({"FIRECRAWL_API_URL": "http://localhost:3002"}, {"Firecrawl Self-Hosted"}),+ ({}, {"Firecrawl"}), # explicit selection, no credentials: anonymous cloud+])+def test_firecrawl_rows_split_by_the_credential_set(monkeypatch, env, active):+ """Cloud and Self-Hosted rows share ``web_backend: firecrawl``; only the one whose env var is set+ is the configured provider (#112022), so the picker cursor does not land on an unconfigured row."""+ import hermes_cli.tools_config as tools_config++ monkeypatch.setattr(tools_config, "get_env_value", env.get)+ rows = _web_rows()+ config = {"web": {"backend": "firecrawl"}}+ lit = {name for name in ("Firecrawl", "Firecrawl Self-Hosted") if _is_provider_active(rows[name], config)}+ assert lit == active+++def test_keyless_row_readiness_follows_registry_availability(monkeypatch):+ """No-key rows used to read "ready" vacuously (#132526): OpenAI Native needs an openai-codex login,+ while free-tier keyless rows really run on the public ring."""+ import plugins.web.openai_native.provider as native+ from hermes_cli.tools_config_providers import provider_readiness_status++ rows = _web_rows()+ native_row = next(p for name, p in rows.items() if p.get("web_backend") == "openai-native")+ free_rows = [p for p in rows.values() if p.get("web_tier") == "free"]+ assert free_rows+ monkeypatch.setattr(native, "has_codex_credentials", lambda: False)+ assert provider_readiness_status(native_row, {"web": {}}) == "needs_auth"+ assert {provider_readiness_status(p, {"web": {}}) for p in free_rows} == {"ready"}+ monkeypatch.setattr(native, "has_codex_credentials", lambda: True)+ assert provider_readiness_status(native_row, {"web": {}}) == "ready"