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.
This commit is contained in:
xyiy001 2026-04-26 21:52:45 +08:00 committed by Teknium
parent 46072425fe
commit e69d11d30c
2 changed files with 13 additions and 1 deletions

View file

@ -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")

View file

@ -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: