读见

Workflow SDK 5 现已推出

原题Workflow SDK 5 is now available

约 9 分钟约 2,140 字原文英文

推荐理由Vercel Workflow SDK 5 将端到端加密、区域驻留和增量重放带入持久工作流,降低生产智能体的步骤衔接开销。开发者可据此比较托管与自托管的密钥管理、数据驻留和可靠执行方案。

读前速览

5 个要点

Workflow SDK 5 在保持相同开发者体验的同时,带来端到端加密、区域数据驻留,以及 1.6x-25x 的性能提升。

  1. 端到端加密,且在 Vercel 上无需配置

    所有 Workflow SDK 负载都会在离开代码前,使用 AES-256-GCM 加密,并为每次运行生成唯一密钥。在 Vercel 上,加密无需设置,还可通过客户端在控制台或 CLI 中解密,实现安全的可观测性。

  2. 区域数据驻留提升性能和可靠性

    每次运行都有自己的所属区域,状态、队列和流均由该区域提供服务,从而消除关键路径上的跨区域往返。运行会在触发函数所在的区域启动,步骤则在应用部署所在的位置执行。

  3. 基准测试中的性能提升达 1.6x 至 25x

    减少队列跳转、增量重放和 WebSocket 流式传输显著降低了延迟。步骤间开销从 618ms 降至 109ms,运行后期的开销从 1,748ms 降至 70ms;对于响应时间为 52.4 秒的智能体,流传输时间从 226.1s 降至 53.5s。

  4. 面向智能体的性能优化

    重写后的引擎减少了队列跳转和网络开销,使包含数千个连续事件、高吞吐量 Token 流和工具链的 AI 工作负载能够高效运行,同时保持相同的开发者体验。

  5. 扩展持久化原语生态

    Workflow SDK 的 World 基础层现在支持 fx、durable-harness 和 eve,为多种智能体实现提供持久化能力,包括与 Pi、OpenCode、Claude Code 和 Codex 的集成。

完整摘要

Workflow SDK 5 在安全性、可靠性和性能方面进行了重大升级。SDK 现在使用 AES-256-GCM 对所有负载进行端到端加密,并为每次运行使用唯一密钥,以保护事件日志、步骤输入和输出以及流中的敏感数据。在 Vercel 上,加密无需任何配置,并支持通过客户端解密实现安全的可观测性。自托管的 Worlds 可以自行管理加密密钥。此次更新还引入了区域数据驻留功能,让每次运行都能在所属区域存储状态,避免跨区域往返,从而提升性能和可靠性。基础设施方面的改进包括减少队列跳转、增量重放和 WebSocket 流式传输,在各项基准测试中带来 1.6x 至 25x 的延迟改善。面向智能体的性能优化可满足 AI 工作负载的高吞吐需求,基准测试中的步骤间开销从 618ms 降至 109ms。其他功能还包括运行中取消、可搜索的运行属性,以及更广泛的框架集成。

目录 · 14 节

登录后请求翻译正文暂无中文,可请求翻译
查看原文

When we first launched Workflow SDK, the goal was simple: write regular async JavaScript, and let the SDK keep it running through crashes, deployments, and long waits.

workflows/welcome-user.ts
import { sleep } from "workflow";
export async function welcomeUser(email) {
"use workflow";
const user = await createUser(email);
await sendWelcomeEmail(user);
// Survives crashes and deployments
// while it waits
await sleep("3d");
await sendCheckInEmail(user);
}

A basic durable workflow

Last year, we shipped just that, with the world-class developer experience Vercel is known for. Then we watched what our customers built with it.

More than 4 billion steps and 700 million runs later, two clear patterns have emerged.

  • The first is automation: Traditional workflows that move data, process orders, coordinate background jobs, manage subscriptions, and run ETL and data pipelines.

  • The second is agents and harnesses: Agents are expensive and long running, so they naturally require durability too.

As those workloads matured, Workflow matured with them. Our priorities have always been security, reliability, and performance.

Here’s how Workflow SDK 5 delivers on all three.

Copy link to heading More secure workflows

The Workflow event log stores step arguments and return values so a run can recover after a crash or deployment. That data can include sensitive customer information, model context, credentials, and tool-call results. Persisting it requires strong protection.

Workflow SDK encrypts every payload end to end, before it leaves your code. Workflow and step inputs and outputs, hook payloads, and stream data are encrypted with AES-256-GCM, using a unique key for each run. With encryption enabled, any Workflow SDK backend, including Vercel, only sees and stores ciphertext. Plaintext is decrypted in your deployment or in authorized observability tools.

Copy link to heading Encryption with zero configuration on Vercel

On Vercel, encryption needs no setup and no code changes. Each run’s key is derived from a key scoped to the deployment that created it, so a run can only decrypt its own data. Your workflow code doesn’t change:

workflows/onboard-customer.ts
export async function onboardCustomer(
customer: Customer,
) {
"use workflow";
// The customer record is stored
// encrypted in the event log
const account = await createAccount(customer);
await sendWelcomeEmail(account.email);
return account.id;
}
async function createAccount(
customer: Customer,
) {
"use step";
// ...and arrives here decrypted,
// inside your deployment
return db.accounts.create(customer);
}

Workflow and step payloads are encrypted without changing application logic.

Because Vercel manages the keys by default, observability keeps working. Names, timings, and statuses are always visible, and when you need to see a payload, you can decrypt it in the dashboard or the CLI. Decryption happens in your browser or terminal, follows the same permissions as the project’s environment variables, and every request is recorded in your team’s audit log.

# Payloads show as 🔒 Encrypted
npx workflow inspect run <run-id>
# Decrypts locally, if you have access
npx workflow inspect run <run-id> --decrypt

Inspect encrypted payloads, then decrypt locally with authorized access.

Copy link to heading Encryption on self-hosted Worlds

Encryption is implemented in the SDK, so it can also protect payloads on self-hosted Worlds before they reach storage, queues, or streams.

A custom World enables encryption by implementing getEncryptionKeyForRun() with your key management. Return the same 32-byte key for each run on every call so the SDK can encrypt new payloads and decrypt them during replay:

world.ts
import type { World } from "@workflow/world";
type RunKeyProvider =
World["getEncryptionKeyForRun"];
export const getEncryptionKeyForRun:
RunKeyProvider = async (run) => {
const runId =
typeof run === "string" ? run : run.runId;
// Return the same 32 bytes for a run
// every time, so replays can decrypt
return keyStore.getRunKey(runId);
};

Provide a stable 32-byte encryption key for each run in a custom World.

Copy link to heading More security work in v5

Cross-run writes are sealed too. When code resumes another run’s hook, starts a run in another deployment, or writes into a stream forwarded from another run, the payload is encrypted to the target run’s public key. The writer can encrypt for that run without reading its existing payloads.

You can also limit how long sensitive data is stored. With payload retention set to experimental_retention: 0, inputs, outputs, and stream contents are deleted as soon as a run completes or fails. The run’s metadata stays visible in observability.

Copy link to heading A redesigned trace viewer

The redesigned trace viewer makes runs easier to navigate, with span search, zoom, a minimap, and local inspection during development.

An interactive demo of the real trace viewer on Vercel. Click a span and use Alt to visualize time deltas.

Run attributes are new in v5. They let you attach searchable context to a run, such as an order ID, and then find runs by it. Attributes are plaintext, so they should not contain secrets.

Copy link to heading Workflows in every region

In Workflow SDK 4, every run lived in iad1. Even when a project was deployed to several regions, each run’s event log, queue, and streams were only stored in one region, so a step running anywhere else made cross-region requests to record its progress.

For v5, we deployed Workflow infrastructure to every Vercel Function region. Each run has its own home region: its state, queue dispatch, and streams are served from the region where it started, without cross-region round trips on the hot path.

By default, a run starts in the region of the function that starts it. Deploy to several regions, and each run stays close to the user who triggered it, with no configuration:

app/api/checkout/route.ts
import { start } from "workflow/api";
import { processOrder } from "@/workflows/process-order";
export async function POST(request: Request) {
const order = await request.json();
// Runs in the region that served this request
const run = await start(
processOrder,
[order],
);
return Response.json({ runId: run.runId });
}

Start each order workflow in the region that handles its request.

To place a run somewhere else, pass a region to start(). That lets a workflow run next to the database it reads and writes, or keep a customer’s data in the region where it has to stay:

app/api/checkout/route.ts
// Keep this customer’s run data in Frankfurt
const run = await start(
processOrder,
[order],
{ region: "fra1" },
);

Store this order workflow’s data in Frankfurt.

The region option decides where a run’s data lives. Your steps run where your app is deployed, so deploy to that region too if you want them to execute there. Existing v4 runs stay in iad1.

Copy link to heading Infrastructure reliability

Regional isolation also improves reliability. A disruption in one region does not have to stop new runs in healthy regions. For projects with Vercel Function failover configured, steps can execute in a fallback region while continuing to use the run’s original home region for state. That state remains pinned to its home region; it does not migrate during failover.

With the help of anonymized telemetry and close collaboration with many customers, we found and fixed dozens of rare bugs and race conditions in the Workflow runtime. Workflow SDK also recovers on its own from more kinds of intermittent network errors.

As a result, with Workflow SDK 5, we’ve seen almost no runs fail or stall because of a platform or runtime bug.

Copy link to heading Agent-ready performance

In Workflow SDK 4, every step invocation involved a queue hop to start the step and another to continue the workflow. That is acceptable for slow background automations, but adds latency to the AI workloads developers are building today.

Agent loops and harnesses can contain thousands of sequential events, high-throughput token streams, tool chains, and dynamic subagents. At that scale, the networking and CPU work around every step became a limit.

In Workflow SDK 5, we rewrote large parts of the engine to minimize extra queue hops, unnecessary networking, and CPU work. Across the measured workloads, we saw 1.6× to 25× improvements in measured latency and overhead, while preserving the same developer experience and introducing no major breaking changes.

The benchmarks below compare v5.2.0 with v4.8.12 on Vercel. Pick a measurement to see how v5 compares with v4, then play or scrub through the explainer to see exactly what each benchmark measures.

Workflow SDK 5 includes hundreds of performance improvements to achieve this. Here are some of the major changes behind these numbers:

Fewer queue hops

In v4, each step handed execution back through the queue. In v5, an invocation can execute several steps inline, including parallel steps, before yielding for a wait, a hook, or an approaching timeout.

The runtime also avoids unnecessary persistence round trips and folds step creation into execution. Fewer queue and network requests mean less CPU work and lower runtime overhead. In a five-step benchmark, p75 step-to-step overhead fell from 618 ms to 109 ms.

Incremental replay

Over a 1,020-step benchmark, v4’s p75 overhead grew with the event log: replaying the full event history took time proportional to its size. In the final sampled range, overhead reached 1,748 ms. On v5.2.0, it was 70 ms. The median time to finish all 1,020 steps fell from 21.0 minutes to 3.0 minutes.

The gap between steps stays low. Step-to-step overhead at p75; lower is better. All bars share a 0–1,800 ms scale.

WebSocket streaming

Durability should not make a streamed response fall behind its producer. On the Vercel World, v5.2.0 writes streams over WebSockets by default. In a benchmark replaying a 52.4-second agent response, median delivery dropped from 226.1 seconds to 53.5 seconds.

A 52.4-second response, delivered in 53.5 seconds. Median delivery time. Same 2,593-chunk recording. Ten runs per version; a shared 0–240 s scale. This measures delivery of a recorded response, not faster model generation.

Payload compression reduces the data stored and transferred. AI token streams average around 80% smaller after compression.

These measurements describe one workload, in one region, against the Vercel World. They are a useful view of runtime overhead, rather than a prediction for every application.

Copy link to heading Benchmark results and methodology

Measured October 8, 2026, on Vercel production in iad1, against the managed Vercel World. Each version uses a separate deployment of the same app. Steps take 1 KB of JSON in and out.

Selected results · v4.8.12 compared with v5.2.0

Measurement

v4.8.12

v5.2.0

Change

First step, p75

418 ms

172 ms

2.4× faster

Between steps, p75

618 ms

109 ms

5.7× faster

Late-run overhead, p75

1,748 ms

70 ms

25× lower

1,020 steps, median

21.0 min

3.0 min

7× faster

Resume, p75

699 ms

425 ms

1.6× faster

Stream delivery, median

226.1 s

53.5 s

4.2× faster

Chunk trip time, p75

172 ms

102 ms

1.7× faster

Runs with a chunk delayed >1 s

6 / 10

0 / 10

100% fewer

The full results, including tails, are in the performance documentation.

Copy link to heading Worlds: the shared durability primitive

Workflow SDK’s durable functions sit on a World: the interface for storing progress, dispatching work, and delivering streams. That same foundation also now supports fx and durable-harness, which adds durability to existing agent harnesses.

Improvements to the shared storage, queue, and streaming infrastructure can benefit any consumer of a World. Optimizations inside the Workflow replay runtime apply to Workflow SDK; they do not automatically apply to every harness.

Choose the integration around how you want to build:

  • Workflow SDK: write durable application logic with use workflow and use step.

  • WorkflowAgent: use @ai-sdk/workflow for an AI SDK agent loop inside a workflow.

  • fx: embed and extend a native coding agent with libfx.

  • durable-harness: keep an existing supported harness and add durability beneath it.

  • eve: build agents with durable sessions powered natively by Workflow SDK and Worlds.

We’ll soon be adding more offerings to our catalog of SDKs and frameworks backed by Worlds for durability.

Copy link to heading Build with Workflow SDK 5

Besides the improvements above, Workflow SDK 5 also adds:

The v5 upgrade docs cover what changed. To start building a new workflow, install the SDK:

pnpm add workflow@latest

Install the latest Workflow SDK.

Workflow SDK also has a Python SDK, now in beta, with the same durable workflows, steps, sleeps, and hooks.

Contributors

Alex Langenfeld, Ashwin Venkatesan, Karthik Kalyanaraman, Mitul Shah, Nathan Rajlich, Shalabh Chaturvedi

Reference Architecture

Choose a stack and work through the decisions behind it, with curated documentation, guides, templates, and courses to help you build.

  • Agent stack: Build and operate agents with models, tools, and durable workflows.
  • Web applications: Choose rendering, data, authentication, and caching approaches.
  • Backends: Choose a runtime, connect services, and run background work.

Browse all stacks

Build with prompts

Build an app, extend an agent, or improve your project with ready-to-use prompts for your coding agent.

值得记下

  1. Workflow SDK 会在每个负载离开你的代码之前,对其进行端到端加密。工作流和步骤的输入与输出、钩子负载以及流数据,都会使用 AES-256-GCM 加密,并为每次运行使用唯一密钥。
  2. 在 Workflow SDK 5 中,我们重写了引擎的大部分内容,以尽量减少额外的队列跳转、不必要的网络通信和 CPU 开销。在测得的各类工作负载中,延迟和开销提升了 1.6× 至 25×。
  3. 每次运行都有自己的所属区域:状态、队列调度和流都由运行启动所在的区域提供服务,关键路径上不会发生跨区域往返。

← 回到本期 · 第 4 条