From e69d11d30c9d24de3d7a39551679471c40daa6be Mon Sep 17 00:00:00 2001 From: xyiy001 Date: Sun, 26 Apr 2026 21:52:45 +0800 Subject: [PATCH] fix(browser): allow CDP override to pass requirement checks Treat explicit CDP override mode as a valid browser backend even when agent-browser is absent, and add a regression test to prevent false-negative availability gating. --- tests/tools/test_browser_homebrew_paths.py | 7 +++++++ tools/browser_tool.py | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/tools/test_browser_homebrew_paths.py b/tests/tools/test_browser_homebrew_paths.py index eb4a699851..221d2e6602 100644 --- a/tests/tools/test_browser_homebrew_paths.py +++ b/tests/tools/test_browser_homebrew_paths.py @@ -209,6 +209,13 @@ class TestFindAgentBrowser: class TestBrowserRequirements: + def test_cdp_override_does_not_require_agent_browser_cli(self, monkeypatch): + monkeypatch.setenv("BROWSER_CDP_URL", "ws://127.0.0.1:9222/devtools/browser/test") + monkeypatch.setattr("tools.browser_tool._is_camofox_mode", lambda: False) + monkeypatch.setattr("tools.browser_tool._find_agent_browser", lambda: (_ for _ in ()).throw(FileNotFoundError("not found"))) + + assert check_browser_requirements() is True + def test_termux_requires_real_agent_browser_install_not_npx_fallback(self, monkeypatch): monkeypatch.setenv("TERMUX_VERSION", "0.118.3") monkeypatch.setenv("PREFIX", "/data/data/com.termux/files/usr") diff --git a/tools/browser_tool.py b/tools/browser_tool.py index f9ca1a0af1..768cec7f71 100644 --- a/tools/browser_tool.py +++ b/tools/browser_tool.py @@ -2840,7 +2840,12 @@ def check_browser_requirements() -> bool: if _is_camofox_mode(): return True - # The agent-browser CLI is always required + # CDP override mode can connect to an existing remote/local browser endpoint + # without requiring the local agent-browser binary on PATH. + if _get_cdp_override(): + return True + + # The agent-browser CLI is required for local launch and cloud-provider flows. try: browser_cmd = _find_agent_browser() except FileNotFoundError: