Multi-Agent Workflows
Multi-agent workflows let multiple agents work together in a directed graph. Each agent handles one step and passes its output to the next. Use this when a task is too complex for a single agent, or when you want specialized agents for different parts of a pipeline.
Input
│
▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Triage │────►│ Research │────►│ Writer │
│ Agent │ │ Agent │ │ Agent │
└──────────┘ └──────────┘ └──────────┘
│
▼
OutputWhen to Use Multi-Agent vs SubAgent
| SubAgent | Multi-Agent Workflow | |
|---|---|---|
| Agents | One child agent | Many agents in a graph |
| Structure | Simple delegation | Directed pipeline or graph |
| Routing | None | Conditional edges, handoffs |
| Use when | One specialized task | Sequential or parallel pipeline |
→ See 02.1.3 SubAgents.md for single agent delegation.
Quick Start
csharp
using HPD.MultiAgent;
var workflow = await AgentWorkflow.Create()
.AddAgent("researcher", new AgentConfig
{
SystemInstructions = "Research the topic thoroughly."
})
.AddAgent("writer", new AgentConfig
{
SystemInstructions = "Write a clear, concise answer."
})
.From("researcher").To("writer")
.BuildAsync();
var result = await workflow.RunAsync("Explain quantum entanglement");
Console.WriteLine(result.FinalAnswer);Streaming
csharp
await foreach (var evt in workflow.ExecuteStreamingAsync(input))
{
if (evt is TextDeltaEvent delta)
Console.Write(delta.Text);
if (evt is WorkflowCompletedEvent)
Console.WriteLine("\nDone.");
}In This Section
- 06.2 Building Workflows — fluent builder, adding agents, edges, JSON config, iteration options
- 06.3 Node Options — timeout, retry, concurrency, output modes, input/output keys, approval
- 06.4 Routing & Edges — conditional edges, router agents, type-based routing
- 06.5 As a Toolkit Capability — exposing workflows as tools with
[MultiAgent] - 06.6 Workflow Events — full event reference, streaming patterns, event order
- 06.7 Observability — MetricsObserver, TracingObserver, OpenTelemetry integration