最新资讯
dev.to 你的 Agent Harness 应具备的 17 项能力 dev.to 离线 AI 记忆中 0.8 余弦阈值为何失效 dev.to Kimi K3.1 Pro 开放权重:自托管 2.8T 模型前的开发者清单 dev.to 如何通过工具调用引导模型以提升 Harness 质量 dev.to AI Agent 审计轨迹不等于对话记录 dev.to 精简 MCP server 工具数量:更少工具、更小影响面,双重收益 dev.to 为什么 git checkout 无法撤销 AI 编码 agent 的改动? wechat AI短剧门槛降降降!实测即梦短剧工作室:剧本分镜预演一条龙,伙伴计划长期护航 dev.to 让模型改写文档前,先量化事实保真度 dev.to 回放 153 个 Claude Code 与 Codex 会话,审计 Agent 的生产影响范围 dev.to 银行 77 意图分类最便宜 LLM:GPT-6.1 Terra 每次成功任务 $0.000727 theinformation.com Chesky的副业:Airbnb向CEO新设AI实验室出售IP
多元动态
登录 注册
智能体 developers.cloudflare.com · @Cloudflare Developers

Cloudflare Agents SDK 新增持久化浏览器工具 browserTool

原文 我的收藏

Cloudflare Agents SDK 推出 browserTool,为 Agent 提供可跨轮次复用的 Browser Run 浏览器,标签页、Cookie 和登录会话在会话存活期间保持。模型通过 Chrome DevTools Protocol 编写代码驱动浏览器,截图以图像形式返回供多模态模型检查。需 Agents SDK v0.28.0 及以上,通过 Browser 注册到 Lifecycle 并加入 Pi Durable 扩展注册表。每个 Pi 对话默认独立标签页,Cookie 与登录态在浏览器内共享;浏览器在 Durable Object 休眠时仍存活,默认空闲超时 10 分钟,会话过期或崩溃会新建浏览器并返回 restarted: true,旧标签与登录态丢失。也可配合 AI SDK 和 TanStack AI 适配器使用。

AI推荐理由 Cloudflare Agents SDK 官方 changelog 发布 browserTool,明确给出 v0.28.0 版本要求、代码示例和会话行为细节(默认 10 分钟空闲超时、崩溃后 restarted: true 且旧标签与登录态丢失),属于可验证的开发者工具更新,对构建持久化浏览器 Agent 有直接参考价值;局限是仅覆盖 Cloudflare 自家 Agents SDK 与 Browser Run 生态,且未提供实际效果或性能数据。

82

正文

The [Cloudflare Agents SDK](https://developers.cloudflare.com/agents/) now provides a `browserTool` that gives your agent a [Browser Run](https://developers.cloudflare.com/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)](https://developers.cloudflare.com/browser-run/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 ↗︎](https://github.com/cloudflare/agents/releases/tag/agents%400.28.0) or greater installed. Create a `Browser`, register it with your object's [Lifecycle](https://developers.cloudflare.com/agents/runtime/lifecycle/), and add the tool to a [Pi Durable](https://developers.cloudflare.com/agents/harnesses/pi/) [extension registry](https://developers.cloudflare.com/agents/harnesses/pi/extensions/) 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 { // ... 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](https://developers.cloudflare.com/agents/tools/browser/#return-to-the-same-browser) for the complete Pi Durable example, required bindings, and behavior when a tool call is interrupted.

来源报道 · 1 篇 · 以下链接均前往原始媒体

Cloudflare Developers Cloudflare Agents SDK 新增持久化浏览器工具 browserTool 10-13 · 原文发布
← 返回精选动态 原文

更多内容