跳到主内容
@wquguru
精选80Cloudflare Agents SDK(Changelog)AI 编程与模型

Cloudflare Agents SDK v0.28.0 新增持久化浏览器工具

Agents - New persistent browser tool in the Agents SDK, with tabs and logins that last between turns

原文
发到 X
推荐理由

AI 开发者注意:Cloudflare Agents SDK 新增持久化浏览器工具,让 Agent 能跨轮次保留标签页和登录态,显著扩展了 Agent 能力。升级到 v0.28.0 并参照示例配置即可启用。

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.

Cloudflare Agents SDK 现在提供了一个 browserTool,它能为你的代理提供一个 Browser Run 浏览器,代理可以在后续轮次中返回该浏览器。你的代理可以打开网站、检查页面,并在浏览器会话保持存活期间,带着其标签页、Cookie 和登录会话完好地返回。

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.

当你将 browserTool 交给代理时,模型会编写代码,通过 Chrome DevTools 协议(CDP)驱动浏览器。截图会作为图像返回,支持图像的模型可以检查这些图像,你的 UI 也可以显示它们。

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:

要使用 browserTool,请确保你安装了 Agents SDK v0.28.0 ↗︎ 或更高版本。创建一个 Browser,将其注册到你的对象的 Lifecycle 中,并在打开 harness 之前将该工具添加到 Pi Durable 扩展注册表中:

代码 · 27 行
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);
}
代码 · 27 行
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.

每个 Pi 对话默认拥有自己的活动标签页。Cookie 和登录状态在浏览器内保持共享。

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.

浏览器在轮次之间保持存活,包括当 Durable Object 休眠时。其默认空闲超时时间为 10 分钟。如果会话过期或崩溃,该工具会创建一个全新的浏览器,并报告 restarted: true。旧的标签页和登录状态将丢失。

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.

你还可以将持久化浏览器与 AI SDK 和 TanStack AI 适配器一起使用,或者通过公共 Browser 和 CDP API 连接另一个 harness。

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

有关完整的 Pi Durable 示例、所需的绑定以及工具调用被中断时的行为,请参阅持久化浏览器工具。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件