Short answer: a multi-agent system is a set of AI agents, each with its own job, tools and instructions, that work on one task together. Something decides which agent runs when (a router, a planner or plain code), the agents share state or pass messages, and the results are combined into one answer. To build one, start with a single agent, split it only where jobs need different tools or can run in parallel, and keep the orchestration in code you can test.
Updated 13 November 2026. This guide replaces our earlier posts "How to Build Multi-Agent Systems" and "Multi-Agent Systems in the AI World".
Multi-agent systems usually start the same way. One agent works well. Then it gets more tools, a longer prompt and more jobs, and it starts picking the wrong tool or forgetting half the question. Splitting it up seems obvious. Splitting it up well is the hard part.
This guide covers what a multi-agent AI system actually is, how one works, the common architectures, and a step-by-step way to build your own from scratch.
What is a multi-agent system?
A multi-agent system (MAS) is a system where several autonomous agents work in a shared environment, each acting on its own information, toward individual or shared goals. The idea is decades older than large language models: "agents and multiagent systems" is an established research field with its own conferences, covering robotics, simulations, trading and logistics.
In AI applications now, the term usually means something more specific:
- Each agent is an LLM with a role. Its own instructions, its own tools, and often its own model.
- The agents cooperate on one request. A support question, a research task, a lead to qualify.
- Something coordinates them. That's either another agent (a router or planner) or ordinary code.
So a "multi-agent AI system" is closer to a small team than to a crowd. One agent classifies, one looks up data, one checks policy, one writes the reply.
How does a multi-agent AI system work?
Strip away the vocabulary and every working multi-agent system has the same five parts:
- Agents. Each one does one job well, with only the tools that job needs.
- Coordination. Decides who runs next and in what order. In production systems this is mostly code, with a model making one decision (for example "what kind of question is this?").
- Shared state. Facts the agents need from each other: the plan, intermediate results, the customer ID from the session. This lives outside every prompt.
- Communication. How work and results move between agents. Inside one process that's a function call. Across services it's a message to an agent's ID.
- Tracing and limits. A record of which agent did what, plus caps on steps, time and cost. Without this, multi-agent systems are close to impossible to debug.
Single agent or multi-agent?
More agents means more model calls, more latency and more places for things to go wrong. Split an agent only when at least one of these is true:
| Split when… | Why it helps |
|---|---|
| Different jobs need different tools | Fewer tools per agent means fewer wrong tool choices and a smaller blast radius |
| Different jobs suit different models | A small model can classify; a stronger one can write the customer-facing reply |
| Parts of the work are independent | Two agents in parallel finish sooner than one doing both in turn |
| One prompt is trying to do everything | Short, specific instructions per role are easier to test and tune |
If none of these apply, keep one well-scoped agent. A single agent with three good tools beats three agents with vague jobs.
Common multi-agent architectures
Almost every multi-agent system is built from a handful of shapes:
- Router + specialists. A small agent classifies the request; code sends it to the right specialist. Cheap and predictable. This is the one we'd start with.
- Pipeline. Agent A's output is agent B's input. Research, then draft, then check.
- Parallel fan-out + merge. Several agents work on the same input at once; a final step combines their answers. Good when a question needs facts from more than one place.
- Planner + subagents. A planning agent writes a to-do list; subagents each take one item with a fresh context. This is what people call a deep agent.
- Supervisor (hierarchical). A supervisor agent decides, turn by turn, which worker acts next. Flexible, but less predictable and harder to cost.
The first three put the decisions in code. The last two let a model decide more. In our view that order is also the order of how easy they are to run in production. Multi-agent orchestration patterns goes deeper on each.
How do agents communicate with each other?
There are two levels, and it's worth not mixing them up.
Inside one workflow, agents don't need a messaging system. The orchestrating code calls one agent, reads its result and passes what's needed to the next. Shared state (ctx.state in a DNotifier workflow) holds facts that several agents read. This is the simplest and most common case.
Across services, agents talk by sending messages. One agent might run on the team's server that owns the order data; another might be written in Python on a GPU machine. Each gets an ID, and the workflow sends work to that ID and waits for the reply. In DNotifier these are called remote agents, and the realtime layer that delivers messages to users is the same one that carries messages between agents.
Free-form agent-to-agent chat ("let the agents talk until they agree") makes good demos. In production it's hard to bound: you can't predict how many turns it will take or what it will cost. If you need agents to negotiate, give the conversation a turn limit and a referee step in code.
How to build a multi-agent AI system from scratch
Here's the order we'd build one in. The code uses DNotifier's JavaScript SDK; the steps apply to any stack.
Step 1: Get one agent working first
Build the single agent with the tools it needs, scoped to the signed-in user, with a step limit and tracing on. If you haven't done this yet, How to Build an AI Agent walks through it. Every later step reuses this agent unchanged.
Step 2: Find the split
Look at real traffic. In a store's support chat, for example, a big share of messages may be general policy questions ("how long do returns take?") that don't need order access at all. That's a split: a policy agent with no tools at all, and the existing order agent.
Step 3: Add a router that only classifies
const textOf = (res) => res?.data?.content ?? res?.content ?? "";
const intentAgent = DNotifier.defineAgent({
name: "intent-agent",
async run(ctx) {
const res = await ctx.sendAI({
message: {
useKnowledgeBase: false,
messages: [
{ role: "system", content: 'Classify the message. Reply with JSON only: {"intent":"order"|"policy"|"other"}' },
{ role: "user", content: String(ctx.input) },
],
},
saveHistory: false,
label: "Classify intent",
});
try {
return { intent: JSON.parse(textOf(res)).intent ?? "other" };
} catch {
return { intent: "other" }; // the model ignored the JSON instruction
}
},
});One model call, one word out, no tools. The router never answers the customer, so it can't say anything wrong to them.
Step 4: Put the orchestration in a workflow
export const support = new DNotifier.Workflow({
name: "support-router",
observability: true,
async entry(ctx) {
const { intent } = await ctx.runAgent("intent-agent", { input: ctx.input });
ctx.state.intent = intent;
if (intent === "policy") return ctx.runAgent("policy-agent", { input: ctx.input });
if (intent === "order") {
const { results } = await ctx.runAgents([
{ name: "order-help", input: ctx.input },
{ name: "policy-agent", input: ctx.input },
]);
return mergeDrafts(ctx, results); // one short ctx.sendAI call; facts about the order win
}
return { answer: "I can help with orders, deliveries and refunds. What would you like to check?" };
},
}).registerAgents({ "intent-agent": intentAgent, "order-help": orderAgent, "policy-agent": policyAgent });Notice what decides the path: an if, not a model. You can read every route in one screen and write a test for each. The full, runnable version of this workflow (with the policy agent, the merge step and React and Flutter clients) is How to Build a Multi-Agent Workflow.
Step 5: Move an agent to another service when you need to
If the policy agent should run somewhere else, register a reference instead of the agent. The entry function doesn't change:
.registerAgents({
"intent-agent": intentAgent,
"order-help": orderAgent,
"policy-agent": { receiverId: "svc-policy-agent" }, // runs on another service
});Step 6: Add limits and read the traces
Give every tool agent a maxToolRounds, cap input length at your API, and keep observability: true on the workflow. Each run then shows up in the dashboard as separate steps: the router's decision, each specialist's tool calls and the merge. When an answer is wrong, the first question is always "which agent?", and the trace answers it.
Real-world multi-agent use cases
- Customer support. Router, order agent, policy agent, merge. Policy questions skip the agent that can read customer data.
- Lead qualification. Research and fit-check agents in parallel, a score in plain code, a person approving the first email. See How to Build an AI Workflow in Code.
- Research and comparison. A planner splits the question; subagents research one part each; a writer combines the summaries.
- Operations. One agent watches events, one diagnoses, one drafts the incident note for a human to send.
Challenges teams run into
For the backend patterns behind these challenges, see scalable architecture for AI agents.
For the coordination problems behind these failures, read about shared context and conflict resolution.
- Cost and latency add up. Every agent is at least one model call. Measure per request before and after a split.
- Errors travel. A wrong classification sends the request to the wrong specialist. Log the router's decision and review a sample of them every week.
- Loops. Agents that can call each other freely can ping-pong. Keep routing in code, or put a hard turn limit on it.
- Context gets lost between agents. Pass explicit, small inputs (an order ID, a summary), not whole conversations.
- Security gets wider. Each agent's tools are a permission boundary. Give each agent only the tools it needs, and keep user identity in your session, never in a prompt.
Which platform should you use for multi-agent systems?
Whatever platform you pick, here's how to build AI agent infrastructure underneath it.
There are two broad kinds of tool:
- Frameworks such as LangGraph, CrewAI and the OpenAI Agents SDK give you building blocks in a library. You host the runtime, the tracing and the integrations yourself, or buy the vendor's hosted add-ons.
- Platforms such as DNotifier run the agent loop, workflows, permission checks and tracing as a service, with an SDK in JavaScript, Python and Dart. You write the agents and the orchestration in your own code.
If you already run a framework in production and it's working, there's no reason to switch for the sake of it. If you're starting out and don't want to host the plumbing, a platform gets you to a traced, permission-checked multi-agent system faster.
Build one: router, two specialists, parallel agents and a merge step, with React and Flutter clients. How to Build a Multi-Agent Workflow · Create your app · Workflows
FAQ
What is a multi-agent system?
A system where several autonomous agents, each with its own role, information and tools, work in a shared environment. In AI applications today it usually means several LLM-based agents cooperating on one request, coordinated by a router, a planner or code.
What is a multi-agent AI system and how does it work?
It's a set of LLM agents with separate jobs. A coordinator (often plain code with one classification step) decides which agents run, they share state or pass messages, and a final step combines their results. Each agent has only the tools its job needs.
How do I build a multi-agent AI system from scratch?
Build one working agent first. Split it only where jobs need different tools, different models or can run in parallel. Add a router that only classifies, put the orchestration in a workflow written in code, then add limits and tracing so you can see which agent did what.
How do AI agents communicate with each other?
Inside one workflow, the orchestrating code passes results from one agent to the next and keeps shared facts in workflow state. Across services, agents have IDs and exchange messages; the workflow sends work to an agent's ID and waits for its reply.
What platform should I use for multi-agent systems?
Use a framework such as LangGraph or CrewAI if you want a library and are happy to host the runtime and tracing yourself. Use a platform such as DNotifier if you want the agent loop, workflows, permissions and tracing run for you while you write the orchestration in your own code.
When should I not use multiple agents?
When one agent with a few well-described tools already handles the job. Splitting adds model calls, latency and debugging work, so only do it when the jobs need different tools or models, or can run in parallel.



