IStreamingWorkflowRun.WatchStreamAsync(CancellationToken) Method

Definition

Asynchronously streams workflow events as they occur during workflow execution.

public System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.Workflows.WorkflowEvent> WatchStreamAsync(System.Threading.CancellationToken cancellationToken = default);
abstract member WatchStreamAsync : System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Microsoft.Agents.AI.Workflows.WorkflowEvent>
Public Function WatchStreamAsync (Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of WorkflowEvent)

Parameters

cancellationToken
CancellationToken

A CancellationToken that can be used to cancel the streaming operation. If cancellation is requested, the stream will end and no further events will be yielded.

Returns

An asynchronous stream of WorkflowEvent objects representing significant workflow state changes.

Remarks

This method yields WorkflowEvent instances in real time as the workflow progresses. The stream completes when the workflow completes, fails, or is terminated. Events are delivered in the order they are raised.

Applies to