Live
Preserving Workers Subrequest Context for BYOIP Hostnames Improves Security ConsistencyStateful Web Interaction with Cloudflare Agents SDK's Persistent Browser ToolBigQuery federates external Iceberg catalogs for in‑place analyticsGitHub secret scanning now blocks Anthropic API keys by default and adds Salesforce as a partnerDeploying NVIDIA Compute Stack Across UK Sectors: Implications for EngineersEnforced refresh of GitHub Copilot managed settings and mandatory client version for sandboxAI Factories for Smart City Operations: Architecture, Deployment, and Ops TakeawaysAutomating Amazon Bedrock Private Pricing Grants with Managed EntitlementsPreserving Workers Subrequest Context for BYOIP Hostnames Improves Security ConsistencyStateful Web Interaction with Cloudflare Agents SDK's Persistent Browser ToolBigQuery federates external Iceberg catalogs for in‑place analyticsGitHub secret scanning now blocks Anthropic API keys by default and adds Salesforce as a partnerDeploying NVIDIA Compute Stack Across UK Sectors: Implications for EngineersEnforced refresh of GitHub Copilot managed settings and mandatory client version for sandboxAI Factories for Smart City Operations: Architecture, Deployment, and Ops TakeawaysAutomating Amazon Bedrock Private Pricing Grants with Managed Entitlements
Cloudflare

Stateful Web Interaction with Cloudflare Agents SDK's Persistent Browser Tool

AI SummaryPowered by AI

The Agents SDK now includes a persistent browser tool that lets agents keep a Browser Run session alive across turns, preserving tabs, cookies, and login state. This change reduces re‑authentication overhead and introduces new considerations for session handling, resource management, and security isolation.

The Cloudflare Agents SDK now ships with a browserTool that lets an agent launch a Browser Run instance, keep it alive across multiple turns, and return to the same tabs, cookies, and login state. This persistence removes the need to re‑authenticate or reconstruct page context for each interaction, which directly impacts how AI‑driven agents perform web‑based tasks.

New Persistent Browser Capability

When the browserTool is added to an agent’s toolset, the model generates code that drives the browser via the Chrome DevTools Protocol (CDP). Screenshots are emitted as image blobs that image‑capable models can analyse, and the UI can render them directly. The tool is only available with Agents SDK version 0.28.0 or later.

Architectural and Implementation Considerations

Integrating the tool requires three steps:

  • Create a Browser instance backed by browserRun.
  • Register the instance in the object’s Lifecycle.
  • Install the browserTool in a Pi Durable extension registry before opening the harness.

A minimal JavaScript example looks like this:

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 });
    }
  });
}

Because the browser runs as a separate process managed by Browser Run, the agent’s lifecycle code must ensure the process stays alive for the duration of the conversation.

Operational and Security Implications

Persisting a browser session means cookies and authentication tokens remain in memory between turns. Practitioners should treat the browser instance as a stateful credential store and consider the following:

  • Isolation: Ensure the browser process is scoped to a single agent instance to avoid cross‑agent data leakage.
  • Session expiry: Monitor the lifetime of cookies; long‑lived sessions may outlive the intended use case.
  • Resource usage: A live browser consumes CPU and memory; plan capacity accordingly, especially under high concurrency.
  • Observability: Capture CDP logs and screenshot metadata to aid debugging and audit trails.

From a DevOps perspective, the new tool adds a dependency on the Browser Run service and the specific SDK version. Deployment pipelines should pin the SDK at ≥ 0.28.0 and verify that the runtime environment provides the required BROWSER and LOADER bindings.

Related CloudNinjas coverage: hands-on guides.

What This Means For Practitioners

Agents that need to interact with web pages can now maintain context without re‑login, simplifying workflows such as form filling, data extraction, or multi‑step navigation. Teams should audit existing agents for opportunities to replace ad‑hoc HTTP calls with the persistent browser, update SDK versions, and incorporate session‑management checks into their security reviews. Monitoring resource consumption and ensuring proper isolation will be key to scaling this capability safely.

Originally published atCloudflare Developer Platform