Cloudflare Kitesurf:为 Agent 而非人类打造的浏览器——它将如何改变 Agentic 网页自动化
💡 工具推荐:做这件事时,用 Evergreen Tools 的 URL 解析器、HTML 转 Markdown、正则测试器 更省心!
Cloudflare 于 2026 年 8 月 7 日发布 Kitesurf,而它的定位比产品本身更值得玩味:这是一款为 AI Agent、而非为人类打造的浏览器。Cloudflare 说它只花了十二周就做了出来,并且完全运行在 Cloudflare Workers 之上。这个卖点刻意做得很朴素。为 Agent 打造的浏览器不需要标签页、主题或扩展,它需要管理上下文窗口、性能、token 成本、可扩展性,以及一个把提示词注入纳入其中的威胁模型。这与「Chrome 替代品」是两种不同的产品,值得理解,因为 Agentic 网页自动化正是 2026 年大量价值的产地。
为 Agent 而生,非为人类
一、抽取优先于渲染
核心设计选择在于它 optimization 的目标。人类需要像素,Agent 需要文本。Cloudflare 表示,在截图与 HTML 抽取这类常见 Agent 任务上,Kitesurf 的 CPU 与内存消耗显著低于 Chromium。代码示例 1 直接从 Worker 驱动它:启动会话、打开页面、取 HTML 内容、关闭。注意这段代码里「缺」了什么:没有渲染循环、没有视口、没有需要等待的人类界面。其余一切都跑在 Cloudflare Workers 里,这使它像无状态一样易于扩展,而一个长寿命的无头 Chromium 实例永远做不到。
// 1. Drive Kitesurf from Workers — extraction, not screenshots
// Kitesurf runs entirely on Cloudflare Workers and is free in beta
// inside Browser Run. Ask for structured text, not a pixel buffer.
export default {
async fetch(req, env) {
const session = await env.BROWSER_RUN.launch({ engine: "kitesurf" });
const page = await session.open("https://example.com/pricing");
const html = await page.content(); // cheaper than rendering pixels
await session.close();
return new Response(html, { headers: { "content-type": "text/html" } });
},
};
// Cloudflare says Kitesurf uses significantly less CPU and memory than
// Chromium for common agentic tasks like screenshots and HTML extraction.二、保护上下文窗口
Agentic 浏览最昂贵的错误,是把网页当作免费的。一个带脚本、导航、广告与页脚的现代页面,单靠自己就能撑爆模型的上下文预算。Cloudflare 明确表示 Kitesurf 被设计来帮助管理上下文窗口与 token 成本,而代码示例 2 就是与之配套的纪律:把 HTML 转成 Markdown、剥掉脚本与样板、保留表格,并在页面进入模型之前截断。代码示例 5 把同一个思路推进到配置层:限制每任务页面数、字节数,以及 token 与美元预算。截图应当是例外,而非默认。
// 2. Shrink the page before it eats your context window
import { htmlToMarkdown } from "./html-to-markdown";
import { countTokens } from "./tokens";
const MAX_TOKENS = 8_000;
export async function toAgentInput(html: string) {
const md = htmlToMarkdown(html, {
stripScripts: true, // remove <script>, <style>, comments
stripNav: true, // drop boilerplate menus and footers
keepTables: true, // keep pricing tables and specs
});
const tokens = countTokens(md);
return tokens <= MAX_TOKENS
? md
: md.slice(0, MAX_TOKENS * 4) + "\n... [truncated]";
}
// A browser built for agents needs to manage context windows and token
// cost, not tabs and themes. Shrinking early is the cheapest win.三、威胁模型是提示词注入
Cloudflare 直言,AI 浏览器面对的是不同的威胁模型,并特别点名提示词注入。当 Agent 读取一个页面时,那个页面就是由可能并不关心你利益的人写下的不可信输入。代码示例 3 把抓取到的内容当作数据、绝不当作指令:它扫描常见的注入模式,更重要的是,把文本包裹在一个不可信内容边界里,让模型知道自己是在「阅读」,而不是在「服从」。仅这一个习惯,就能防住最常见的 Agentic 网页失败——评论或页脚里的一条隐藏指令,劫持了 Agent 的目标。
// 3. Treat page content as untrusted data, never as instructions
// A browser for agents has a different threat model: prompt injection.
const INJECTION = [
/ignore (all )?(previous|above) instructions/i,
/you are now/i,
/disregard .* and (send|transfer|delete)/i,
/<!--[\s\S]*?(system|assistant)[\s\S]*?-->/i,
];
export function sanitizePageText(text: string) {
for (const pattern of INJECTION) {
if (pattern.test(text)) {
throw new Error("Possible prompt injection in fetched page");
}
}
// Wrap untrusted content so the model treats it as data, not orders.
return `<untrusted_page_content>\n${text}\n</untrusted_page_content>`;
}四、隔离,让失败止步于本地
由于 Kitesurf 使用 isolates 运行在 Cloudflare Workers 上,页面之间彼此隔离。Cloudflare 所述的设计确保:若 Agent 在某个页面上访问了恶意源,它无法污染同一任务中的其他浏览器页面。代码示例 4 顺应这一模型:每个 URL 一个会话、每页超时、用 try/catch 隔离单点失败而非中止整轮研究,并用 finally 块始终拆掉会话。跨多个来源的并行研究之所以安全,正是因为任意两个页面不共享状态。
// 4. One page per isolate — no cross-page leakage
// Cloudflare designed Kitesurf with isolation per page, so an agent
// hitting a malicious source on one page cannot corrupt others.
export async function research(urls: string[], env) {
const results = await Promise.all(
urls.map(async (url) => {
const session = await env.BROWSER_RUN.launch({ engine: "kitesurf" });
try {
const page = await session.open(url, { timeoutMs: 15_000 });
return { url, text: sanitizePageText(await page.toMarkdown()) };
} catch (e) {
return { url, error: String(e) }; // isolate the failure too
} finally {
await session.close(); // always tear the session down
}
}),
);
return results;
}五、像对待其他工具那样为浏览器做预算
Kitesurf 公测免费,这让人容易忽略那句话的后半段:你的上下文窗口、你的延迟、你的用户耐心,从来都不是免费的。代码示例 5 把浏览器纳入你对模型调用所用的同一套预算纪律:限制每任务页面数、每页超时、HTML 大小、输出格式,以及 token 与美元上限。这正是「为 Agent 打造的浏览器」这一前提背后的同一原则:网页自动化如今已是 Agent 的一等能力,而一等能力理应配一等限制。
# 5. Budget the browser so web tasks never run away
# Agent browsing is unbounded by nature; cap it like any other tool.
browser:
engine: kitesurf
max_pages_per_task: 12
timeout_ms: 15000
max_html_bytes: 2_000_000
formats: [markdown, html] # skip screenshots unless truly needed
budget:
tokens_per_task: 60000
usd_per_task: 0.75
# Screenshots cost far more than HTML extraction; request them only
# when a visual decision truly requires pixels. Kitesurf is free in
# beta, but your context window and latency are never free.六、Agent 从中得到了什么
Kitesurf 通过了约 21.5 万项 Web 平台测试,Cloudflare 称每周还在新增数百项,因此这是一款早期但真实的浏览器,而非演示品。它由来自 Blitz 的模块化渲染引擎、Firefox 的 Stylo CSS 解析器与 Boa JS 构建,Cloudflare 也把开源项目 Obscura 引擎列为起点。它为 Agent 开发者提供的,是那个无聊却必要的层:一种无需维护脆弱 Chromium 集群,就能导航、填表与抽取内容的方式。把它与「抽取优先的请求、激进的上下文压缩、注入防御、每页隔离和硬预算」配在一起,网页自动化就不再是你 Agent 栈里最脆弱的那一环。
抽取优先于渲染
把页面当作不可信输入
📌 常见问题 FAQ
Cloudflare Kitesurf 是什么?
一款于 2026 年 8 月 7 日发布的云端浏览器,专为 AI Agent 而非人类设计。它完全运行在 Cloudflare Workers 上,并在 Browser Run 中免费公测。
它与 Chrome 有何不同?
它去掉了人类界面:没有标签页、主题或扩展。它针对上下文窗口、性能、token 成本、可扩展性与提示词注入威胁等 Agent 关切做优化,Cloudflare 称其在截图与 HTML 抽取等任务上的 CPU 与内存消耗显著低于 Chromium。
它由什么构建?
来自 Blitz 的模块化渲染引擎、Firefox 的 Stylo CSS 解析器与 Boa JS(Rust 实现的 ECMAScript 引擎),其余一切运行在 Cloudflare Workers 内。Cloudflare 把开源的无头引擎 Obscura 列为起点。
它可用于生产了吗?
它处于免费公测,Cloudflare 称其通过约 21.5 万多项 Web 平台测试并每周新增数百项。它能渲染 TodoMVC、维基百科、Hacker News 与 Cloudflare 博客等页面,但属于早期阶段而非完成品。
最需要防范的安全风险是什么?
提示词注入。Agent 读取的页面是不可信输入,因此要扫描注入模式,并把抓取到的内容包裹在显式的不可信边界里,让模型把它当作数据而非指令。