Remote Browser Sessions, CDP Agent Tools, Live View, and Session Recording
How remote headless browser sessions work with CDP, agent browser tools, human handoff via Live View, and rrweb session recordings.
This page summarizes Cloudflare documentation on Browser Run (formerly Browser Rendering): managed Chromium sessions you drive with the Chrome DevTools Protocol (CDP), the Agents SDK Browser and browserTool APIs, and observability features (Live View, Human in the Loop, session recording). Chrome DevTools for agents describes a related idea—repeatable browser scripts for investigations—but Cloudflare’s stack centers on remote sessions, CDP, and Worker bindings.
Browser Run sessions: what you get and when you need them
Section titled “Browser Run sessions: what you get and when you need them”A Browser Session is one remote Chrome instance on Cloudflare’s network. You can open it from the REST/CDP API, a browser binding in a Worker, Puppeteer or Playwright, or agent tools that speak CDP.
Browser Sessions give you full control over a headless browser. You can connect from anywhere using the REST API, or from a Cloudflare Worker using a browser binding.
— Cloudflare, Get started
Use a real browser when the task needs a rendered DOM, client-side JavaScript, network waterfalls, screenshots, or debugging—not when a plain HTTP response is enough. The browser agent example lists inspecting pages, debugging frontends, scraping rendered content, capturing screenshots, and profiling performance; for simple fetches, the docs point to fetch() instead.
| Approach | Session lifetime | Typical use |
|---|---|---|
browserTool / Browser class |
Persistent across turns (until idle timeout or close) | Multi-step agents, logins, return-to-same-tab workflows |
Quick Actions (browser_markdown, browser_links, etc.) |
One-shot: load page, return result, close browser | Stateless reads without a Durable Object |
| CDP WebSocket (Puppeteer/Playwright/MCP) | keep_alive on acquire (10s–20m on binding; up to 20 minutes) |
Scripts, CI, external automation |
wrangler browser create |
CLI-managed session | Local debugging and Live View without wiring tokens in every command |
Quick Actions do not share cookies or login state with a persistent browserTool session—a protected page logged in via the agent is not logged in for a Quick Action unless you pass credentials in options (Quick Action tools).
CDP and browser bindings: connect, command, and manage tabs
Section titled “CDP and browser bindings: connect, command, and manage tabs”CDP is the same protocol Chrome DevTools uses. Browser Run exposes standard DevTools HTTP/WebSocket endpoints so any CDP client can connect.
The Chrome DevTools Protocol (CDP) is a remote debugging protocol that allows you to instrument, inspect, debug, and profile Chromium-based browsers.
— Cloudflare, Chrome DevTools Protocol (CDP)
Acquire a session over WebSocket, for example:
wss://api.cloudflare.com/client/v4/accounts/{account_id}/browser-run/devtools/browser
Query parameters include keep_alive (10 000–1 200 000 ms), recording, lab (experimental Chrome features such as WebMCP), and optional guardrails via the cf-brapi-guardrails header (CDP documentation). Session management (HTTP) covers creating sessions, opening tabs, listing targets, and closing sessions without WebSockets.
Inside a Worker, the typed Browser binding API wraps the same lifecycle: acquire(), connectSession(), launch(), getLiveView(), closeSession(), and nested devtools methods (listTargets, newTarget, getProtocol, etc.). keepAlive on the binding must be between 10 seconds and 20 minutes; you can enable recording, guardrails, outboundByHost, and targets: true at acquire time.
For local wrangler dev, Browser Run has no local simulator—you set remote: true on the browser binding (Local development).
Wrangler CLI: create and view sessions without embedding API tokens
Section titled “Wrangler CLI: create and view sessions without embedding API tokens”Browser Rendering now supports wrangler browser commands, letting you create, manage, and view browser sessions directly from your terminal, streamlining your workflow. Since Wrangler handles authentication, you do not need to pass API tokens in your commands.
— Cloudflare, Manage Browser Rendering sessions with Wrangler CLI
Commands include wrangler browser create, close, list, and view (Wrangler commands). create accepts --keepAlive (60–600 seconds) and --lab for experimental features. view opens Live View for a session—useful when WebMCP tools wait for human confirmation in the live browser.
Agents SDK browser tools: persistent browser vs legacy CDP execute
Section titled “Agents SDK browser tools: persistent browser vs legacy CDP execute”Cloudflare’s recommended path for new agents is the Browser class with browserTool adapters (Pi Durable, AI SDK, TanStack AI), not the deprecated createBrowserTools from agents/browser/ai (Browser tools).
Give your agent a browser it can return to on later turns. Browser Run keeps the remote browser open, so your agent can continue from the same page with its tabs, cookies, and login session intact while the browser session remains alive.
— Cloudflare, Browser
The remote browser runs outside the agent’s Durable Object; the object stores the session id and reconnects after hibernation while the session is still alive. By default an idle browser stays up for about 10 minutes (keepAliveMs); expiry or a crash clears tabs, cookies, and logins—it is not permanent storage.
How the model drives the browser
Section titled “How the model drives the browser”With the current Agents SDK direction, the model uses a durable browser_execute tool and writes code against CDP instead of a fixed action list:
Agents can now use Browser Run through a single durable browser_execute tool. Instead of choosing from a fixed list of actions, the model writes code against the Chrome DevTools Protocol (CDP) and can inspect pages, capture screenshots, read rendered content, debug frontend behavior, and interact with live browser sessions.
— Cloudflare, Agents SDK improves browser automation, code execution, and recovery
The browser API inside sandboxed tool code includes browser.cdp(), browser.attachToTarget(), browser.spec(), internal host helpers (assignHost, listHosts), and limits: each call runs in an isolated Dynamic Worker with no fetch()/connect(), default 60s timeout, results truncated (~24 000 characters), screenshots up to 1 MB (Browser API).
Legacy createBrowserTools still exposes browser_search + browser_execute with a cdp helper; each legacy browser_execute call historically opened a fresh session per invocation unless you configure session: { mode: "dynamic" | "reuse" } (browser agent, Session lifecycle). Modes:
- one-shot (default): new session per execution, torn down when the run ends
- reuse: named shared session until closed or swept
- dynamic: start one-shot; model can
cdp.startSession()to promote after login
Sessions persist in Durable Object storage across hibernation and approval pauses. browserTool does not pause a run while a human uses Live View—hand off between turns (Hand off to a person).
Quick Action tools and the links endpoint
Section titled “Quick Action tools and the links endpoint”Stateless Quick Actions (browser_markdown, browser_extract, browser_links, browser_scrape) need only the browser binding—no Loader or Durable Object (Quick Action tools). The REST links endpoint is:
https://api.cloudflare.com/client/v4/accounts/<accountId>/browser-run/links
Use Quick Actions for one-shot reads; use browserTool when the agent must return to the same logged-in browser.
Live View: see and control the remote browser in real time
Section titled “Live View: see and control the remote browser in real time”Live View connects to a page target (usually one tab) in an active session.
Live View lets you see and interact with a remote Browser Run session in real time. This is useful for debugging automation scripts, monitoring what a browser is doing, or manually stepping in when a task requires human intervention.
— Cloudflare, Live View
Access paths:
- Cloudflare dashboard — Browser Run → Live Sessions (Live View)
devtoolsFrontendUrlfrom API responses (targets=trueorjson/list) — opens the hosted UI atlive.browser.run- Native Chrome DevTools — replace the
https://live.browser.run/ui/inspector?wss=prefix withdevtools://devtools/bundled/inspector.html?wss=in Chrome only
Modes for generated URLs: tab (single page control), full (tabs chrome), devtools (full DevTools panels) (Live View).
From agent application code, browser.liveView() lists open tabs and Live View links; it returns undefined if no browser is open. URLs are bearer credentials (~5 minute start deadline by default, up to 1 hour via expiresInMs):
Live View URLs are bearer credentials. Anyone with a link can control the browser, including the sites it is logged in to. Show the links only to trusted, authenticated users. Do not give them to the model, and do not store them.
— Cloudflare, Hand off to a person
For view-only sharing, REST Live View can set guardrails: { "mode": "readonly" }; that blocks automation clients from driving the session with Puppeteer/Playwright (Live View).
At the CDP layer, Cloudflare.getLiveView returns devtoolsFrontendUrl when connected to Browser Run (Human in the Loop). Agents SDK browser.liveView({ mode: "tab" }) is the handoff pattern: user acts in Live View; on the next turn the model continues with updated cookies (Live View and human takeover).
Human in the Loop: login, MFA, CAPTCHA, and approvals
Section titled “Human in the Loop: login, MFA, CAPTCHA, and approvals”Some flows cannot be fully automated. Human in the Loop lets an operator step into the same live session via Live View, then automation resumes.
When your agent hits a snag like a login page or unexpected edge case, it can hand off to a human instead of failing. With Human in the Loop, a human steps into the live browser session through Live View, resolves the issue, and hands control back to the script.
— Cloudflare, Browser Run adds Live View, Human in the Loop, and Session Recordings
Browser Run extends CDP with Cloudflare.* commands (only on Browser Run sessions):
| Command | Role |
|---|---|
Cloudflare.getLiveView |
Generate operator URL (mode: tab, full, or devtools) |
Cloudflare.handoff |
Request intervention with instructions and optional timeout (max 30 minutes) |
Cloudflare.handoffComplete |
Event when operator marks Done/Failed or handoff times out |
The structured handoff flow: subscribe to Cloudflare.handoffComplete, share Live View, send Cloudflare.handoff, wait for completion, then continue (Human in the Loop). mode: "tab" is required for handoff UI support. A simpler manual detection pattern shares Live View and polls the page (for example waiting for a logged-in DOM signal).
Legacy Code Mode can pause a run with the browser intact: cdp.getLiveViewUrl(), approval-gated call, durable log replay on resume—model code must not use Promise.all for CDP calls (Approval and human handoff). The model cannot invoke Cloudflare.getLiveView, Cloudflare.handoff, or Browser.close from sandboxed browser tool code; the application owns those (Browser API).
Session recording: rrweb replay after the browser closes
Section titled “Session recording: rrweb replay after the browser closes”Session recording captures DOM changes, input, and navigation as structured rrweb events—not video—so you can audit what an agent did (Session recording).
Session recording captures DOM changes, mouse and keyboard events, and page navigation as structured JSON events — not a video — so it is lightweight and easy to inspect.
— Cloudflare, Session recording
Enable at session acquisition (recording: true on binding, Puppeteer/Playwright launch, or ?recording=true on the CDP WebSocket URL). Recording cannot be turned on when reconnecting to an existing session. The recording finalizes when the session closes (explicit close, idle keep_alive, or Worker termination).
Retrieve via dashboard (Browser Run → Runs) or:
GET https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/browser-run/recording/<SESSION_ID>
Agents SDK: note sessionId with browser.resolve() while open, then getBrowserRecording() after close (Recording). Limits: 30 days retention, 2 hours max per session, not available for Quick Actions; input fields masked by default in rrweb (Session recording, Recording).
Guardrails and internal hosts: limit where automation can go
Section titled “Guardrails and internal hosts: limit where automation can go”Guardrails restrict HTTP/HTTPS hostnames for full browser sessions (CDP, Puppeteer, Playwright)—not Quick Actions (Guardrails). Set allowedDomains and optional allowedDomainSets (for example common-cdns) via REST or binding.
For agent-only internal dev previews, Browser supports up to eight internal hostnames (*.internal, .test, .example, .invalid), plain HTTP on port 80, no HTTPS/WebSockets on those hosts (Limits). Guardrails do not apply to internal hosts; setting allowedDomains: [] can restrict the browser to internal hosts only. Internal hosts work when the Worker is deployed, not in local dev without them.
Repeatable browser state for investigations (Chrome DevTools CLI)
Section titled “Repeatable browser state for investigations (Chrome DevTools CLI)”When an agent must debug a complex UI state (checkout step, filtered dashboard), re-building that state every chat is expensive. Google’s Chrome DevTools CLI for agents recommends capturing steps as a script:
Complex states, such as a multi-step checkout or a filtered dashboard, are expensive for an agent to rebuild conversationally every time. Use a saved script as the starting point for a new investigation.
— Google Chrome, Automate repeatable browser workflows with the Chrome DevTools CLI
That pattern complements Cloudflare’s persistent Browser Run sessions and dynamic/reuse session modes: scripts seed state; remote sessions keep cookies and tabs across agent turns.
Common mistakes
Section titled “Common mistakes”- Using Quick Actions for a page that needs an existing login from
browserTool - Treating Live View URLs as shareable with the model or storing them in logs
- Expecting recording after reconnecting without
recording: trueat acquire - Assuming sub-agents can host
Browser(not supported yet) - Changing internal hostname sets without
browser.close(), leaving a stale browser until next use - Double-submitting after an interrupted browser tool call—replay is intentional avoided
- Using readonly Live View links with Puppeteer/Playwright automation on the same session
How to check this on your site
Section titled “How to check this on your site”- Create a session with Wrangler
browser createor the CDP acquire flow and confirm you receive asessionIdand, withtargets=true, adevtoolsFrontendUrl. - Open Live View via the URL or
wrangler browser viewand confirm the remote tab loads and accepts input intabmode (Live View). - Run a short automation script with Puppeteer or Playwright over the CDP WebSocket and verify
Page.navigateand target listing via session HTTPjson/list. - Enable
recording: true, close the session, and confirm the run appears under Browser Run Runs or via the recording API. - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about so it can be corrected quickly.