Skip to content
AI NEWS JOURNAL
VercelAI NEWS / JOURNAL

Workflow is 10x faster, again

Workflow SDK 5.8 introduces a new execution engine that reduces step-to-step latency by 12x and cuts function time for large fan-outs by 14x, improving turn times for durable AI agents. The update enables speculative execution for idempotent steps, reducing overhead in benchmarks—p75 step-to-step latency dropped from 85 ms to 7 ms, and resumption after idle time improved from 425 ms to 184 ms. Users must upgrade to workflow@5.8.0 or later, ensure steps are idempotent, or set maxRetries = 0 for non-idempotent steps. The new engine is enabled by default, with existing runs continuing on the older version. Third-party Worlds must support spec version 9 to benefit from improvements.

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. This directly improves turn times for durable AI agents, among many other improvements. 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. Make sure your steps are idempotent where possible to get the most out of this upgrade. Copy link to headingDrastically reduced overhead In our benchmarks comparing 5.2.0 to 5.8.0, p75 step-to-step overhead fell from 85 ms to 7 ms. The median run, including 102 seconds of step work, finished in 111 seconds instead of 3.0 minutes. Running 256 parallel steps in a fan-out added 5.5× less overhead, 2.5 seconds instead of 13.5 seconds, and the median run spent 14× less time in functions beyond the steps' own work, 105 seconds instead of 1,446. A five-turn agent loop that streams its tokens through durable streams and calls tools added 0.9 seconds of overhead instead of 3.0 seconds, 3.3× less. Consult the benchmarks page for how we measure these numbers. Resuming after 1 second idle time went from 425 ms to 184 ms, 2.3× faster. Resumptions more than 5 seconds out might see slightly larger overhead. You can choose to keep functions warm for longer to optimize time-to-resume at the cost of additional compute time. Copy link to headingSpeculative execution for retryable steps Many of the above benefits rely on speculative execution of Steps. Only Steps that are idempotent can be run in this way. A step that passes its stepId as an idempotency key, like the Stripe charge below, is already safe and needs no changes. If your step is sensitive and can't be retried, mark it with maxRetries = 0 to opt out and ensure it still runs at most once. You should already be making Steps idempotent wherever possible, or flag them with maxRetries = 0, to ensure Workflow SDK doesn't re-run your Steps when it's not safe to do so. import { getStepMetadata } from "workflow"; // Idempotent: stepId stays the same across retries and speculative// re-runs, so Stripe creates one charge. No changes needed.async function chargeUser(userId: string, amount: number) { "use step"; const { stepId } = getStepMetadata(); await stripe.charges.create( { amount, currency: "usd", customer: userId }, { idempotencyKey: stepId }, );} // Hard to make idempotent: SMTP has no idempotency key, so a second// attempt sends a second email. Opt out of speculation and retries.async function sendReceiptEmail(to: string, orderId: string) { "use step"; await smtp.sendMail({ to, subject: `Your receipt for order ${orderId}` });} sendReceiptEmail.maxRetries = 0; Copy link to headingGet started Upgrade to workflow@5.8.0. To keep creating runs on the previous engine after upgrading, set WORKFLOW_SPEC_VERSION=8. If you're on 4.x, start with the upgrade guide, since v5 is a major release. npm install workflow@latest Using a third-party World? All Worlds maintained by Vercel already support the new engine. A third-party World needs to support World spec version 9 before upgrading gives you any of these improvements. Until it does, new runs keep using the previous engine. Contributors Peter Wielander, Pranay Prakash, Karthik Kalyanaraman, Nate Rajlich, Shalabh Chaturvedi, Alex Langenfeld

Sources

Read original ↗

Related topics

← Continue to all updates