Workflow SDK 5.2.0 Defaults to WebSocket, Speeding Up Streaming Responses by 4.2x

Workflow SDK 5.2.0 now uses WebSocket writes by default, making AI streaming responses 4.2x faster with no code changes.
In version 5.2.0, Vercel's Workflow SDK switched event writes and stream writes from "one HTTP request per write" to reusing a single WebSocket connection by default; developers only need to upgrade the dependency with zero changes to business code. Official benchmarks show that when replaying an AI agent token stream, full response delivery is 4.2x faster than v4.8.12, with no chunk exceeding one second of latency. Since every step start and completion is an event write, workflows with more steps save more requests, and deployment models billed by request also see cost reductions. The article also covers the connection lifecycle, the fact that in-flight runs don't switch transport, and the need to read the upgrade guide before going from 4.x to 5.x, noting that this is essentially a redesign of the I/O model for high-frequency AI streaming writes.
From HTTP to WebSocket: An Under-the-Hood Upgrade With No Code Changes Required
In version 5.2.0, Vercel's Workflow SDK switched event writes and stream writes to the WebSocket channel by default. Previously, every write—whether a single event or a chunk of streaming data—required its own separate HTTP request. After the upgrade, these writes all reuse a single WebSocket connection. Developers don't need to change any business logic; they simply need to upgrade the dependency to workflow@5.2.0 or higher.

On the surface, this change looks like a minor adjustment at the transport layer, but it actually addresses the core bottleneck of workflow engines in AI scenarios: when a single run contains many steps or continuously outputs tokens, the number of HTTP requests grows linearly with the number of writes—and WebSocket compresses that into a constant number of connections.
WebSocket is a protocol for full-duplex communication over a single TCP connection. It is established via an HTTP upgrade handshake, after which the client and server can push data frames to each other at any time without carrying full request and response headers on every exchange as HTTP does. For high-frequency, small-grained, continuous write scenarios, WebSocket eliminates the cost of repeatedly establishing connections and the overhead of headers, compressing N requests into N frames over a single connection. This is also why it is widely adopted in real-time chat, collaborative editing, financial market data, and AI token streaming output.
It's worth noting that WebSocket is not superior to HTTP in every scenario. It requires maintaining connection state and imposes additional requirements on load balancing, proxies, and timeout strategies; when write frequency is very low, HTTP's simplicity and stateless nature are actually easier to operate. The reason the change discussed in this article works is precisely that workflow event writes and streaming output are typical high-frequency write patterns.
The Biggest Gains Are in Streaming Scenarios
The official benchmark used a replay test of an AI agent's token stream: v5.2.0 delivered the full response 4.2x faster than v4.8.12, with no chunk experiencing more than one second of latency. This figure has clear significance for teams building AI streaming output—the wait between the user seeing the first character and the last is significantly compressed, and long answers no longer suffer from the disjointed feeling of "fast at the start, stalled at the end."
At the code level, existing streaming code is fully compatible. The writer obtained from getWritable() still writes chunk by chunk, the semantics of "use step" and "use workflow" are unchanged, and the SDK batches these chunks out once the WebSocket is open. In other words, token stream code written before the upgrade automatically gets a faster transport path after the upgrade.
import { getWritable } from "workflow";
async function streamChunks(chunks: string[]) {
"use step";
const writer = getWritable<string>().getWriter();
for (const chunk of chunks) {
await writer.write(chunk);
}
writer.releaseLock();
}
export async function streamingWorkflow(chunks: string[]) {
"use workflow";
await streamChunks(chunks);
}
In the Workflow SDK, getWritable() returns a writable stream; after calling getWriter(), data is appended chunk by chunk via write(), consistent with the standard usage of the Web Streams API. releaseLock() is used to release the writer's lock on the stream so that other consumers can take over.
"use step" and "use workflow" are directive markers in the Workflow SDK: the former declares a function as a durable, retryable workflow step, and the latter declares the workflow entry point. The SDK recognizes these directives at compile time or runtime and records the execution results of steps to support resuming from checkpoints. Understanding this helps clarify why every step start and completion produces an event write—these records are the foundation of workflow recoverability, and the WebSocket change reduces precisely the transport cost of recording these states.
Event Writes: The More Steps, the More Requests Saved
In a workflow, the start and completion of every step is an event write. As the number of steps grows, the number of HTTP requests balloons accordingly. After switching to WebSocket, these events are sent over the same connection, and the number of requests drops significantly. Vercel's phrasing is "improve performance and reduce costs"—for deployment models billed by request, this item may matter more to teams' bottom lines than latency.
It's important to clarify the connection lifecycle: the queue handler opens a connection for each delivery. This means WebSocket is not a global long-lived connection pool but is established and reused at the granularity of each delivery. The SDK manages this layer internally, so developers don't need to handle reconnection logic themselves.
The phrase "the queue handler opens a connection for each delivery" means that when the workflow engine's message queue delivers a task to an executor, it establishes a WebSocket connection for that delivery and reuses it for its lifetime. This differs from a traditional process-level or application-level global connection pool: the boundary of the connection is determined by the delivery unit, not by the process or tenant.
The trade-off of this design is that it avoids the resource consumption of long-lived connections during idle periods and the complexity of spanning deployments, while still being able to merge multiple writes into a single connection within a single delivery. Because connection establishment, reuse, and closure are all managed internally by the SDK, developers neither need to handle reconnection and heartbeats nor can they directly control the connection pool size; if you have special requirements for connection behavior, keep an eye on whether future SDK versions expose relevant configuration.
Upgrade Notes
The upgrade itself is simple:
npm install workflow@latest
There's one behavioral boundary to be aware of: after upgrading and deploying, newly started runs will use the WebSocket path, while runs already in flight at the time of the upgrade will continue running on the deployment where they started and will not switch transport mid-flight. This is a reasonable design for long-running workflows, avoiding disruption from a protocol switch during a run.
Additionally, going from 4.x to 5.x is a major version upgrade, and the official recommendation is to read the upgrade guide first rather than jumping straight to 5.2.0. Version 5.2.0 only makes WebSocket writes the default; the underlying 5.0 changes still need to be handled step by step according to the guide.
Why This Change Matters
Changing the workflow's write channel from "one HTTP request per write" to "one WebSocket" is essentially redesigning the I/O model for AI workloads. AI agent output is naturally continuous, fine-grained, and long-lasting, which doesn't match the HTTP request-response model. By changing this default behavior at this layer, Vercel is effectively acknowledging that streaming writes should be a first-class citizen of workflow engines rather than something developers have to optimize themselves.
For teams building AI applications with the Workflow SDK, the cost of upgrading to 5.2.0 is close to zero, and the benefits show up in both response speed and request overhead. As for whether to borrow the same approach in your own workflow system, it depends on your write frequency—if a run has only a handful of steps, HTTP's simplicity still has advantages; once you enter high-frequency write or token streaming scenarios, the gap opened up by WebSocket quickly becomes apparent.
Related articles

Nothing CMF Buds 2A Drops to $17.89 on Black Friday: A New Low for ANC Earbuds
Nothing CMF Buds 2A wireless earbuds Black Friday deal: just $17.89 on Amazon, about $11 off retail and a record low. ANC earbuds at an entry-level price.

When AI Creation Gets Accused of "Spitting": Hacker News Heats Up Over the Glaude Controversy
A Hacker News post, "Spitting in the Face of Glaude," sparks debate on AI creation transparency and attribution ethics. This analysis examines the blurred creator identity behind the controversy and offers practical advice for AI content production.

Akai Embraces Custom Firmware: MPC Sample 1.4 Lets Users AI-Program Their Sampler
Akai embraces the modding community with MPC Sample 1.4 firmware, supporting vibe-coded custom firmware and effects. We analyze the impact of this open strategy on music hardware and AI-assisted programming.