Skip to content

Workflow Events ​

Multi-agent workflows emit a live stream that combines graph-level workflow events and normal child-agent events. Use these events when a UI, TUI, host, or dashboard needs to show workflow progress instead of only the final result.

Projection Layers ​

Render multi-agent runs in three layers:

  1. Workflow graph projection: workflow start/end, node start/end, skipped nodes, layer events, and edge traversal.
  2. Child agent runtime projection: normal AgentEvent values emitted by the agent running inside a node.
  3. Parent tool projection: when a workflow is invoked through [MultiAgent], the parent stream has a normal tool call wrapper with workflow events nested beneath it.
text
Parent agent
  tool draft_and_review
    DraftAndReview workflow
      draft node
        child agent text/tool events
      review node
        child agent text/tool events

Subscribe Or Iterate ​

Subscribe before running if projection code should live outside the execution loop:

csharp
using HPD.Agent;
using HPD.MultiAgent;

using var started = workflow.Subscribe<WorkflowStartedEvent>(evt =>
{
    ui.StartWorkflow(evt.WorkflowName, evt.NodeCount);
});

using var nodeStarted = workflow.Subscribe<WorkflowAgentStartedEvent>(evt =>
{
    ui.StartNode(evt.WorkflowName, evt.AgentId, evt.AgentName);
});

using var childEvents = workflow.SubscribeAny(evt =>
{
    if (evt is AgentEvent agentEvent && evt is not WorkflowStartedEvent)
    {
        ui.AppendAgentEvent(agentEvent);
    }
});

await foreach (var _ in workflow.ExecuteStreamingAsync(
    "Explain what changed in this thread.",
    cancellationToken: CancellationToken.None))
{
    // Subscriptions handle rendering while the stream is drained.
}

The returned async stream and workflow subscriptions expose the same public projection. Render from one path, or de-duplicate if you use both.

Use RunAsync(...) when you only need the final workflow result. Use ExecuteStreamingAsync(...) when you need streaming iteration. The workflow stream yields AgentEvent values, so application code does not need to reference HPD.Events. The generated [MultiAgent] wrapper supplies parent event context automatically.

Event Families ​

EventUse it for
WorkflowStartedEventCreate the workflow timeline; use WorkflowName, NodeCount, and LayerCount
WorkflowCompletedEventMark workflow completion; use duration and success/failure/skipped counts
WorkflowAgentStartedEventStart a workflow node row or card
WorkflowAgentCompletedEventComplete a node and show output, progress, duration, or error
WorkflowAgentSkippedEventShow a skipped node caused by routing or conditions
WorkflowApprovalRequestedEventPrompt the application or user for node approval
WorkflowApprovalTimedOutEventReport an approval request that exceeded its wait limit
WorkflowEdgeTraversedEventShow route decisions in graph/debug views
WorkflowLayerStartedEventStart a layer group in parallel or layer-based execution
WorkflowLayerCompletedEventComplete a layer group
WorkflowDiagnosticEventRender or log graph diagnostics
WorkflowRecoveryEventShow a node recovering through an alternate path or agent
WorkflowAttemptCompletedEventShow attempt-level completion status for recovery and retry views

Child agent events pass through as their normal event types. A workflow node can contain text deltas, reasoning events, tool call events, permission requests, structured result events, retries, and diagnostics.

Checkpointing does not add a separate public workflow event family. HPD Base owns durable activation state and checkpoint persistence; use its inspection surfaces for durable execution state. Do not rely on a structured CheckpointSaved event in the multi-agent workflow stream.

Metadata ​

Workflow-level events carry workflow metadata. WorkflowAgentStartedEvent and WorkflowAgentCompletedEvent describe a node through their own AgentId and AgentName properties, but their Metadata points to the workflow context.

Child agent events carry child agent metadata:

  • Metadata.AgentChain shows the nested agent path.
  • Metadata.Depth identifies nesting depth.
  • MessageId groups text and reasoning.
  • CallId groups tool activity.
  • request ids such as PermissionId group bidirectional interactions.

Use workflow event fields for graph structure. Use child AgentEvent metadata for runtime output inside a node.

Parent Agent Tools ​

When a parent agent exposes a workflow with [MultiAgent], the parent sees it as a normal tool call with CallType = MultiAgent. In the source-generated streaming path, the generated wrapper invokes the IMultiAgentWorkflow path with the parent execution context. That context carries the parent event coordinator, agent metadata, and client inheritance. Workflow events and child events then bubble into the parent stream.

[MultiAgent] has StreamEvents = true by default. If streaming is disabled, the generated wrapper uses RunAsync(...), so the parent stream does not receive the same live workflow projection.

Generated multi-agent capability tools require permission by default. A parent permission request can appear before workflow events.

Public Event Surface ​

The public workflow stream contains selected workflow events plus normal child agent events:

Runtime momentPublic event
workflow startsWorkflowStartedEvent
workflow completesWorkflowCompletedEvent
agent node startsWorkflowAgentStartedEvent
agent node completesWorkflowAgentCompletedEvent
agent node is skippedWorkflowAgentSkippedEvent
a node requests approvalWorkflowApprovalRequestedEvent
an approval request times outWorkflowApprovalTimedOutEvent
parallel layer startsWorkflowLayerStartedEvent
parallel layer completesWorkflowLayerCompletedEvent
route is traversedWorkflowEdgeTraversedEvent
workflow diagnostic is emittedWorkflowDiagnosticEvent
node recovery is selectedWorkflowRecoveryEvent
a node attempt completesWorkflowAttemptCompletedEvent
child agent emits an eventthe child AgentEvent

Other lower-level runtime events are not projected into the public workflow stream.

Persistence Caveat ​

Workflow events are live runtime events unless a persistence path maps them into thread history. Do not assume every workflow diagnostic, route, or child event is durable on the parent thread. If your product needs durable workflow replay, validate the session/thread policy and event persistence behavior for that workflow.

Built for production .NET agent applications.