Prerequisites
- An Anthropic API key with Managed Agents beta access
- A Browserbase API key and project ID
- Node.js 18+
1. Install dependencies
@browserbasehq/browse-cli (browse) to drive the session. Session creation can go through @browserbasehq/cli (bb) or curl — install both so you can switch freely. Step 2 declares them as sandbox dependencies too.
2. Create the agent and environment
Create both once, store the returned IDs as env vars, and reuse them across dispatches.Disabling
web_fetch and web_search forces Claude to browse through Browserbase. Leave them on and Claude shortcuts around the real browser.3. Set your environment variables
4. Dispatch a run
Each dispatch is one turn of the agent loop. Pass the user prompt plus the Browserbase credentials Claude needs to create a session. The prompt tells Claude how to create a session. You can show it either flavor — thebb CLI, or curl straight against the API. Both work; pick whichever you prefer and stay consistent.
- bb CLI
- curl
5. Watch the run live
Every Browserbase session has a Live View URL. Grab it once the agent creates the session — from your own code with the Browserbase SDK, from the sandbox with thebb CLI, or directly with curl.
- Browserbase SDK
- bb CLI
- curl
Ending the session
Managed Agents tears down the sandbox when the run finishes. Browserbase sessions don’t end automatically — close them explicitly or rely on the session timeout.- Browserbase SDK
- bb CLI
- curl
Troubleshooting
The agent keeps using web_search instead of the browser.
The agent keeps using web_search instead of the browser.
Disable
web_search and web_fetch in the agent_toolset_20260401 configs. Without them, Claude has to use the Browse CLI.Snapshots blow past the context window.
Snapshots blow past the context window.
Pipe every snapshot through
head -200. Tell Claude in the system prompt to prefer screenshot over snapshot and only fall back to snapshots when it needs a ref ID to click.`browse --connect <sessionId>` fails with an auth error.
`browse --connect <sessionId>` fails with an auth error.
Every browse invocation needs
BROWSERBASE_API_KEY in the environment. Prefix each command: BROWSERBASE_API_KEY=$KEY browse --json --connect $SID open https://....The run times out before the agent finishes.
The run times out before the agent finishes.
Managed Agents has a default dispatch timeout. For long tasks, split work across multiple dispatches and pass prior
tool_use_id references so Claude picks up where it left off.How do I reuse a browser across dispatches?
How do I reuse a browser across dispatches?
Don’t end the Browserbase session between dispatches. Pass the existing
sessionId in the next prompt and Claude reconnects with browse --connect <sessionId>. Cookies and local storage persist because it’s the same browser.Next steps
Browse CLI reference
Every command Claude can issue against a Browserbase session.
Session Live View
Embed real-time browser views in your chat UI.
Contexts
Persist cookies and storage across agent runs.
Agent Identity
Verified browsers, proxies, and auth for agents on the open web.