Run.resumeStreamVNext() (Experimental)
Experimental
This feature is experimental and the API may change in future releases.
The .resumeStreamVNext() method resumes a suspended workflow run with new data, allowing you to continue execution from a specific step and to observe the stream of events.
Usage example
const run = await workflow.createRunAsync();
const stream = run.streamVNext({
inputData: {
value: "initial data",
},
});
const result = await stream.result;
if (result!.status === "suspended") {
const resumedStream = await run.resumeStreamVNext({
resumeData: {
value: "resume data",
},
});
}
Parameters
resumeData?:
z.infer<TInput>
Input data that matches the workflow's input schema
runtimeContext?:
RuntimeContext
Runtime context data to use during workflow execution
step?:
Step<string, any, any, any, any, TEngineType>
The step to resume execution from
tracingOptions?:
TracingOptions
Options for AI tracing configuration.
metadata?:
Record<string, any>
Metadata to add to the root trace span. Useful for adding custom attributes like user IDs, session IDs, or feature flags.
Returns
stream:
MastraWorkflowStream<ChunkType>
A custom stream that extends ReadableStream<ChunkType> with additional workflow-specific properties
stream.status:
Promise<RunStatus>
A promise that resolves to the current workflow run status
stream.result:
Promise<WorkflowResult<TState, TOutput, TSteps>>
A promise that resolves to the final workflow result
stream.usage:
Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>
A promise that resolves to token usage statistics
Stream Events
The stream emits various event types during workflow execution. Each event has a type field and a payload containing relevant data:
workflow-start: Workflow execution beginsworkflow-step-start: A step begins executionworkflow-step-output: Custom output from a stepworkflow-step-result: A step completes with resultsworkflow-finish: Workflow execution completes with usage statistics