Building a Multi-Agent Workflow with Microsoft Agent Framework in C#
A single agent can do a lot. Two agents that hand off cleanly can do more, and you don't have to invent message routing to make it work.
You shipped a single-agent assistant that pulls data and drafts a report in one go. The output is fine. The prompts are getting fat. One system message is now trying to be researcher, fact-checker, and copywriter all at once, and the quality is starting to drift in obvious ways. Splitting roles helps. The trick is splitting them without writing your own message broker, which I've done, twice, and would not recommend.
Why separate agents at all
A specialist beats a generalist on long tasks. Same is true for prompts. A research agent focused on "find sources, return structured facts" outperforms a single mega-prompt that's also trying to write prose. Multi-agent workflows let you compose specialists instead of cramming everything into one system message.
Think of it like a newsroom. One person digs up the facts. A different person writes the copy. They communicate through a shared notepad, not by reading each other's minds. Agent Framework gives you that notepad.
Two agents handing off
var researcher = new ChatAgent(
name: "Researcher",
instructions: "Find three relevant facts about the user's question. " +
"Return them as JSON: { \"facts\": [\"...\", \"...\", \"...\"] }.",
model: "gpt-4o-mini",
tools: new[] { Tools.FromType<WebSearchTool>() });
var writer = new ChatAgent(
name: "Writer",
instructions: "Given JSON facts, write a 120-word briefing in plain prose.",
model: "gpt-4o-mini");
var workflow = new SequentialWorkflow("ResearchAndWrite",
steps: new IWorkflowStep[]
{
new AgentStep(researcher, output: "facts_json"),
new AgentStep(writer, input: "facts_json")
});
var run = await workflow.RunAsync(new { question = "Why did the SR-71 retire?" });
Console.WriteLine(run.FinalOutput);
Why it works
Each agent has one narrow job. The framework owns the wiring. The output/input mapping is the notepad: researcher writes JSON, writer reads it, neither agent needs to know anything about the other's prompt. The blast radius of a bad prompt edit is one agent, not the whole workflow. Big improvement when you're iterating fast.
When to use multi-agent
When a single prompt has more than two clear responsibilities, or when output quality lives or dies on a step that benefits from a different model (cheap for triage, smart for the final word). Also when you need human-readable intermediate outputs for auditability. Compliance teams love a fact table they can read.
When not to
Short user-facing chat. The latency tax kills the UX. Also avoid it when the "two agents" are actually one agent with two prompts you haven't bothered to merge yet. Multi-agent should reduce complexity, not make a procedural pipeline sound more impressive in standup.
Workflow shape
sequenceDiagram
participant U as User
participant W as SequentialWorkflow
participant R as Researcher
participant Wr as Writer
U->>W: question
W->>R: question
R->>R: web_search
R-->>W: facts_json
W->>Wr: facts_json
Wr-->>W: briefing prose
W-->>U: FinalOutputConclusion
Open your fattest single-agent prompt and draw a line through it between the "find" parts and the "phrase" parts. If you can name the two halves, you have your first multi-agent workflow waiting. Spin it up in an afternoon, measure quality and latency, and only then decide if it earned its keep.