Interface IAgentObserver
Receives lifecycle notifications about an agent run. Implementations are
expected to be non-blocking — heavy work (DB writes, network IO) should be
queued. Multiple observers may be registered via DI; the engine fans out
calls in registration order.
public interface IAgentObserver
Methods
OnDeltaAsync(AgentDeltaContext, CancellationToken)
Called for each piece of a streamed model call (stream=calls) as it arrives: visible text or the
Task OnDeltaAsync(AgentDeltaContext context, CancellationToken ct = default)
OnIterationCompletedAsync(AgentIterationContext, CancellationToken)
Called after each provider call returns, before tool dispatch.
Task OnIterationCompletedAsync(AgentIterationContext context, CancellationToken ct = default)
OnRunCompletedAsync(AgentRunCompletedContext, CancellationToken)
Called once when an agent run ends (whether normally or via cancellation/error).
Task OnRunCompletedAsync(AgentRunCompletedContext context, CancellationToken ct = default)
OnRunStartedAsync(AgentRunContext, CancellationToken)
Called once when an agent run begins.
Task OnRunStartedAsync(AgentRunContext context, CancellationToken ct = default)
OnToolInvokedAsync(AgentToolInvocationContext, CancellationToken)
Called for each tool invocation, after it returns or throws.
Task OnToolInvokedAsync(AgentToolInvocationContext context, CancellationToken ct = default)