BLOG
The Browser Session API for Persistent Profiles and Live Debugging
Learn how the browser session API manages persistent profiles, live debugging, and CDP access for AI web agents in production.
When an AI agent needs to log into a dashboard, maintain state across a multi-hour workflow, and recover from failures without starting over, the browser session API is the layer that makes it possible. Session state — cookies, local storage, IndexedDB, WebSocket connections — is what separates a script that reloads a page from an agent that actually operates software. Remote Browser exposes a browser session API built for persistent profiles and live debugging, so you can run browser-use-style agents without assembling your own Chromium infrastructure.
If you have been evaluating browser-use alternatives or trying to move a web agent browser from a laptop into production, the session layer is usually where things break. Local Chromium works until the machine reboots, the network drops, or a second agent needs the same profile. This post explains what a browser session API is, why persistent profiles matter, and how live debugging via the Chrome DevTools Protocol (CDP) keeps agents observable in production.
Why the Browser Session API Matters for AI Agents
AI agents do not fetch pages one at a time. They navigate multi-step workflows: log in with credentials, wait for async tables to render, extract data, fill forms, dismiss modals, and confirm mutations. Every step depends on state carried over from the previous one. In a local automation script, that state lives in the memory of a long-running Chromium process. If the process dies, the state dies with it.
A browser session API treats browser state as a resumable resource, decoupled from any single process. The session has an identity, a profile, and a CDP endpoint. Reconnect to the same session hours later and the cookies are still there, the WebSocket is still registered, and the page is still mounted. For AI agents that think for a long time between actions, that durability is not a convenience — it is a requirement. Browser-use itself is a prominent open-source library for AI web agents, but the runtime beneath it determines whether those agents survive in production.
What a Browser Session API Should Provide
Not every "session" API on the market is the same. The useful ones share a few concrete capabilities.
Session Lifecycle Management
The API should let you create a session, retrieve its connection details, and shut it down deterministically. That includes handling idle timeouts and usage controls so a stuck agent does not hold a browser open indefinitely. Auto-expiry guard-rails are critical when agents are unattended.
Persistent Profiles
A persistent profile is the browser's user-data directory — cookies, localStorage, IndexedDB, site permissions, and extensions — stored as a named resource. You can attach the same profile to a new session after the old one is gone. This is how an agent resumes a logged-in state without re-authenticating.
Live Debugging via CDP
The session should expose a WebSocket endpoint that speaks the standard Chrome DevTools Protocol. That enables live debugging with any CDP-compatible tool: Playwright, Puppeteer, Selenium, or a custom client. You should be able to watch the page render in real time, inspect the DOM, and evaluate JavaScript in the page context while the agent is running.
Library Compatibility
A browser session API is only useful if your existing tooling can connect to it. Remote Browser sessions are compatible with Playwright, Puppeteer, and Selenium, which means you can keep your existing agent code and swap the browser connection. You do not need a custom SDK to talk to the session — just a CDP URL.
Persistent Sessions vs. Ephemeral Browsers
Ephemeral browsers are fine for stateless scraping. The agent loads a URL, extracts what it needs, and tears everything down. But many AI agent workloads are stateful by nature:
| Scenario | Ephemeral browser | Persistent session |
|---|---|---|
| Logged-in SaaS dashboard | Re-authenticate every run | Profile keeps the login |
| Long-running background agent | Process death loses everything | Session survives reconnects |
| Multi-step checkout flow | Risk of state loss mid-flow | State intact across steps |
| Human handoff for debugging | Hard to attach after the fact | Live viewer and CDP access |
| Concurrent workers sharing a profile | Not possible | Isolated sessions, named profiles |
The distinction changes how you design agents. With a persistent session, you can split a workflow across multiple processes: one agent plans, pauses, and a second agent resumes the same session with the same logged-in context. That is the architecture behind many browser-use cloud browser deployments.
Live Debugging: CDP and the Live Viewer
The hardest part of running AI agents is not writing the prompt — it is seeing what the browser actually did. Remote Browser sessions expose a live viewer plus a raw CDP endpoint so you can step through the agent's actions in real time.
Connecting from TypeScript with Playwright looks like this:
import { chromium } from 'playwright';
// Connect to a Remote Browser session over CDP
const browser = await chromium.connectOverCDP(
'wss://remote-browser.dev/cdp/session_abc123'
);
// Reuse the existing context so the profile persists
const defaultContext = browser.contexts()[0];
const page = defaultContext.pages()[0] ?? (await defaultContext.newPage());
// The session is already authenticated from the persistent profile
await page.goto('https://app.example.com/dashboard');
const rows = await page.locator('table tbody tr').count();
console.log(`Found ${rows} rows in the dashboard`);
await browser.close();The key point: connectOverCDP does not launch a new browser. It attaches to an existing session. If the agent was mid-workflow, the page state — including modals, network requests, and in-memory JavaScript — is still there. Playwright's documentation on `connectOverCDP` covers the protocol-level details.
Live debugging also means you can open the live viewer while the agent runs, watch the cursor move, and manually intervene if it goes off the rails. That observability is what makes browser-use production workloads audit-ready rather than a black box.
Browser Session API vs. Local Chromium
Teams often start with a local Chromium process and add orchestration later. That works for development, but the operational differences show up fast:
| Concern | Local Chromium | Browser session API on Remote Browser |
|---|---|---|
| State persistence | Tied to process lifetime | Named persistent profiles |
| Debugging | Local DevTools only | Live viewer + CDP access |
| Scaling | One browser per machine | Hosted sessions per workload |
| Isolation | Manual profile management | Session isolation built in |
| Network constraints | Local IP, local proxies | Configurable proxy and browser settings |
| Monitoring | DIY | Usage controls and session status |
The hosted approach is not about avoiding a local install. It is about making the browser a shareable, observable infrastructure component. When your agent runs in a container, a serverless function, or a CI job, it cannot rely on a Chrome process that lives elsewhere. The browser session API moves that dependency into the network, where the agent can reach it from anywhere. This is the same argument we made in remote browsers for AI agents — the runtime layer is the missing piece.
Browser-Use Compatibility in Production
Browser-use is the most widely adopted open-source library for AI web automation, and many teams building browser-use alternatives start there. The library handles the agent loop — perception, reasoning, action — while the browser handles the actual execution. In development, browser-use launches a local Chromium instance. In production, that local instance becomes a bottleneck: it is tied to one machine, hard to monitor, and impossible to share across a team.
The browser session API is the production runtime behind that loop. Instead of letting browser-use spin up a fresh browser, you point it at an existing session URL. That gives you:
- Durable state — sessions outlive the agent process.
- Observability — watch the agent's actions in the live viewer.
- Team collaboration — multiple developers can attach to the same session to debug a failure.
- Clean shutdown — terminate the browser without leaving orphan processes.
The practical difference between a remote browser online and a session API is exactly this: an online browser is a tool you use, while a session API is infrastructure you build on. If you are building a hosted agent product, the session API is the better fit because it gives you programmatic control over state, isolation, and access.
Putting the Session API to Work
If you are moving from a local setup to hosted sessions, the migration path is short:
- Create a session with a named profile attached. The profile holds the authentication state your agent needs.
- Connect from your agent. Use Playwright, Puppeteer, or Selenium over the CDP endpoint.
- Debug in real time. Open the live viewer or attach your own DevTools tooling while the agent runs.
- Reuse the profile. If the session terminates, create a new one with the same profile; login state persists.
For teams running multiple agents, session isolation matters as much as persistence. Each session can have its own profile, its own proxy settings, and its own usage limits, so one noisy workload cannot degrade another. The session API also supports configurable browser settings — viewport, locale, timezone, and related options — that you can pin per session for reproducibility.
Before you scale, check the [current pricing and limits