Skip to main content

Run.restart()

The .restart() method restarts an active workflow run that lost connection to the server, allowing you to continue execution from the moment it lost connection (the last active step).

Usage exampleDirect link to Usage example

const run = await workflow.createRun();

const result = await run.start({ inputData: { value: "initial data" } });

//.. server connection lost,

const restartedResult = await run.restart();

ParametersDirect link to Parameters

requestContext?:

RequestContext
Request Context data to use when resuming

tracingContext?:

TracingContext
Tracing context for creating child spans and adding metadata. Automatically injected when using Mastra's tracing system.

currentSpan?:

Span
Current 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 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.

ReturnsDirect link to 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 Tracing is enabled. Use this to correlate logs and debug execution flow.

On this page