IProgressSink
NexusLabs.Foundry.MicrosoftAgentFramework¶
NexusLabs.Foundry.MicrosoftAgentFramework.Progress¶
IProgressSink Interface¶
Receives progress events as they occur during agent/workflow execution. Implement this interface to build SSE streams, console displays, trace diagrams, etc.
Example¶
// Auto-discovered by Foundry — no explicit registration needed.
public sealed class ConsoleSink : IProgressSink
{
public ValueTask OnEventAsync(IProgressEvent e, CancellationToken ct)
{
Console.WriteLine($"[{e.WorkflowId}] {e.GetType().Name}");
return ValueTask.CompletedTask;
}
}
Remarks¶
Auto-discovery (simple apps): If Foundry's source generator or
reflection-based scanning is active, any class implementing
IProgressSink is automatically registered in DI as a singleton.
These auto-discovered sinks become the default sinks used by
Create(string).
You can also register sinks manually via
services.AddSingleton<IProgressSink, MySink>() — all DI-registered
IProgressSink instances are treated as defaults.
Per-orchestration sinks (complex apps): Use Create(string, IEnumerable<IProgressSink>) to pass sinks explicitly for a specific workflow run. This overload ignores the default sinks entirely, giving multi-tenant or multi-workflow applications full control over which sinks receive events for each orchestration.
Performance: Implementations should be fast — a slow sink delays
the agent pipeline. Use ChannelProgressReporter for non-blocking delivery
when sinks perform I/O.
Methods¶
IProgressSink.OnEventAsync(IProgressEvent, CancellationToken) Method¶
Called for each progress event. Implementations should be fast — a slow sink
delays the agent pipeline (use ChannelProgressReporter for non-blocking delivery).
System.Threading.Tasks.ValueTask OnEventAsync(NexusLabs.Foundry.MicrosoftAgentFramework.Progress.IProgressEvent progressEvent, System.Threading.CancellationToken cancellationToken);
Parameters¶
progressEvent IProgressEvent
cancellationToken System.Threading.CancellationToken