Complex applications often require multiple specialized agents working together. The MAF orchestrator manages handoffs, context sharing, and sequencing.
import { Orchestrator, Agent } from "@microsoft/agents";
const triageAgent = new Agent({ name: "Triage", instructions: "Route to the right specialist." });
const billingAgent = new Agent({ name: "Billing", instructions: "Handle billing inquiries." });
const supportAgent = new Agent({ name: "Support", instructions: "Provide technical support." });
const orchestrator = new Orchestrator({
agents: [triageAgent, billingAgent, supportAgent],
defaultAgent: triageAgent,
});
// Agent can hand off
await orchestrator.handoff(triageAgent, billingAgent, { context: { userId: "123" } });
| Pattern | Description | Use Case |
|---|---|---|
| Router | Single entry agent delegates to specialists | Customer support |
| Pipeline | Agents process sequentially | Document processing pipeline |
| Debate | Multiple agents discuss, then synthesize | Decision support |
| Round Robin | Alternate between agents | Multi-perspective analysis |
When handing off between agents, context (memory, conversation history, state) should be explicitly passed.
await orchestrator.handoff(fromAgent, toAgent, {
context: {
conversationId: convId,
userProfile: await memory.get("user_profile"),
sessionState: { currentTask: "troubleshooting" },
}
});