Problem
When a user has Chrome running with --remote-debugging-port=9222, the agent's browser_navigate tool still falls through to launching a separate headless Chromium instance via Playwright (--session mode). This wastes time, resources, and ignores the user's live browser — which may have logged-in sessions, specific tabs open, etc.
The /browser connect command already knows how to detect and connect to Chrome on port 9222 (cli.py lines 5203-5213), but this logic lives exclusively in the CLI and is not available to the agent's browser tool.
Solution
Add _auto_detect_local_chrome() to tools/browser_tool.py that:
- Probes
localhost:9222 for a listening socket (1s timeout)
- If open, fetches
/json/version and resolves the WebSocket debugger URL
- Returns the
ws://... URL, or empty string if Chrome isn't running
Wire this into _get_session_info() as a step between 'no cloud provider configured' and 'launch headless Chromium via Playwright'.
Priority chain
BROWSER_CDP_URL env var (explicit, e.g. /browser connect)
config.yaml → browser.cdp_url (persistent fallback)
- Auto-detect Chrome on port 9222 (NEW)
- Cloud browser provider (Browserbase, Browser-Use)
- Local headless Chromium launch (
--session)
Testing
- Manual:
python3 -c 'from tools.browser_tool import _auto_detect_local_chrome; print(_auto_detect_local_chrome())' returns ws://localhost:9222/devtools/browser/... when Chrome is running
- Unit tests: mock socket probe, test resolution path
- Integration:
browser_navigate connects to live Chrome without needing /browser connect
Files changed
tools/browser_tool.py: new _auto_detect_local_chrome(), updated _get_session_info()
- Also synced
_get_cdp_override() config.yaml fallback (was in installed version, missing from upstream)
Problem
When a user has Chrome running with
--remote-debugging-port=9222, the agent'sbrowser_navigatetool still falls through to launching a separate headless Chromium instance via Playwright (--sessionmode). This wastes time, resources, and ignores the user's live browser — which may have logged-in sessions, specific tabs open, etc.The
/browser connectcommand already knows how to detect and connect to Chrome on port 9222 (cli.py lines 5203-5213), but this logic lives exclusively in the CLI and is not available to the agent's browser tool.Solution
Add
_auto_detect_local_chrome()totools/browser_tool.pythat:localhost:9222for a listening socket (1s timeout)/json/versionand resolves the WebSocket debugger URLws://...URL, or empty string if Chrome isn't runningWire this into
_get_session_info()as a step between 'no cloud provider configured' and 'launch headless Chromium via Playwright'.Priority chain
BROWSER_CDP_URLenv var (explicit, e.g./browser connect)config.yaml→browser.cdp_url(persistent fallback)--session)Testing
python3 -c 'from tools.browser_tool import _auto_detect_local_chrome; print(_auto_detect_local_chrome())'returnsws://localhost:9222/devtools/browser/...when Chrome is runningbrowser_navigateconnects to live Chrome without needing/browser connectFiles changed
tools/browser_tool.py: new_auto_detect_local_chrome(), updated_get_session_info()_get_cdp_override()config.yaml fallback (was in installed version, missing from upstream)