fix(browser-cdp): remove agent-browser requirement from _browser_cdp_check (#15952) - #15979
Conversation
…check (NousResearch#15952) browser_cdp is a pure WebSocket CDP client that needs only a configured CDP endpoint — it never invokes the agent-browser CLI. The old check_fn called check_browser_requirements(), which returns False whenever the agent-browser binary is absent, silently disabling browser_cdp even for users with Chrome running on --remote-debugging-port. Remove the check_browser_requirements() gate from _browser_cdp_check(); only verify that _get_cdp_override() returns a non-empty URL. Update the test that expected the tool to be gated when agent-browser was absent — the correct expectation is that a configured CDP URL is sufficient. Regression guard: reverted fix → test_check_fn_false_when_browser_requirements_fail passed (old behavior: returns False); with fix → returns True. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes tool availability gating for browser_cdp by removing an unnecessary dependency on the agent-browser CLI, aligning the check function with the tool’s actual runtime requirements (a configured CDP WebSocket endpoint).
Changes:
- Remove
check_browser_requirements()fromtools/browser_cdp_tool._browser_cdp_check()soagent-browseris no longer required forbrowser_cdpavailability. - Update/rename the corresponding check_fn unit test to reflect that a CDP URL alone should open the gate.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/browser_cdp_tool.py | Simplifies browser_cdp availability check to depend only on presence of a configured CDP endpoint. |
| tests/tools/test_browser_cdp_tool.py | Updates check_fn gating tests to reflect the new (correct) availability behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| monkeypatch.setattr(bt, "check_browser_requirements", lambda: False) | ||
| monkeypatch.setattr( | ||
| bt, "_get_cdp_override", lambda: "ws://localhost:9222/devtools/browser/x" | ||
| ) |
There was a problem hiding this comment.
The new test test_check_fn_true_when_cdp_url_set_but_agent_browser_missing doesn’t actually simulate agent-browser being missing (it only patches _get_cdp_override, same as the previous test). To make this a real regression guard, patch bt.check_browser_requirements (or _find_agent_browser) to raise/return False and assert _browser_cdp_check() still returns True, or remove/merge this test to avoid redundant coverage.
| ) | |
| ) | |
| def _unexpected_browser_check(): | |
| raise AssertionError( | |
| "check_browser_requirements should not be needed when CDP URL is set" | |
| ) | |
| monkeypatch.setattr(bt, "check_browser_requirements", _unexpected_browser_check) |
…n CDP URL is set Copilot correctly noted the prior test was identical to the happy-path case: both only patched _get_cdp_override without verifying that check_browser_requirements is never reached. Add an assertion-raising monkeypatch so the test actually fails if the removed call were ever re-introduced. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks @copilot — finding is real. Addressed in Redundant test (line 405): Added an assertion-raising monkeypatch on |
|
@copilot The test's intent is to verify that |
|
The behavioral goal (CDP URL sufficient without local agent-browser) was independently achieved on current main by making |
Summary
_browser_cdp_check()calledcheck_browser_requirements()which requires the agent-browser CLI binarybrowser_cdpis a pure WebSocket CDP client that never invokes agent-browser at runtime--remote-debugging-portandbrowser.cdp_urlin config could not use the toolThe bug
_browser_cdp_check()imported and calledcheck_browser_requirements()frombrowser_tool.py. That function looks for the agent-browser binary — returningFalse(and gating the tool out) when it isn't found. Butbrowser_cdpis entirely self-contained: it only needs a WebSocket URL and thewebsocketspackage, which is already a transitive dependency. The agent-browser binary is not invoked anywhere inbrowser_cdp_tool.py.The fix
Remove the
check_browser_requirements()call and its import from_browser_cdp_check(). The only gate needed is whether_get_cdp_override()returns a non-empty endpoint URL. Update the test that verified the old (incorrect) behavior.Test plan
test_check_fn_false_when_browser_requirements_failpassed — old code gated on agent-browsertest_check_fn_true_when_cdp_url_set_but_agent_browser_missingpasses — CDP URL alone opens the gateRelated
🤖 Generated with Claude Code