BLOG
Agentic Browser: What It Is and How to Run One in Production
An agentic browser lets an AI agent perceive and act on real web pages. Learn the architecture, runtime requirements, and how to run one on hosted Chromium.

An agentic browser is a real browser instance that an AI agent controls through a programmatic interface — typically the Chrome DevTools Protocol (CDP) — so the agent can observe page state, decide on an action, and execute it in a loop until a task is complete. It is not a new browser engine and not a wrapper around a search API. It is Chromium plus a control surface plus a runtime that keeps the session alive, isolated, and observable while a model drives it.
That distinction matters because most "agentic browser" failures in production are not model failures. They are runtime failures: sessions that die mid-task, profiles that leak cookies between tenants, no way to watch what the agent did, and no way to reproduce a bad run. This guide covers what an agentic browser actually is, how the perception-action loop maps onto CDP, what to evaluate before you ship, and how to wire one up with Playwright against a hosted runtime.
What makes a browser "agentic"
A conventional browser automation script is deterministic. You write page.click('#submit') and it runs once. An agentic browser inverts control: the model receives a representation of the page, chooses an action from a constrained set, and the runtime executes it. The loop repeats until the agent declares success or hits a step budget.
Three properties separate an agentic browser from a scripted one:
- Observation is model-facing. The agent needs page state in a form it can reason about — accessibility trees, DOM snapshots, screenshots, or extracted text. Raw HTML is usually too noisy; the accessibility tree is the common default because it is structured and relatively stable across layout changes.
- Actions are grounded in live state. The agent must act on element references that still exist. A stale selector from three steps ago is the most common source of agent errors, so the runtime needs to re-resolve targets against the current DOM on every step.
- The loop is stateful. Cookies, localStorage, navigation history, and open tabs persist across steps. If the browser restarts between steps, the agent loses context and the task fails.
An agentic browser is therefore closer to a long-lived session than to a request. That single fact drives most of the infrastructure decisions below.
The perception-action loop over CDP
CDP is the wire protocol Chromium exposes for external control. It is organized into domains — Page, DOM, Runtime, Network, Target — and every agentic browser ultimately speaks it, whether directly or through a library.
A typical step looks like this:
- Observe. The runtime calls
Page.captureSnapshotorAccessibility.getFullAXTreeand serializes the result into the model's context. - Decide. The model returns a structured action:
click(elementRef),type(elementRef, text),navigate(url),scroll(direction). - Act. The runtime resolves the element reference to a live node and dispatches the input via
Input.dispatchMouseEventorInput.dispatchKeyEvent. - Wait. The runtime waits for network idle or a specific DOM condition before the next observation, otherwise the agent reads a half-rendered page.
Playwright and Puppeteer wrap this protocol with higher-level APIs, and most agent frameworks sit on top of one of them. The important architectural point is that the agent framework and the browser runtime are separable. You can run browser-use, Stagehand, or a custom loop against any CDP endpoint — local Chrome, a container you manage, or a hosted session. See the Playwright CDP documentation for the connection semantics.
Local Chrome vs. a hosted agentic browser runtime
The first production decision is where the browser runs. Both options are viable; they fail in different ways.
| Criterion | Local Chrome / self-managed container | Hosted agentic browser runtime |
|---|---|---|
| Setup time | Install, pin versions, manage drivers | One API call returns a CDP endpoint |
| Session lifetime | Tied to the process or container | Survives worker restarts; reconnectable |
| Isolation | You build it (containers, profiles, namespaces) | Per-session isolation by default |
| Observability | Add your own screencast and logging | Live viewer, recordings, session metadata |
| Scaling | Provision and drain your own fleet | Concurrency managed by the provider |
| Debugging a failed run | Reproduce locally, hope it recurs | Reattach to the live or recorded session |
| Cost model | Compute + engineering time | Metered per browser-hour; see /pricing |
Local Chrome is the right choice for development and for short, single-tenant tasks. It becomes expensive the moment you need concurrency, tenant isolation, or post-hoc debugging — not because the browser is hard, but because the surrounding runtime is.
A hosted runtime is not a different browser. It is the same Chromium, exposed over CDP, with the operational concerns handled. The trade-off is that you inherit the provider's session lifecycle and pricing model, so you need to understand both before committing.
Production criteria for an agentic browser
Before choosing a runtime, evaluate it against the failure modes that actually show up in production.
Session persistence and reconnection
Agents run for minutes, sometimes hours. A worker restart, a deploy, or a network blip should not kill the task. The runtime should let you reconnect to an existing session by ID and resume from the current page state. Persistent profiles — saved cookies and storage — matter for any workflow that involves authenticated sessions.
Isolation between sessions and tenants
If you run agents for multiple customers, a shared browser profile is a data breach waiting to happen. Each session should have its own profile, its own cookie jar, and its own network context. Verify this rather than assuming it.
Observability
You need to answer "what did the agent see and do at step 14?" A live viewer lets a human watch and intervene. Recordings let you replay a failed run. Structured logs of each action and observation let you diff a good run against a bad one. Without these, debugging an agent is guesswork.
Network controls
Many real tasks require geo-appropriate IPs or configurable browser settings for proxy routing. Check what the runtime exposes — proxy configuration, custom headers, and browser launch flags — and whether those settings are per-session or global.
Usage controls
Concurrency limits, step budgets, and per-session timeouts are your primary defense against a runaway agent burning budget. Confirm how the runtime meters usage and where you can enforce caps. Current rates and limits are on the /pricing page.
Wiring an agentic browser with Playwright over CDP
The following TypeScript example connects Playwright to a hosted Chromium session over CDP, runs a minimal observe-act loop, and cleans up. It assumes your runtime returns a WebSocket debugger URL when a session is created.
import { chromium, type Page } from "playwright";
type Session = { id: string; cdpUrl: string };
// Your runtime's session-creation endpoint returns a CDP WebSocket URL.
async function createSession(): Promise<Session> {
const res = await fetch(`${process.env.BROWSER_API}/sessions`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${process.env.BROWSER_API_KEY}`,
},
body: JSON.stringify({ profile: "checkout-agent", timeoutSeconds: 900 }),
});
if (!res.ok) throw new Error(`session create failed: ${res.status}`);
return res.json();
}
async function observe(page: Page): Promise<string> {
// Accessibility tree is a stable, model-friendly representation.
const snapshot = await page.accessibility.snapshot({ interestingOnly: true });
return JSON.stringify(snapshot);
}
async function act(page: Page, action: { kind: string; selector?: string; text?: string }) {
switch (action.kind) {
case "click":
await page.locator(action.selector!).click({ timeout: 10_000 });
break;
case "type":
await page.locator(action.selector!).fill(action.text ?? "");
break;
case "navigate":
await page.goto(action.text!, { waitUntil: "domcontentloaded" });
break;
default:
throw new Error(`unknown action: ${action.kind}`);
}
// Wait for the page to settle before the next observation.
await page.waitForLoadState("networkidle", { timeout: 15_000 }).catch(() => {});
}
async function run() {
const session = await createSession();
const browser = await chromium.connectOverCDP(session.cdpUrl);
const context = browser.contexts()[0] ?? (await browser.newContext());
const page = context.pages()[0] ?? (await context.newPage());
try {
await page.goto("https://example.com", { waitUntil: "domcontentloaded" });
for (let step = 0; step < 20; step++) {
const state = await observe(page);
const action = await decideNextAction(state); // your model call
if (action.kind === "done") break;
await act(page, action);
}
} finally {
// Disconnect the client; the hosted session ends on its own timeout
// or via an explicit stop call to your runtime.
await browser.close();
}
}Two details are easy to get wrong. First, connectOverCDP attaches to an existing browser rather than launching one, so browser.close() disconnects your client — it does not necessarily terminate the remote session. Stop the session explicitly through your runtime's API when the task is done, or you will pay for idle time. Second, the waitForLoadState call is a heuristic. For SPAs that render after network idle, wait on a specific selector or a custom predicate instead.
For a broader walkthrough of the runtime layer, see Remote browsers for AI agents.
Where agentic browsers fit in an agent stack
An agentic browser is one component in a larger system. A typical production stack looks like this:
- Orchestrator — schedules tasks, enforces budgets, retries failures.
- Model — decides the next action from the observation.
- Agent framework — browser-use, Stagehand, or a custom loop; translates model output into CDP calls.
- Browser runtime — the hosted Chromium session, its profile, network, and lifecycle.
- Observability — recordings, logs, and a live viewer for human review.
Keeping the runtime separate from the framework is what lets you swap models or frameworks without rebuilding your infrastructure. It also means you can test a new model against the same deterministic browser environment, which is the only way to compare agent performance fairly.
If you are evaluating runtimes, the documentation covers session creation, CDP connection, profiles, and the live viewer in detail. For a comparison of running Chromium without local setup, see remote browser online.
Common failure modes and how to avoid them
Stale element references. The agent clicks an element that was re-rendered. Fix: re-resolve selectors on every step and treat element references as valid only for the current observation.
Reading half-loaded pages. The agent observes before the page settles. Fix: wait on a specific condition, not a fixed timeout.
Session death mid-task. The container or process hosting the browser restarts. Fix: use a runtime with reconnection, and persist task state outside the browser.
Profile bleed. Two tasks share cookies. Fix: per-session profiles, verified with a test that checks cookie isolation.
Runaway loops. The agent retries the same failing action indefinitely. Fix: step budgets, repeated-action detection, and a hard session timeout.
No audit trail. A customer disputes what the agent did. Fix: recordings and structured action logs, retained per your data policy.
Conclusion
An agentic browser is Chromium plus a control protocol plus a runtime that keeps sessions alive, isolated, and observable. The model gets the attention, but the runtime determines whether the agent works in production. Start with a local Chrome instance to develop the loop, then move to a hosted runtime when you need concurrency, isolation, reconnection, or a live viewer. Evaluate candidates on session persistence, tenant isolation, observability, network controls, and usage limits — not on benchmark claims. When you are ready to test a hosted session, the documentation and /pricing pages are the place to start.