Interface IOrchestrationStreamHandler
- Namespace
- LMKit.Agents.Orchestration.Streaming
- Assembly
- LM-Kit.NET.dll
Interface for handling streaming orchestration output.
Implement this interface to receive tokens as they are generated across all agents in an orchestration, enabling real-time display of multi-agent workflows.
public interface IOrchestrationStreamHandler
Examples
class ConsoleOrchestrationHandler : IOrchestrationStreamHandler
{
public Task OnTokenAsync(OrchestrationStreamToken token, CancellationToken ct)
{
if (token.Type == OrchestrationStreamTokenType.Content)
Console.Write(token.Text);
else if (token.Type == OrchestrationStreamTokenType.AgentStarted)
Console.WriteLine($"\n--- {token.AgentName} ---");
return Task.CompletedTask;
}
public Task OnOrchestrationStartAsync(IOrchestrator orchestrator, string input, CancellationToken ct)
{
Console.WriteLine($"Starting orchestration: {orchestrator.Name}");
return Task.CompletedTask;
}
public Task OnOrchestrationCompleteAsync(OrchestrationResult result, CancellationToken ct)
{
Console.WriteLine($"\nOrchestration complete: {result.Status}");
return Task.CompletedTask;
}
public Task OnErrorAsync(Exception ex, CancellationToken ct)
{
Console.WriteLine($"Error: {ex.Message}");
return Task.CompletedTask;
}
}
Methods
- OnErrorAsync(Exception, CancellationToken)
Called when an error occurs during the orchestration.
- OnOrchestrationCompleteAsync(OrchestrationResult, CancellationToken)
Called when the orchestration completes.
- OnOrchestrationStartAsync(IOrchestrator, string, CancellationToken)
Called when the orchestration starts.
- OnTokenAsync(OrchestrationStreamToken, CancellationToken)
Called when a new token is received from any agent in the orchestration.