Skip to content

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    │
└──────────┘     └──────────┘     └──────────┘


                                    Output

When to Use Multi-Agent vs SubAgent

SubAgentMulti-Agent Workflow
AgentsOne child agentMany agents in a graph
StructureSimple delegationDirected pipeline or graph
RoutingNoneConditional edges, handoffs
Use whenOne specialized taskSequential 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

Released under the MIT License.