Engineering notes — ExplainersVercel Workflow SDK 5.8 migration: faster runs in practice
How to upgrade to Vercel Workflow SDK 5.8, enable the new execution engine, make steps idempotent, and actually see latency and cost improvements.
Vercel Workflow SDK 5.8 moves existing workflows onto a new execution engine with much lower per-step overhead and better behavior for large fan-outs. The upgrade is a version bump, but you only see the promised gains if your steps are idempotent and your configuration lets the new engine do its work.
This is a concrete guide to upgrading to workflow@5.8.0, understanding what the engine change actually does, and tuning parallel and AI-heavy workflows to benefit from it.
What actually changed in Workflow SDK 5.8?
Vercel’s changelog describes 5.8 as:
"Workflow SDK 5.8 runs workflows on a new execution engine, rebuilt for performance. Step-to-step latency is 12x lower, and large fan-outs, like running 256 steps in parallel, use 14x less function time outside your step code."
Vercel, in Workflow is 10x faster, again
The key points from the announcement:
- A new execution engine powers workflows created with
workflow@5.8.0or later. - Step-to-step overhead in their benchmark dropped from p75 85 ms to 7 ms.
- A median run with 102 seconds of actual step work finished in 111 seconds instead of 3 minutes.
- A fan-out of 256 parallel steps added 2.5 seconds of overhead instead of 13.5 seconds.
- The median run spent 105 seconds in non-step function time instead of 1,446 seconds.
- A five-turn durable AI agent loop that streams tokens and calls tools added 0.9 seconds of overhead instead of 3.0 seconds.
- Resuming after 1 second idle dropped from 425 ms to 184 ms.
Most of these gains come from speculative execution of retryable steps. The engine is allowed to re-run safe steps when that improves throughput and tail latency.
If you upgrade but your steps are not idempotent, or you blanket every step with maxRetries = 0, you keep safety but lose a lot of the performance upside.
How to upgrade to Workflow SDK 5.8 safely
The minimum change is straightforward:
- Bump the package version to
workflow@5.8.0or later. - Let new runs use the new execution engine by default.
- Leave existing runs alone; they keep using the old engine until they finish.
Vercel is explicit about this behavior:
"To get the new engine, upgrade to workflow@5.8.0 or later. New runs will use the new engine by default, and runs already started on an older version will safely keep running on that version."
Vercel, in Workflow is 10x faster, again
If you need to upgrade the SDK but temporarily keep new workflows on the old engine, set:
export WORKFLOW_SPEC_VERSION=8With WORKFLOW_SPEC_VERSION=8, new runs keep using the previous engine even after the dependency bump. That gives you a feature-flag feel: you can ship the package upgrade, then remove or change the env var once you’ve hardened your steps.
If you’re currently on 4.x, Vercel says to start with their upgrade guide, because v5 is a major release. Follow that first, then come back to this engine change.
Third-party Worlds and spec version 9
If your workflows use a third-party World, there’s an extra gate:
- All Worlds maintained by Vercel already support the new engine.
- A third-party World must support World spec version 9 before the new engine applies.
- Until then, new runs continue on the previous engine, even if you’re on
workflow@5.8.0.
That means you can’t assume the latency numbers until you’ve confirmed your World provider is on spec v9.
How speculative execution works for steps
Speculative execution is the main behavioral change you need to reason about.
Vercel describes it this way:
"Many of the above benefits rely on speculative execution of Steps. Only Steps that are idempotent can be run in this way."
Under the new engine:
- Retryable steps (those that can safely be run again) may be executed speculatively.
- This lets the engine overlap work, recover faster from transient issues, and shrink the overhead you pay between steps.
- Non-idempotent steps must be explicitly marked to avoid speculative re-runs.
The Stripe-style pattern they mention as safe is:
- Pass a stable idempotency key derived from
stepId. - The external system (Stripe in their example) uses that key to ensure at-most-once semantics.
In TypeScript, an illustrative pattern looks like this:
// Illustration only, not from Vercel's docs
import { Step } from "workflow";
export const chargeCustomer = Step.of("chargeCustomer", async (input) => {
const idempotencyKey = `charge_${input.stepId}`;
const res = await fetch("https://api.example-payments.com/charge", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": idempotencyKey,
},
body: JSON.stringify({
customerId: input.customerId,
amount: input.amount,
}),
});
if (!res.ok) throw new Error("Charge failed");
return res.json();
});Here, a speculative or retried call with the same stepId ends up with the same idempotency key. The payment API turns “maybe run twice” into “logically run once”.
For sensitive steps that can’t be retried at all, Vercel’s guidance is that you should mark them with maxRetries = 0 to opt out and ensure they still run at most once.
So in your step declaration, you set maxRetries = 0 (exact API shape depends on your current usage). That tells the engine not to speculatively execute or otherwise re-run it.
Making fan-out / fan-in workflows cheaper and faster
The benchmark numbers for large parallelism are stark:
- Running 256 parallel steps added 2.5 seconds overhead instead of 13.5 seconds.
- The run spent 14× less time in functions beyond the steps’ own work.
If you already have a fan-out / fan-in pattern for an AI workflow, data processing, or multi-tenant job runner, 5.8 changes what’s expensive:
- Before 5.8: a big chunk of your billable time was orchestration and function overhead.
- With 5.8: more of the total time is your actual step code. The “tax” for concurrency is smaller.
A simple fan-out / fan-in shape looks like this:
Start
|
v
Step A (plan)
|
v
Fan-out: Steps B1..Bn in parallel
| | |
v v v
Fan-in: Step C (aggregate)
|
v
DoneTo benefit from the new engine in this pattern:
- Keep fan-out steps idempotent. They’re the main candidate for speculative execution and retries.
- Use stable keys per unit of work (per user, per document, per agent turn) so duplicates coalesce on the external system.
- Keep the aggregation step small and mostly in-memory where possible, so you don’t reintroduce a bottleneck.
For AI agents, Vercel calls out:
- A five-turn agent loop that streams via durable streams and calls tools.
- Overhead dropped from 3.0 seconds to 0.9 seconds.
If your agent loop is structured as a series of steps (plan, call model, call tools, update state, repeat), this is where speculative execution and lower base overhead tighten up “time to next token” and “time to next tool call”.
If you’re building AI-heavy workflows on top of Next.js APIs and Vercel already, the patterns from my work on Recall’s generated cards and Seuil’s learning system carry over: keep external effects idempotent, structure calls clearly, then let the infrastructure run them hard in parallel.
Measuring before and after: step latency and cost
Vercel shares headline numbers, but each app’s mix of I/O, compute and external APIs is different. I’d treat this upgrade like any infrastructure change: measure it.
You can’t see their internal benchmarks, but you can:
- Log per-step timings in your own code.
- Measure queue-to-start latency for each step.
- Track billable function time before and after.
An illustrative instrumentation approach around your step functions:
// Illustration only
export const expensiveStep = Step.of("expensiveStep", async (input) => {
const started = Date.now();
const result = await doWork(input);
const ended = Date.now();
console.log("step:expensiveStep", {
durationMs: ended - started,
runId: input.runId,
stepId: input.stepId,
});
return result;
});Collect logs for a day on 5.2.x, then again after upgrading to 5.8 with the same traffic shape. The expectation from Vercel’s benchmark is:
- Shorter gaps between steps starting.
- Lower total runtime for workflows with many steps.
- Less billable time outside the body of your step functions.
If you already use Vercel’s tracing features, the approach from instrumenting Vercel Daemons with OpenTelemetry also applies here: treat each workflow step as a span you can compare across deployments.
Tuning resume latency vs cost
The new engine also affects how quickly a paused workflow picks up again. In Vercel’s benchmark:
- Resuming after 1 second idle: 425 ms → 184 ms (2.3× faster).
- Resumptions after 5+ seconds might see slightly larger overhead.
Vercel adds one important consequence: you can choose to keep functions warm for longer to optimize time-to-resume at the cost of additional compute time.
So you have a direct time vs money trade-off:
- If your workflows are latency sensitive (interactive AI agents, user-facing orchestrations), keeping functions warm longer may be worth it.
- If they are batch or background, you probably care more about spend than the extra hundreds of milliseconds on a resume.
Because Vercel’s announcement doesn’t describe the exact configuration knobs here, I’d treat any “keep warm longer” setting as an optimization pass after you’ve:
- Upgraded.
- Cleaned up idempotency.
- Confirmed speculative-friendly steps are fast and parallel.
Trying it: a staged rollout plan
Based on the announcement, a practical rollout looks like this:
Audit your steps
- Identify steps with external side effects: payments, emails, third-party writes.
- For each, choose:
- Make it idempotent (idempotency key, upsert logic, dedupe), or
- Mark it non-retryable with
maxRetries = 0.
Upgrade the SDK
- Bump to
workflow@5.8.0or later. - Keep
WORKFLOW_SPEC_VERSION=8set while you shake out idempotency bugs.
- Bump to
Measure on the old engine
- Add logging or tracing around step runtimes.
- Capture a baseline for a few representative workflows: large fan-out, AI agent, and a simple linear flow.
Switch to the new engine
- Remove or change
WORKFLOW_SPEC_VERSIONso new runs use the new engine. - Confirm any third-party Worlds you depend on support spec version 9.
- Remove or change
Compare and tune
- Re-run the same workflows and compare timings.
- Decide whether to adjust warm durations based on your resume-latency vs cost trade-off.
This aligns cleanly with how I’d stage a Next.js or Vercel infra change in a production SaaS, similar to the rollout patterns I described for Vercel Standard build billing changes and the 20MiB request body limit.
When I wouldn’t rush the migration
There are a few cases where I’d slow down or hold off on the new engine:
- Non-idempotent, high-stakes side effects where you’re not yet sure you can express safe idempotency keys or upserts.
- Workflows that depend on a third-party World that hasn’t moved to spec version 9. Upgrading the SDK without the World support won’t change engine behavior.
- Teams with no observability on step behavior today. If you can’t tell whether a step was re-run, you’ll have a hard time debugging speculative execution interactions.
You can still upgrade to workflow@5.8.0 in these scenarios and leave WORKFLOW_SPEC_VERSION=8 set while you put the right safeguards and visibility in place.
The new Workflow execution engine in SDK 5.8 is a clear infrastructure upgrade: much lower per-step overhead, cheaper big parallel fans, and tighter agent loops, as long as your steps are written for idempotency. If you treat the migration as a chance to re-audit side effects and observability, you get both the performance benefits and a system that’s easier to reason about. If you want help wiring this into a Next.js or Vercel-based product, you can start a project with me through my Next.js developer services.
Sources
- Vercel: Workflow is 10x faster, again - speculative execution and the new Workflow execution engine: https://vercel.com/changelog/workflows-speculative-execution