This guide sets up a Claude Managed Agent that browses the web through a Browserbase session. You create the agent and environment once, then start as many sessions as you need.Documentation Index
Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- An Anthropic API key — Managed Agents is enabled by default for all API accounts in beta
- 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 sessions.The Anthropic SDK sets the
managed-agents-2026-04-01 beta header automatically. If you’re calling the REST API directly with curl, add -H "anthropic-beta: managed-agents-2026-04-01" to every request.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. Start a session and stream events
A session is one running instance of the agent. You open an SSE stream against the session, send a user message, and process events as they arrive — agent text, tool calls, and a finalsession.status_idle event when Claude is done.
The prompt tells Claude how to create a Browserbase session. You can show it either flavor — the bb CLI or curl straight against the API. Both work; pick whichever you prefer and stay consistent.
- bb CLI
- curl
client.beta.sessions.events.list(session.id).
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
Two sessions to clean up — Anthropic’s and Browserbase’s. Anthropic Managed Agents: archive the session when you’re done. Archiving terminates the container and stops compute billing. Sessions are also deleted after a TTL — see Anthropic’s docs for current values.- 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 session times out before the agent finishes.
The session times out before the agent finishes.
Long-running sessions stay alive — Anthropic only times out compute, not the session itself. If you’re hitting an inactivity timeout, send another
user.message event to wake the agent up. For multi-stage workflows, just keep sending events on the same session ID; the conversation history is preserved server-side.How do I reuse a browser across runs?
How do I reuse a browser across runs?
Don’t end the Browserbase session between user messages. 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. Across separate Anthropic sessions, use Browserbase Contexts to persist cookies and storage.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.