How Sessions Work
Named Sessions
Use the-s flag to create and reuse named sessions:
Dormant Session Lifecycle
1
Park
When a client disconnects, the server parks the session. All state is preserved: browser instance, browser contexts, open pages, page-to-context mappings, element registries, frame contexts, and session approvals.The server also snapshots
context.storageState() for crash recovery (best-effort, non-blocking).2
TTL countdown
A dormant session has a configurable TTL (default: 300 seconds / 5 minutes). If no client
reconnects within the TTL, the session expires and all resources are cleaned up.
3
Restore
When a client connects with a matching
sessionId, the server checks if the parked browser is
still alive. If so, all state is transferred to the new client connection. If the browser crashed
during dormancy, the server starts fresh.4
Expire
After TTL, dormant sessions are destroyed. Owned browsers are closed. CDP-attached (borrowed) browsers have their reference dropped without closing the external browser process.
What Gets Preserved
Ghost Page Filtering
When a dormant session is restored, some pages may come back asabout:blank if the browser discarded them during dormancy. BAP filters these out automatically — any page with url === "about:blank" is treated as non-existent, and ensureReady() creates a fresh page.
MCP vs CLI Sessions
MCP clients get the current destroy-on-disconnect behavior. Session persistence is a CLI-specific feature designed for agents that make multiple sequential shell commands.