Table of Contents

Method RunStreamingAsync

Namespace
LMKit.Agents.Orchestration.Streaming
Assembly
LM-Kit.NET.dll

RunStreamingAsync(IOrchestrator, string, IOrchestrationStreamHandler, OrchestrationOptions, CancellationToken)

Executes the orchestration with streaming output to a handler.

public static Task<OrchestrationResult> RunStreamingAsync(this IOrchestrator orchestrator, string input, IOrchestrationStreamHandler handler, OrchestrationOptions options = null, CancellationToken cancellationToken = default)

Parameters

orchestrator IOrchestrator

The orchestrator to execute.

input string

The input prompt.

handler IOrchestrationStreamHandler

The stream handler to receive tokens.

options OrchestrationOptions

Optional orchestration options (StreamHandler will be set automatically).

cancellationToken CancellationToken

Cancellation token.

Returns

Task<OrchestrationResult>

The final orchestration result.

Examples

var handler = DelegateOrchestrationStreamHandler.ConsoleWithAgentLabels();
var result = await orchestrator.RunStreamingAsync("Analyze this data", handler);

RunStreamingAsync(IOrchestrator, string, Action<OrchestrationStreamToken>, OrchestrationOptions, CancellationToken)

Executes the orchestration with streaming output using a token callback.

public static Task<OrchestrationResult> RunStreamingAsync(this IOrchestrator orchestrator, string input, Action<OrchestrationStreamToken> onToken, OrchestrationOptions options = null, CancellationToken cancellationToken = default)

Parameters

orchestrator IOrchestrator

The orchestrator to execute.

input string

The input prompt.

onToken Action<OrchestrationStreamToken>

Callback for each token.

options OrchestrationOptions

Optional orchestration options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<OrchestrationResult>

The final orchestration result.

Examples

var result = await orchestrator.RunStreamingAsync("Task",
    token =>
    {
        if (token.Type == OrchestrationStreamTokenType.Content)
            Console.Write(token.Text);
    });

RunStreamingAsync(IOrchestrator, string, Action<string>, OrchestrationOptions, CancellationToken)

Executes the orchestration with streaming content output using a string callback.

public static Task<OrchestrationResult> RunStreamingAsync(this IOrchestrator orchestrator, string input, Action<string> onContent, OrchestrationOptions options = null, CancellationToken cancellationToken = default)

Parameters

orchestrator IOrchestrator

The orchestrator to execute.

input string

The input prompt.

onContent Action<string>

Callback for content text (not agent transitions or tool calls).

options OrchestrationOptions

Optional orchestration options.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<OrchestrationResult>

The final orchestration result.

Examples

var result = await orchestrator.RunStreamingAsync("Task",
    text => Console.Write(text));
Share