Skip to Content

Run.stream()

The .stream() method allows you to monitor the execution of a workflow run, providing real-time updates on the status of steps.

Usage example

const run = await workflow.createRunAsync(); const stream = await run.stream({ inputData: { value: "initial data", }, });

Parameters

inputData?:

z.infer<TInput>
Input data that matches the workflow's input schema

runtimeContext?:

RuntimeContext
Runtime context data to use during workflow execution

Returns

stream:

ReadableStream<StreamEvent>
A readable stream that emits workflow execution events in real-time

getWorkflowState:

() => Promise<WorkflowResult<TOutput, TSteps>>
A function that returns a promise resolving to the final workflow result

Extended usage example

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

Stream Events

The stream emits various event types during workflow execution. Each event has a type field and a payload containing relevant data:

  • start: Workflow execution begins
  • step-start: A step begins execution
  • tool-call: A tool call is initiated
  • tool-call-streaming-start: Tool call streaming begins
  • tool-call-delta: Incremental tool output updates
  • step-result: A step completes with results
  • step-finish: A step finishes execution
  • finish: Workflow execution completes