Run.resume()
The .resume() method resumes a suspended workflow run with new data, allowing you to continue execution from a specific step.
Usage example
const run = await workflow.createRunAsync();
const result = await run.start({ inputData: { value: "initial data" } });
if (result.status === "suspended") {
const resumedResults = await run.resume({
resumeData: { value: "resume data" }
});
}Parameters
resumeData?:
z.infer<TResumeSchema>
Data for resuming the suspended step
step?:
Step<string, any, any, TResumeSchema, any, TEngineType> | [...Step<string, any, any, any, any, TEngineType>[], Step<string, any, any, TResumeSchema, any, TEngineType>] | string | string[]
The step(s) to resume execution from. Can be a Step instance, array of Steps, step ID string, or array of step ID strings
runtimeContext?:
RuntimeContext
Runtime context data to use when resuming
runCount?:
number
Optional run count for nested workflow execution
tracingContext?:
TracingContext
AI tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.
currentSpan?:
AISpan
Current AI span for creating child spans and adding metadata. Use this to create custom child spans or update span attributes during execution.
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.
outputOptions?:
OutputOptions
Options for AI tracing configuration.
includeState?:
boolean
Whether to include the workflow run state in the result.
Returns
result:
Promise<WorkflowResult<TState, TOutput, TSteps>>
A promise that resolves to the workflow execution result containing step outputs and status
traceId?:
string
The trace ID associated with this execution when AI tracing is enabled. Use this to correlate logs and debug execution flow.
Extended usage example
if (result.status === "suspended") {
const resumedResults = await run.resume({
step: result.suspended[0],
resumeData: { value: "resume data" }
});
}Note: When exactly one step is suspended, you can omit the
stepparameter and the workflow will automatically resume that step. For workflows with multiple suspended steps, you must explicitly specify which step to resume.