megachangelog
Feature0.28.0

Persistent browser tool in Agents SDK with tabs and logins

The Cloudflare Agents SDK now includes a browserTool that allows agents to maintain a persistent browser session across multiple turns, preserving tabs, cookies, and login sessions. The browser remains alive even when the Durable Object hibernates, with a 10-minute idle timeout before creating a fresh session.

The Cloudflare Agents SDK now provides a browserTool that gives your agent a Browser Run browser it can return to on later turns. Your agent can open a website, inspect a page, and come back to it with its tabs, cookies, and login session intact while the browser session remains alive.

When you give browserTool to your agent, the model writes code that drives the browser through the Chrome DevTools Protocol (CDP). Screenshots return as images that an image-capable model can inspect and your UI can display.

To use browserTool, make sure you have Agents SDK v0.28.0 ↗︎ or greater installed. Create a Browser, register it with your object's Lifecycle, and add the tool to a Pi Durable extension registry before opening the harness:

import { Browser, browserRun } from "agents/browser";
import { browserTool } from "agents/browser/pi";

export class MyAgent extends DurableObject {
	// ...

	browser = new Browser({ provider: browserRun(this.env.BROWSER) });

	harness = new PiHarness({
		harness: async ({ storage, context }) => {
			this.registry.install({
				name: "browser",
				tools: [
					browserTool({
						ctx: this.ctx,
						browser: this.browser,
						loader: this.env.LOADER,
					}),
				],
			});

			// ...

			return Harness.open(
				storage,
				{ models, registry: this.registry },
				context,
			);
		},
	});

	lifecycle = Lifecycle.install(this).use(this.browser).use(this.harness);
}
import { Browser, browserRun } from "agents/browser";
import { browserTool } from "agents/browser/pi";

export class MyAgent extends DurableObject<Env> {
	// ...

	browser = new Browser({ provider: browserRun(this.env.BROWSER) });

	harness = new PiHarness({
		harness: async ({ storage, context }) => {
			this.registry.install({
				name: "browser",
				tools: [
					browserTool({
						ctx: this.ctx,
						browser: this.browser,
						loader: this.env.LOADER,
					}),
				],
			});

			// ...

			return Harness.open(
				storage,
				{ models, registry: this.registry },
				context,
			);
		},
	});

	lifecycle = Lifecycle.install(this).use(this.browser).use(this.harness);
}

Each Pi conversation gets its own active tab by default. Cookies and logins remain shared within the browser.

The browser stays alive between turns, including when the Durable Object hibernates. Its default idle timeout is 10 minutes. If the session expires or crashes, the tool creates a fresh browser and reports restarted: true. The old tabs and login state are gone.

You can also use the persistent browser with the AI SDK and TanStack AI adapters, or connect another harness through the public Browser and CDP APIs.

Refer to persistent browser tools for the complete Pi Durable example, required bindings, and behavior when a tool call is interrupted.

agentsbrowsersdkdurable-objectstools

Source: original entry ↗

More from Cloudflare

Follow Cloudflare to get its new changes in your feed and email digest.

Feature

Cloudflare API MCP server sends Workers Issues as MCP Events

The Cloudflare API MCP server now exposes Workers Issues as MCP Events through webhook subscriptions, allowing agents to receive real-time notifications when production failures are detected without polling. Clients can subscribe to cloudflare.alert.workers_observability_real_time_issue scoped to an account or individual Worker.

workersmcpmonitoringapiobservability
Feature

Web Analytics: Deeper Core Web Vitals Diagnostics with LCP & INP Sub-Part Metrics

Real User Monitoring in Web Analytics now breaks down Largest Contentful Paint (LCP) and Interaction to Next Paint (INP) into their constituent phases, plus splits connection time into TCP and TLS components. These sub-part metrics are available in the dashboard and queryable through the GraphQL Analytics API to help identify which specific area is impacting page performance.

web-analyticsrumcore-web-vitalsperformanceapi
Improvement

Workers subrequests now preserve context for BYOIP destinations

Cloudflare Workers now preserves context when subrequests target BYOIP-proxied hostnames, maintaining CF-Worker headers and client signals. This ensures consistent security rule evaluation and accurate Bot Management results instead of incorrectly treating internal traffic as external.

workersbyoipbot-managementsecuritysubrequests
See all Cloudflare changes →