Class OrchestrationStreamingExtensions
- Namespace
- LMKit.Agents.Orchestration.Streaming
- Assembly
- LM-Kit.NET.dll
Extension methods for streaming orchestration execution.
Provides convenient APIs for consuming streaming output from orchestrators, including callback-based handlers and IAsyncEnumerable<T> support.
public static class OrchestrationStreamingExtensions
- Inheritance
-
OrchestrationStreamingExtensions
- Inherited Members
Examples
// IAsyncEnumerable streaming
await foreach (var token in orchestrator.StreamAsync("Build a REST API"))
{
if (token.Type == OrchestrationStreamTokenType.Content)
Console.Write(token.Text);
else if (token.Type == OrchestrationStreamTokenType.AgentStarted)
Console.WriteLine($"\n[{token.AgentName}]");
}
// Callback-based streaming
var result = await orchestrator.RunStreamingAsync("Task",
token => Console.Write(token.Text));
// Handler-based streaming
var handler = DelegateOrchestrationStreamHandler.ConsoleVerbose();
var result = await orchestrator.RunStreamingAsync("Task", handler);
Methods
- RunStreamingAsync(IOrchestrator, string, IOrchestrationStreamHandler, OrchestrationOptions, CancellationToken)
Executes the orchestration with streaming output to a handler.
- RunStreamingAsync(IOrchestrator, string, Action<OrchestrationStreamToken>, OrchestrationOptions, CancellationToken)
Executes the orchestration with streaming output using a token callback.
- RunStreamingAsync(IOrchestrator, string, Action<string>, OrchestrationOptions, CancellationToken)
Executes the orchestration with streaming content output using a string callback.
- RunStreamingToConsoleAsync(IOrchestrator, string, bool, OrchestrationOptions, CancellationToken)
Executes with streaming and writes directly to console.
- StreamAsync(IOrchestrator, string, OrchestrationOptions, CancellationToken)
Streams orchestration output as an async enumerable.
- StreamContentAsync(IOrchestrator, string, OrchestrationOptions, CancellationToken)
Streams only content text from the orchestration (filters out agent transitions, tool calls, etc.).
- StreamWithAgentLabelsAsync(IOrchestrator, string, OrchestrationOptions, CancellationToken)
Streams content with agent labels, showing which agent is generating each response.