The Workflow SDK now sends event writes and stream writes to Vercel Workflows over a WebSocket by default, replacing one HTTP request per write, or per write group for streams. No code change is needed beyond upgrading to [email protected] or later.
Once you deploy the upgrade, new runs use it. In-flight runs finish on the deployment they started on.
npm install workflow@latest
Existing streaming code works as is. A step that writes a burst of chunks, like AI tokens, sends them over the WebSocket once it opens:
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 .…