Skip to content

StreamingRunWorkflowExtensions

NexusLabs.Needlr.AgentFramework.Workflows

StreamingRunWorkflowExtensions Class

Extension methods on Microsoft.Agents.AI.Workflows.StreamingRun and Microsoft.Agents.AI.Workflows.Workflow for collecting agent responses.

public static class StreamingRunWorkflowExtensions

Inheritance System.Object 🡒 StreamingRunWorkflowExtensions

Methods

StreamingRunWorkflowExtensions.CollectAgentResponsesAsync(this StreamingRun, CancellationToken) Method

Collects all agent response text from a streaming run, grouped by executor ID.

public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,string>> CollectAgentResponsesAsync(this Microsoft.Agents.AI.Workflows.StreamingRun run, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

run Microsoft.Agents.AI.Workflows.StreamingRun

cancellationToken System.Threading.CancellationToken

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>>
A dictionary mapping each agent's executor ID to its complete response text. Agents that emitted no text produce no entry.

StreamingRunWorkflowExtensions.RunAsync(this Workflow, ChatMessage, IReadOnlyList<IWorkflowTerminationCondition>, CancellationToken) Method

Creates a streaming execution of the workflow, sends the message, collects all agent responses, and stops early when any termination condition is met.

public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,string>> RunAsync(this Microsoft.Agents.AI.Workflows.Workflow workflow, Microsoft.Extensions.AI.ChatMessage message, System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition>? terminationConditions, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

workflow Microsoft.Agents.AI.Workflows.Workflow

The workflow to execute.

message Microsoft.Extensions.AI.ChatMessage

The chat message to send to the workflow.

terminationConditions System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition>

Conditions evaluated after each completed agent turn. The first condition that returns true causes the loop to stop and remaining responses to be discarded. Pass an empty collection (or null) to disable Layer 2 termination.

cancellationToken System.Threading.CancellationToken

Optional cancellation token.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>>
A dictionary mapping each agent's executor ID to its complete response text up to the point of termination. Agents that emitted no text produce no entry.

StreamingRunWorkflowExtensions.RunAsync(this Workflow, ChatMessage, CancellationToken) Method

Creates a streaming execution of the workflow, sends the message, and collects all agent responses.

public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,string>> RunAsync(this Microsoft.Agents.AI.Workflows.Workflow workflow, Microsoft.Extensions.AI.ChatMessage message, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

workflow Microsoft.Agents.AI.Workflows.Workflow

The workflow to execute.

message Microsoft.Extensions.AI.ChatMessage

The chat message to send to the workflow.

cancellationToken System.Threading.CancellationToken

Optional cancellation token.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>>
A dictionary mapping each agent's executor ID to its complete response text. Agents that emitted no text produce no entry.

StreamingRunWorkflowExtensions.RunAsync(this Workflow, string, IReadOnlyList<IWorkflowTerminationCondition>, CancellationToken) Method

Creates a streaming execution of the workflow, sends the message, collects all agent responses, and stops early when any termination condition is met.

public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,string>> RunAsync(this Microsoft.Agents.AI.Workflows.Workflow workflow, string message, System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition>? terminationConditions, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

workflow Microsoft.Agents.AI.Workflows.Workflow

The workflow to execute.

message System.String

The user message to send to the workflow.

terminationConditions System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.IWorkflowTerminationCondition>

Conditions evaluated after each completed agent turn. The first condition that returns true causes the loop to stop and remaining responses to be discarded. Pass an empty collection (or null) to disable Layer 2 termination.

cancellationToken System.Threading.CancellationToken

Optional cancellation token.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>>
A dictionary mapping each agent's executor ID to its complete response text up to the point of termination. Agents that emitted no text produce no entry.

StreamingRunWorkflowExtensions.RunAsync(this Workflow, string, CancellationToken) Method

Creates a streaming execution of the workflow, sends the message, and collects all agent responses.

public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<string,string>> RunAsync(this Microsoft.Agents.AI.Workflows.Workflow workflow, string message, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

workflow Microsoft.Agents.AI.Workflows.Workflow

The workflow to execute.

message System.String

The user message to send to the workflow.

cancellationToken System.Threading.CancellationToken

Optional cancellation token.

Returns

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyDictionary<System.String,System.String>>
A dictionary mapping each agent's executor ID to its complete response text. Agents that emitted no text produce no entry.