Skip to content

ChannelProgressReporter

NexusLabs.Needlr.AgentFramework

NexusLabs.Needlr.AgentFramework.Progress

ChannelProgressReporter Class

Non-blocking IProgressReporter that pushes events to a System.Threading.Channels.Channel<> and drains them to sinks on a background task. Use this when sinks do I/O (database, network) and you don't want to block the agent pipeline.

public sealed class ChannelProgressReporter : NexusLabs.Needlr.AgentFramework.Progress.IProgressReporter, System.IAsyncDisposable

Inheritance System.Object 🡒 ChannelProgressReporter

Implements IProgressReporter, System.IAsyncDisposable

Remarks

Report(IProgressEvent) writes to the channel and returns immediately. A background consumer drains events to all sinks. Events are delivered in order but asynchronously.

CreateChild(string) returns a lightweight wrapper that shares the parent's channel — no additional background tasks are created.

Call DisposeAsync() to drain remaining events and stop the background consumer.

Constructors

ChannelProgressReporter(string, IReadOnlyList<IProgressSink>, IProgressSequence, IProgressReporterErrorHandler, string, string, int, int) Constructor

Creates a channel-based reporter with the given sinks. Starts a background consumer immediately.

public ChannelProgressReporter(string workflowId, System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.AgentFramework.Progress.IProgressSink> sinks, NexusLabs.Needlr.AgentFramework.Progress.IProgressSequence sequence, NexusLabs.Needlr.AgentFramework.Progress.IProgressReporterErrorHandler? errorHandler=null, string? agentId=null, string? parentAgentId=null, int depth=0, int capacity=1000);

Parameters

workflowId System.String

sinks System.Collections.Generic.IReadOnlyList<IProgressSink>

sequence IProgressSequence

errorHandler IProgressReporterErrorHandler

agentId System.String

parentAgentId System.String

depth System.Int32

capacity System.Int32

Properties

ChannelProgressReporter.AgentId Property

Gets the current agent ID, or null for workflow-level scope.

public string? AgentId { get; }

Implements AgentId

Property Value

System.String

ChannelProgressReporter.Depth Property

Gets the nesting depth.

public int Depth { get; }

Implements Depth

Property Value

System.Int32

ChannelProgressReporter.WorkflowId Property

Gets the workflow ID for this reporter's scope.

public string WorkflowId { get; }

Implements WorkflowId

Property Value

System.String

Methods

ChannelProgressReporter.CreateChild(string) Method

Creates a child reporter scoped to a specific agent. Events emitted by the child carry the parent's agent ID as ParentAgentId and an incremented Depth.

public NexusLabs.Needlr.AgentFramework.Progress.IProgressReporter CreateChild(string agentId);

Parameters

agentId System.String

The agent ID for the child scope.

Implements CreateChild(string)

Returns

IProgressReporter

ChannelProgressReporter.DisposeAsync() Method

Completes the channel and waits for the background consumer to drain all remaining events to sinks.

public System.Threading.Tasks.ValueTask DisposeAsync();

Implements DisposeAsync()

Returns

System.Threading.Tasks.ValueTask

ChannelProgressReporter.NextSequence() Method

Allocates the next globally-ordered sequence number.

public long NextSequence();

Implements NextSequence()

Returns

System.Int64

ChannelProgressReporter.Report(IProgressEvent) Method

Emits a progress event to all registered sinks.

public void Report(NexusLabs.Needlr.AgentFramework.Progress.IProgressEvent progressEvent);

Parameters

progressEvent IProgressEvent

Implements Report(IProgressEvent)