The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
simplify(compat): tools/browser_tool — drop the legacy _PROVIDER_REGISTRY test-override shim (+_is_legacy_provider_registry_overridden), repoint 1 test to the agent.browser_registry seam; repoint 1 missed supervisor import
Teknium69eb1feb3e39
diff --git a/tests/tools/test_browser_cloud_provider_cache.py b/tests/tools/test_browser_cloud_provider_cache.pyindex b32acee1578..44bb8fa9564 100644--- a/tests/tools/test_browser_cloud_provider_cache.py+++ b/tests/tools/test_browser_cloud_provider_cache.py@@ -250,13 +250,12 @@ class TestCloudProviderCachePolicy:def test_explicit_provider_instantiation_failure_does_not_cache(self, monkeypatch, caplog):- """If `_PROVIDER_REGISTRY[key]()` raises, log warning and don't cache."""- def exploding_factory():+ """If instantiating the registered provider raises, log warning and don't cache."""+ def exploding_factory(name):raise RuntimeError("missing dependency")- monkeypatch.setattr(- browser_tool, "_PROVIDER_REGISTRY", {"browser-use": exploding_factory}- )+ monkeypatch.setattr("tools.browser_tool_cloud._ensure_browser_plugins_loaded", lambda: None)+ monkeypatch.setattr("tools.browser_tool_cloud._registry_get_browser_provider", exploding_factory)monkeypatch.setattr("hermes_cli.config.read_raw_config",lambda: {"browser": {"cloud_provider": "browser-use"}},diff --git a/tests/tools/test_browser_secret_exfil.py b/tests/tools/test_browser_secret_exfil.pyindex 4857c1df1e7..1aad081d1c0 100644--- a/tests/tools/test_browser_secret_exfil.py+++ b/tests/tools/test_browser_secret_exfil.py@@ -275,7 +275,8 @@ class TestBrowserSupervisorRedaction:"""Verify supervisor dialog snapshots redact page-originated secrets."""def test_pending_and_recent_dialog_messages_redacted(self):- from tools.browser_supervisor import DialogRecord, PendingDialog, SupervisorSnapshot+ from tools.browser_supervisor import SupervisorSnapshot+ from tools.browser_supervisor_dialogs import DialogRecord, PendingDialogfake_key = "sk-" + "SUPERVISORDIALOGSECRET1234567890"snapshot = SupervisorSnapshot(diff --git a/tools/browser_tool.py b/tools/browser_tool.pyindex c817c490a54..62607b214ab 100644--- a/tools/browser_tool.py+++ b/tools/browser_tool.py@@ -72,9 +72,6 @@ except ImportError:# with only ``get_provider``; no mutable registry → constant generation.def _browser_registry_generation(*, scope=None):return (0, 0)-from plugins.browser.browserbase.provider import BrowserbaseBrowserProvider-from plugins.browser.browser_use.provider import BrowserUseBrowserProvider-from plugins.browser.firecrawl.provider import FirecrawlBrowserProvider# Optional backends: Camofox (CAMOFOX_URL routes everything through its REST API)# and the Browser Use CLI.try:@@ -226,17 +223,6 @@ def _get_vision_model() -> Optional[str]:from tools import browser_tool_cdp as _cdp-# -----------------------------------------------------------------------------# Cloud provider registry — legacy class-name dict is a backward-compat shim:-# honoured when a test monkeypatches it, otherwise agent.browser_registry wins.-# ------------------------------------------------------------------------------_PROVIDER_REGISTRY: Dict[str, type] = {- "browserbase": BrowserbaseBrowserProvider, "browser-use": BrowserUseBrowserProvider, "firecrawl": FirecrawlBrowserProvider,-}-# Frozen import-time copy used to detect test-time monkeypatching. NEVER mutate.-_DEFAULT_PROVIDER_REGISTRY: Dict[str, type] = dict(_PROVIDER_REGISTRY)-from tools import browser_tool_cloud as _cloudfrom tools import browser_tool_lightpanda_fallback as _lpdiff --git a/tools/browser_tool_cloud.py b/tools/browser_tool_cloud.pyindex d5c3e6f44b6..3d52d382491 100644--- a/tools/browser_tool_cloud.py+++ b/tools/browser_tool_cloud.py@@ -26,17 +26,6 @@ def _memo(_bt, resolved_attr: str, cache_attr: str, compute: Callable[[], objectreturn getattr(_bt, cache_attr)-def _is_legacy_provider_registry_overridden() -> bool:- """True when a test has patched ``_PROVIDER_REGISTRY`` (identity check per key; extra keys count too)."""- _bt = _origin()- try:- return len(_bt._PROVIDER_REGISTRY) != len(_bt._DEFAULT_PROVIDER_REGISTRY) or any(- _bt._PROVIDER_REGISTRY.get(key) is not default_cls for key, default_cls in _bt._DEFAULT_PROVIDER_REGISTRY.items()- )- except Exception:- return False--def _ensure_browser_plugins_loaded() -> None:"""Idempotently trigger plugin discovery (standalone scripts/tests may never import ``model_tools``)."""try:@@ -80,18 +69,13 @@ def _get_cloud_provider() -> Optional[CloudBrowserProvider]:def _instantiate_explicit_cloud_provider(provider_key: str) -> Optional[CloudBrowserProvider]:"""Build the provider named by ``browser.cloud_provider``.- A patched ``_PROVIDER_REGISTRY`` (test fixtures) drives the legacy dict; otherwise the plugin registry is- consulted. Strict: an unregistered name raises ``ValueError`` (never a silent reroute to auto-detect); any+ Strict: an unregistered name raises ``ValueError`` (never a silent reroute to auto-detect); anyother instantiation error is logged and yields None so the next call retries."""_bt = _origin()try:- if _is_legacy_provider_registry_overridden():- factory = _bt._PROVIDER_REGISTRY.get(provider_key)- resolved = factory() if factory is not None else None- else:- _ensure_browser_plugins_loaded()- resolved = _registry_get_browser_provider(provider_key)+ _ensure_browser_plugins_loaded()+ resolved = _registry_get_browser_provider(provider_key)if resolved is None:from tools.tool_backend_helpers import selection_errorraise ValueError(selection_error(