Back/harness engineering

Vercel Workflows — Durable Execution for Agents

Updated 2026-04-19
2 min read
278 words

Vercel Workflows — Durable Execution for Agents

Vercel Workflows GA 发布(2026-04-16)。将长运行、可靠的 durable execution 引入 TypeScript/Python 应用代码,无需单独的 orchestrator、Kubernetes 或独立基础设施。

核心定位

Framework-defined infrastructure 解决了 web 应用的部署配置问题。Workflows 将这一模型扩展到长运行系统:durable workflows 是应用代码的扩展,而非单独维护的 orchestration 代码库。

Beta 数据(2025-10 至 2026-04):

  • 1 亿+ runs,5 亿+ steps
  • 1,500+ 客户
  • 20 万+ 周 npm 下载

三大基础设施组件

  1. Event log:记录每一步的输入、输出、流块、sleep、hook 和错误。执行状态和历史的事实来源。
  2. Fluid compute:每一步作为自己的函数调用在 Fluid compute 上运行。workflow 库处理出队、状态加载、加密、执行和交接。
  3. Vercel Queues:每个函数自动将下一步入队。可在 Vercel 上自动运行、自有 Postgres 或内存中本地运行。

关键洞察:没有单独的 orchestration 服务,只需为实际运行的步骤付费。

编程模型

export async function createSite(input: { userId: string }) {
  "use workflow"
  const profile = await fetchUserProfile(input.userId)
  const plan = await generateSitePlan(profile)
  const site = await buildSite(plan)
  return site
}

async function fetchUserProfile(userId: string) {
  "use step"
  return db.user.findUnique({ where: { id: userId } })
}

看起来像一个函数调用另一个函数,这正是重点。每个 step 自动获得隔离、重试、持久化、可观测性和 durable continuation。

Agent 场景

Durable Agents Workflow SDK 与 AI SDK 深度集成,提供 durable execution、工具调用、状态管理和优雅处理外部事件/中断的能力。

Durable Streams getWritable() 提供持久流,多个客户端可以连接、断开、稍后重连、从任意点恢复。workflow 即使用户关闭浏览器也继续运行。

Hooks and Sleep

  • Hooks:等待外部触发恢复,适合 human-in-the-loop 审批流
  • Sleep:暂停指定时间(分钟到天/月),适合邮件 drip campaigns

Agent 友好设计

  • 普通 TypeScript/Python:workflow 是函数,step 是函数,agent 只需推理一个系统
  • CLI 可观测性npx workflow inspect runs <wrun_id>,agent 可以直接从终端检查 workflow 状态
  • 内置 E2E 加密:所有数据(step 输入/输出/流块)在离开部署前加密,仅运行 workflow 的部署环境内解密
  • Skills 支持npx skills add vercel/workflow,agent 可直接 scaffold、debug、管理 workflows

Worlds:可移植性适配器

  • Managed:Vercel 全自动处理
  • Self-hosted:自有基础设施,Postgres 参考实现
  • Embedded:社区已构建 MongoDB、Redis、Turso、Jazz Cloud、Cloudflare 适配器

生产案例

  • Mux:媒体智能层,AI 推理跨复杂视频管道的执行、重试和编排
  • Durable:网站创建关键路径,数十个并行 AI steps 在 30 秒内交付完整站点,160+ directives 跨 75 文件
  • Flora:50+ 图像模型的媒体生成管道,无队列、无状态机、无单独服务

Counterpoints & Gaps

  • Vercel 生态锁定:虽然 Worlds 提供可移植性,但最佳体验仍在 Vercel 平台
  • 本地开发 vs 生产一致性虽有保证,但复杂 state 调试仍需要学习成本
  • Python SDK 刚进入 beta,生态成熟度低于 TypeScript

Sources

Linked from