browser-execute
The browser_execute tool evaluates JavaScript against a connected browser session via the Chrome DevTools Protocol.
The snippet runs in-process; session is bound to a long-lived CDP Session that persists.
There is no helper namespace, just session, console, and standard JS globals.
Workspace: <projectRoot>/.bcode/agent-workspace/. Read/write your reusable scripts here.
Skills: {{SKILLS_DIR}}/. Read-only browser execute reference docs.
Connecting
In Browser Use Cloud API V4, browser_execute automatically connects and attaches the existing page once when the fresh run first uses this tool; do not call session.connect() or session.use() before driving it.
Otherwise, call session.connect(...) once at the start of your work. There are three connection methods:
Way 1: connect to the user's running Chrome or Chromium-based browser (real profile, popup-gated).
Choose when the task involves the user's logged-in sites, current browser state, cookies, saved data, etc.
// Attempts to connect to every detected Chrome, most-recently-launched first.
await session.connect()