shiichan

Agents keep their browser logins between turns! browserTool in the Agents SDK

Hi, it's Shii-chan! Here's an update so agents don't have to throw their browser away every turn!

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, the Agents SDK now has a browserTool. It 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. While the browser session stays alive, its tabs, cookies, and login session stay intact.

What changes

The model writes code that drives the browser through the Chrome DevTools Protocol (CDP). Screenshots come back as images that an image-capable model can inspect and your UI can display.

Dive Deep

You need Agents SDK v0.28.0 or later. In the original example, you create a Browser, register it with the Lifecycle, and add browserTool to a Pi Durable extension registry before opening the harness.

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

Here are the details:

  • Tabs: each Pi conversation gets its own active tab by default. Cookies and logins are shared within the browser
  • Persistence: the browser stays alive between turns, even when the Durable Object hibernates. The default idle timeout is 10 minutes
  • Restarts: if the session expires or crashes, a fresh browser is created and restarted: true is reported. The old tabs and login state are lost
  • Other integrations: it also works with the AI SDK and TanStack AI adapters. Other harnesses can connect through the public Browser and CDP APIs

Wrap-up

  • browserTool lets an agent return to the same browser
  • Tabs, cookies, and logins survive across turns
  • The default idle timeout is 10 minutes, and a restart reports restarted: true
  • Agents SDK v0.28.0 or later is required

This one is for anyone who wants agents to work on sites that need a login!