Visitar URL original
Vercel WorkflowsSkip to content

Build agents and applications that pause and resume

Vercel Workflows runs multi-step logic as durable code that can retry failed steps, wait for external events, and resume across crashes and deployments.
app/workflows/ai-content-workflow.ts
export async function aiContentWorkflow(topic: string) {
  'use workflow';
 
  const draft = await generateDraft(topic);
 
  const summary = await summarizeDraft(draft);
 
  return { draft, summary };
}

Vercel Workflows builds on the open-source Workflow SDK for JavaScript and TypeScript, and on workflow support in the vercel Python SDK to let your code pause, resume, and maintain state.

With Workflows, Vercel manages the infrastructure so you can focus on writing business logic. Vercel Functions execute your workflow and step code. Vercel Queues enqueue and execute those routes with reliability. Managed persistence stores all state and event logs in an optimized database.

Your workflows are:

  • Resumable: Pause for minutes or months, then resume from the exact point.
  • Durable: Survive deployments and crashes with deterministic replays.
  • Observable: Use built-in logs, metrics, and tracing and view them in your Vercel dashboard.
  • Write async JavaScript, TypeScript, or Python with familiar language primitives. No YAML or state machines.
Workflows diagram.
Workflows diagram.

Compare background worker options to choose between durable workflows, individual queued jobs, and continuously running workers.

For JavaScript and TypeScript, install the Workflow SDK package:

Terminal
pnpm i workflow
Terminal
yarn add workflow
Terminal
npm i workflow
Terminal
bun add workflow

Follow the Workflow SDK getting started guide to create your first workflow.

If you're using Pi, Claude Code, Codex, or OpenCode, durable-harness connects your agent to the Workflow SDK's persistence and execution infrastructure so sessions can resume after crashes and deployments. The durable harness guides cover setup for each, along with fx and eve, which already have durability built in.

WorkflowAgent runs an AI SDK agent loop inside a workflow. eve uses Workflows for durable sessions and adds built-in channels and approvals. See Choosing between eve, AI SDK agents, and WorkflowAgent to compare these options with an agent that runs within one request.

For a durable agent that works on GitHub, createDurableGithubAgent from GitHub Tools wraps a WorkflowAgent with GitHub tools configured. Each model call and tool call runs as a step. A write that needs approval returns an approval request, and the tool runs only after your application sends back an answer.

Follow Build durable workflows in Python on Vercel to start an onboarding workflow from FastAPI, persist completed steps, retry failures, and send a follow-up after a three-day wait.

  • Workflows and steps: Write durable functions with 'use workflow' and 'use step' directives.
  • Sleep and hooks: Pause for minutes to months, or wait for external events.
  • Observability: Track runs in real time, trace failures, and analyze performance.
  • Streams: Stream data in and out of workflows with managed persistence.
  • Dynamic workflows: Start runs from workflow source assembled after deployment, over steps already deployed with your app. Experimental.
  • Multi-region: Run workflows close to your users across all Vercel Function regions.
  • Skew Protection: Protect your workflows from version skew.
  • Usage-based pricing: Pay only for Events, Data Written, and Data Retained.
  • Data retention: See how long Vercel keeps run data, where Vercel stores it, and how to delete it sooner.

Workflows runs in every Vercel Function region. When a run starts, Workflows pins it to a single region and keeps its state, queue dispatch, and streams there for the run's lifetime. This avoids cross-region round trips on the hot path and contains the blast radius of a regional event to the runs pinned there.

Reads, hook resumes, and stream consumers can come from anywhere. The platform routes them to the run's region automatically.

By default, Workflows pins a run to the region of the function that started it. No configuration needed:

  • Deploy your app to a single region and every run lives in that region.
  • Deploy your app to multiple regions and each run is pinned to the region that served the user who triggered it.

To pin a run to a specific region, pass the region option to start():

app/api/start-workflow/route.ts
import { start } from 'workflow/api';
import { myWorkflow } from '@/workflows/my-workflow';
 
const run = await start(myWorkflow, [input], { region: 'sfo1' });

The region option controls where the run's data is stored and where its queue messages are dispatched from. It does not deploy your code to that region. For step execution to happen in the selected region, deploy your app there. To do this, configure Function regions through the regions key in vercel.json or the Function Regions project setting. If you deploy your app to a region other than the requested one, the run's data stays in the requested region while its steps execute in the nearest deployed region.

Multi-region requires workflow version 5.0.0-beta.33 or later. Runs created by the 4.x release line always live in iad1. Workflows locks each run's region at creation. To run in a different region, start a new run. Upgrading the SDK does not migrate runs created before the upgrade.

To learn which run data stays in the run's region, see Where Vercel stores run data.

Every step, input, output, sleep, and error inside a workflow is recorded automatically.

You can track runs in real time, trace failures, and analyze performance without writing extra code.

To inspect your runs, go to your Vercel dashboard , select your project, and open Workflows in the sidebar.

To inspect runs from the CLI or a local web UI, and to add tracing and run attributes, see Observability in the Workflow SDK docs.

Workflow run data can include recorded inputs, outputs, errors, and state.

Team owners can read decrypted Workflow run data. To grant a non-owner access to decrypted Workflow run data without granting owner-level access, assign the Workflow Run Data Viewer extended permission. For compatible roles and assignment details, see Extended Permissions.

Combine Chat SDK with Workflows to start durable tasks from chat messages and pause for human approval. Chat SDK handles platform events and replies, while Workflows persists execution across waits and retries.

Follow Chat SDK with Vercel Workflows to build a Slack approval flow with authorized approvers and a timeout. For another example, see the human-in-the-loop guide.

Workflow SDK is the open-source library you use to write durable workflows with the 'use workflow' and 'use step' directives. Vercel Workflows is the managed service that runs that code on Vercel. It stores run state and event logs, dispatches steps through Vercel Queues, and shows every run in the Workflows dashboard. The same code runs locally on the SDK's Local World, which needs no setup, and you can run it on other infrastructure with a World adapter, such as the Postgres World.

You can write workflows in JavaScript or TypeScript with the Workflow SDK. It has setup guides for Next.js, Vite, React Router, Astro, Express, Fastify, Hono, Nitro, Nuxt, SvelteKit, and TanStack Start, and NestJS support is in beta. Python support is also in beta through the vercel-workflow package, which marks workflows and steps with the @wf.workflow and @wf.step decorators instead of directives. Pick your framework in the Workflow SDK getting started guide.

Use Workflows when a job has several steps whose results must survive crashes and deployments, waits for minutes to months, or pauses until an external event or approval arrives. Use Vercel Queues for independent jobs that each need delivery with retries, and Vercel Schedules to start work on a cron schedule or once at a specific time. The services work together: a schedule can start a workflow each time it fires, and Workflows uses Queues to dispatch its steps. Compare every option in Background workers.

You have two options that run on Workflows. WorkflowAgent from @ai-sdk/workflow runs an AI SDK agent loop inside a workflow, so model calls run as durable steps and tools marked 'use step' get retries. eve is Vercel's framework for agents defined as files in an agent/ directory. On Vercel, every eve session runs as a workflow, and eve adds built-in channels such as Slack, tool approvals, a sandbox, and evals, so you don't write workflow code yourself. To compare them, see Choosing between eve, AI SDK agents, and WorkflowAgent.

Yes. Chat SDK exports requestApproval from chat/workflow. It posts a card with approve and deny buttons, then suspends the workflow until someone clicks or an optional timeout passes. Pass approvers to restrict who can decide. The wait survives deployments and restarts and uses no compute while suspended. Follow Chat SDK with Vercel Workflows for a Slack example, or read Approvals in the Chat SDK docs.


Was this helpful?

supported.