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

const run = myWorkflow.createRun(); // Add a stream to monitor execution const result = run.stream({ inputData: {...} }); for (const chunk of stream) { // do something with the chunk }

Messages

start:

object
The workflow starts
object

example:

{ type: 'start', payload: { runId: '1' } }
Example message structure

step-start:

object
The start of a step
object

example:

{ type: 'step-start', payload: { id: 'fetch-weather' } }
Example message structure

tool-call:

object
A tool call has started
object

example:

{ type: 'tool-call', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:...' } }
Example message structure

tool-call-streaming-start:

object
A tool call/agent has started
object

example:

{ type: 'tool-call-streaming-start', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:...' } }
Example message structure

tool-call-delta:

object
The delta of the tool output
object

example:

{ type: 'tool-call-delta', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:\n' + ' [\n' + ' {\n' + ' "date": "2025-05-16",\n' + ' "maxTemp": 22.2,\n' + ' "minTemp": 16,\n' + ' "precipitationChance": 5,\n' + ' "condition": "Dense drizzle",\n' + ' "location": "New York"\n' + ' },\n' + ' ' }, argsTextDelta: '📅' }
Example message structure

step-result:

object
The result of a step
object

example:

{ type: 'step-result', payload: { id: 'Weather Agent', status: 'success', output: [Object] } }
Example message structure

step-finish:

object
The end of a step
object

example:

{ type: 'step-finish', payload: { id: 'Weather Agent', metadata: {} } }
Example message structure

finish:

object
The end of the workflow
object

example:

{ type: 'finish', payload: { runId: '1' } }
Example message structure

Parameters

params:

object
Configuration object for starting the workflow run
z.infer<TInput>

z.infer<TInput>?:

inputData
Runtime context data to use when starting the workflow
RuntimeContext

runtimeContext?:

RuntimeContext
Runtime context data to use when starting the workflow

Returns

result:

Promise<WorkflowResult<TOutput, TSteps>>
A stream that pipes each step to the stream