Dev & EngARTICLE

Vercel's Workflow SDK 5 encrypts data by default and cuts latency by up to 25x

Vercel's Workflow SDK 5 encrypts data by default and cuts latency by up to 25x
Image: Carina Ferreira
Article · Dev & Eng
Reading
6 min
Tables
1
Code
3
In short

The new version of the SDK that keeps pipelines and agents running through failures and deploys tackles three fronts at once: security, reliability, and performance for AI workloads.

From automation to agents: why Vercel rewrote the runtime

When Vercel launched the Workflow SDK, the proposal was simple: write ordinary asynchronous JavaScript and let the SDK keep execution alive through failures, deploys, and long waits. A sleep("3d") in the middle of a function survives a redeploy with no extra code. Since then, according to Vercel, the SDK has surpassed 4 billion steps executed and 700 million runs.

Two usage patterns emerged from that, and they shaped version 5. The first is traditional automation: moving data, processing orders, coordinating background jobs, managing subscriptions, running ETL. The second is AI agents and harnesses, which are expensive and long-running and therefore also require durability. Workflow SDK 5 was designed on top of these two cases, with a stated focus on security, reliability, and performance.

End-to-end encryption without touching your code

The Workflow event log stores the arguments and return values of each step to allow recovery after a crash or deploy. That log can contain sensitive customer data, model context, credentials, and tool-call results. Starting with v5, this entire payload is encrypted with AES-256-GCM before it leaves your code, using a unique key per run.

On Vercel, this requires no configuration at all: each run's key is derived from a key associated with the deployment, so a run can only decrypt its own data. The workflow code doesn't change:

typescript
export async function onboardCustomer(customer: Customer) {
 "use workflow";
 const account = await createAccount(customer);
 await sendWelcomeEmail(account.email);
 return account.id;
}

async function createAccount(customer: Customer) {
 "use step";
 // arrives decrypted here inside your deployment
 return db.accounts.create(customer);
}

Observability keeps working because each step's names, timings, and status remain visible in plain text; only the payload becomes ciphertext. To inspect the actual content, you need to decrypt locally, in the browser or the terminal, respecting the same permissions as the project's environment variables:

npx workflow inspect run <run-id>
npx workflow inspect run <run-id> --decrypt

Those running self-hosted Worlds can also enable encryption by implementing getEncryptionKeyForRun() with their own key management, as long as it always returns the same 32 bytes for the same run. Writes between runs (when code resumes another run's hook or writes to a forwarded stream) are also sealed, encrypted to the destination run's public key. And those who want to retain as little as possible can zero out retention with experimental_retention: 0, deleting inputs, outputs, and streams as soon as the run ends, keeping only the metadata.

Redesigned trace viewer and run attributes

v5 brings a reworked trace viewer, with span search, zoom, minimap, and local inspection during development. It's the screen that shows where a run got stuck or took too long, now navigable without having to cross-reference logs manually.

Run attributes also arrive: searchable metadata that can be attached to a run, such as an order ID, to later locate executions by that value. Vercel is explicit about the limitation: attributes remain in plain text, so they shouldn't carry secrets.

Workflows in every region, not just iad1

In Workflow SDK 4, every run lived in the iad1 region, even in projects deployed across multiple regions. That meant a step running elsewhere made cross-region requests just to record its progress, a hidden latency cost for any geographically distributed app.

In v5, Vercel brought Workflow infrastructure to every Function region. By default, a run is born in the region of the function that started it; you can force a different region by passing the region option to start():

typescript
const run = await start(processOrder, [order], { region: "fra1" });

This fixes where the run's state lives, but not where steps execute: steps run wherever the app is deployed, so pinning the data region to Frankfurt only makes sense if the deployment also covers that region. Old runs, created in v4, remain stuck in iad1 with no automatic migration. The extra gain is resilience: with Function failover configured, instability in one region doesn't bring down new runs in healthy regions, and state stays fixed in the origin region during failover.

Fewer queue hops for agent workloads

In v4, every step invocation went through one queue hop to start and another for the workflow to continue. For slow background automation this is irrelevant; for agent loops with thousands of sequential events, high-throughput token streams, and dynamic subagents, that per-step network and CPU cost became a real bottleneck.

v5 rewrote large parts of the engine to reduce queue hops, unnecessary network traffic, and CPU work, allowing a single invocation to execute multiple steps (including in parallel) before yielding control to a wait, a hook, or an upcoming timeout. A second pillar is incremental replay: instead of reprocessing the entire event history on every resume, the runtime avoids that growth proportional to log size. By default, streams in Vercel's World now travel over WebSocket, and payload compression cuts the average size of AI token streams by about 80%.

The numbers, measured on October 8, 2026, comparing v5.2.0 with v4.8.12 in production on Vercel (region iad1, steps with 1 KB of JSON input and output), are as follows:

Chart comparing V4 and V5 versions of the Workflow SDK, showing that the new version is 5.7 times faster
Chart comparing V4 and V5 versions of the Workflow SDK, showing that the new version is 5.7 times faster. Reprodução: vercel.com.
Measurementv4.8.12v5.2.0Change
First step, p75418 ms172 ms2.4x faster
Between steps, p75618 ms109 ms5.7x faster
Late overhead, p751,748 ms70 ms25x lower
1,020 steps, median21.0 min3.0 min7x faster
Resume, p75699 ms425 ms1.6x faster
Stream delivery, median226.1 s53.5 s4.2x faster
Runs with a chunk delayed >1s6 of 100 of 10100% fewer

A caveat is in order: Vercel itself treats these numbers as a snapshot of one specific workload, in one region, against Vercel's managed World, and not as a guaranteed forecast for any application. Those running self-hosted Worlds or other regions should measure their own scenario before generalizing these gains.

Worlds as a shared foundation: fx, durable-harness, and eve

Behind the SDK lies the concept of World, the interface that handles storing progress, dispatching work, and delivering streams. That same foundation now underpins other Vercel offerings: fx, for embedding and extending a native code agent via libfx; durable-harness, which adds durability to existing agent harnesses (with support for Pi and OpenCode, and experimental integrations with Claude Code and Codex on Vercel Sandbox); and eve, for building agents with native durable sessions.

Improvements in the shared storage, queue, and streaming layer benefit any consumer of World, but optimizations inside the Workflow SDK's replay runtime don't automatically propagate to every harness.

What changes in practice for those already running v4

Vercel states it has not introduced significant breaking changes in v5, so the update tends to be straightforward: pnpm add workflow@latest. Even so, there are concrete points to watch before migrating in production:

  • Runs created in v4 remain stuck in the iad1 region; there is no automatic migration of existing data to other regions.
  • Encryption is zero-config only on Vercel; in self-hosted Worlds it requires implementing and operating your own key management via getEncryptionKeyForRun().
  • Run attributes are plaintext by design, so they don't serve as a substitute for a secret or searchable sensitive data.
  • The most significant performance gains (incremental replay, fewer queue hops) matter mostly for those already operating agents or long-running harnesses; simple batch automation pipelines feel less difference day to day.

The Python SDK, launched in beta alongside v5, replicates durable steps, sleeps, and hooks for those building outside the Node.js ecosystem, a sign that Vercel's bet on durability as an infrastructure primitive goes beyond JavaScript.

Translated from the Brazilian Portuguese original · Read the original