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

Cloudflare Agents SDK v0.33.0:升级 Pi 1.5

Agents - Agents SDK now supports Pi 1.5 with fewer storage writes and lower memory use

原文
发到 X
推荐理由

涉及核心 Agent 框架的破坏性变更与 API 弃用,使用 Cloudflare Agents 构建应用的开发者必须立即检查 session.events() 调用及重试逻辑,并注意数据版本不兼容导致的回滚风险。

Agents SDK v0.33.0 upgrades PiHarness to Pi 1.5 ↗︎. The release reduces storage transactions while streaming, improves throughput across many sessions, and reduces memory use when streaming large tool calls.

Agents SDK v0.33.0 将 PiHarness 升级至 Pi 1.5 ↗︎。此次发布减少了流式传输过程中的存储事务,提升了多会话的吞吐量,并降低了流式传输大型工具调用时的内存占用。

Performance improvements

性能改进

  • Far fewer storage writes while streaming. Pi stores streamed answers and tool output in batches, within a second of each update, instead of on every update. Over SQLite, this cuts storage transactions by about 27x for long answers and 5.7x for turns with parallel tools, and CPU by about a quarter.
  • Higher throughput across many sessions. Pi's scheduler no longer rechecks every conversation on each commit. In a SQLite benchmark with 2,048 sessions, one Pi harness went from 88 to 459 agent runs per second.
  • Less memory on large answers. Streaming a 500 KB tool call used to take about 20 seconds of CPU and a 100 MB heap. Pi now appends new text instead of copying it on every update.
  • 流式传输期间的存储写入大幅减少。Pi 以批处理方式存储流式答案和工具输出,在每个更新后的一秒内完成,而不是每次更新都立即写入。在 SQLite 上,这使得长答案的存储事务减少了约 27 倍,并行工具调用的轮次减少了约 5.7 倍,CPU 使用量减少了约四分之一。
  • 多会话吞吐量提升。Pi 的调度器不再在每次提交时重新检查每个对话。在包含 2,048 个会话的 SQLite 基准测试中,一个 Pi harness 每秒代理运行次数从 88 次提升至 459 次。
  • 大型答案的内存占用更低。流式传输 500 KB 的工具调用以前需要约 20 秒的 CPU 时间和 100 MB 堆内存。现在 Pi 采用追加新文本的方式,而不是在每次更新时复制文本。

Streaming updates remain visible immediately, but are persisted in batches. With the default settings, a crash can lose up to about one second of streamed progress. Refer to Recovery to configure this interval.

流式更新保持即时可见,但以批处理形式持久化。使用默认设置时,崩溃可能导致最多约一秒的流式进度丢失。请参阅 Recovery 部分配置此间隔。

Session and tool updates

会话和工具更新

  • A view of each session. session.watch() replaces session.events(). It returns the newest transcript entries and the session's live state, such as the answer being streamed, running tools, and why the last run ended without an answer.
  • Continue without adding a message. The new session.continue() API starts a new run using the existing transcript, for example after a model error or when a run reaches its turn limit.
  • Turn limit. defaults.maxTurns caps the tool rounds a run can take in new sessions.
  • Tasks that keep crashing end. Pi now ends a task cut off by its restart limit instead of parking it. retry() and the parked status are removed.
  • Browser in Pi's code mode. Scripts in Pi's code mode can call browserTool and pass its screenshots to image(). browserTool also stops when the harness aborts its call.
  • 每个会话的视图。session.watch() 取代了 session.events()。它返回最新的转录条目以及会话的实时状态,例如正在流式传输的答案、正在运行的工具,以及上次运行未产生答案的原因。
  • 无需添加消息即可继续。新的 session.continue() API 使用现有转录启动新运行,例如在模型错误发生后或当运行达到轮次限制时。
  • 轮次限制。defaults.maxTurns 限制了新会话中运行可进行的工具轮次上限。
  • 持续崩溃的任务结束。Pi 现在会终止被重启限制截断的任务,而不是将其挂起。retry() 方法和 parked 状态已被移除。
  • Pi 代码模式中的浏览器功能。Pi 代码模式中的脚本可以调用 browserTool,并将其截图传递给 image()。当 harness 中止调用时,browserTool 也会停止。

Continue an unanswered conversation

继续未回答的对话

For an existing session and submission operationId, check the result before offering a continuation. For example, after resolving a model error:

对于现有的会话和提交操作 operationId,在提供续传之前检查结果。例如,在解决模型错误后:

代码 · 8 行
const result = await session.wait(operationId);
if (result.status === "unanswered" && result.reason === "model_error") {
	const receipt = await session.continue({
		operationId: `${operationId}:continue`,
	});
	const continued = await session.wait(receipt.operationId);
	console.log(continued.status, continued.text);
}
代码 · 8 行
const result = await session.wait(operationId);
if (result.status === "unanswered" && result.reason === "model_error") {
	const receipt = await session.continue({
		operationId: `${operationId}:continue`,
	});
	const continued = await session.wait(receipt.operationId);
	console.log(continued.status, continued.text);
}

This starts a new run without appending a user message. The session must be idle. If the transcript already ends in an answer, the operation returns unanswered with reason nothing_to_answer. Refer to Work with sessions.

这将启动一个新运行,而不会追加用户消息。会话必须处于空闲状态。如果转录已经以答案结尾,该操作将返回 unanswered,原因为 nothing_to_answer。请参阅 Work with sessions。

Upgrade

升级

Once a conversation runs on Pi 1.5, Pi 1.4 cannot read it. After upgrading, roll forward to fix deployment issues rather than rolling back to Pi 1.4.

一旦对话在 Pi 1.5 上运行,Pi 1.4 就无法读取它。升级后,请向前滚动以修复部署问题,而不是回滚到 Pi 1.4。

Update callers of session.events() to use session.watch(), and remove uses of retry() and the parked status. Refer to the Pi Durable 1.5.0 changelog ↗︎ for the full list of breaking changes.

更新 session.events() 的调用方以使用 session.watch(),并移除 retry() 和 parked 状态的用法。请参阅 Pi Durable 1.5.0 变更日志 ↗︎ 以获取所有破坏性更改的完整列表。

The Agents SDK v0.33.0 changelog ↗︎ has step-by-step upgrade instructions. Point your coding agent at them and upgrade today:

Agents SDK v0.33.0 变更日志 ↗︎ 提供了逐步升级说明。将你的编码代理指向这些说明,并立即进行升级:

Copy promptPrompt copied!

复制 promptPrompt 已复制!

更进一步:量化金融体系

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

进入量化体系 →

相似阅读

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