How multi-agent systems work: a practical primer
TL;DR
It is the easiest pattern to build, test, and debug; move to pub-sub only when decoupling is needed.
Every agent must read from and write to a single source of truth, not its own private context.
Typed, versioned message contracts stop malformed outputs from cascading through the system.
Design pause-and-review checkpoints so that a timeout results in no action, not automatic approval.
Combine sandboxed simulation, replay tests, and chaos injection to cover correctness, performance, and safety.
A multi-agent system (MAS) is a network of AI programs, called agents. Each one does a specific job. Together they handle work that is too big for any single agent. Google Cloud notes these systems can scale to very large numbers of agents sharing one environment.
Four building blocks make up every one of them:
- Agents. Autonomous programs with a goal, tools, and memory.
- Orchestrator. The control layer that routes tasks and enforces rules.
- Shared state. A single source of truth (database, cache, or message store) all agents read from and write to.
- Tools. APIs, functions, and data sources agents call to take action in the world.
That is the shape of it. The rest of this article goes deeper: architectures, how agents talk, planning, testing, and a build checklist you can use.
Think of a professional kitchen. The head chef (orchestrator) does not cook every dish. They hand out tasks, check quality, and time the service. Each cook (agent) owns one station. If the sauce chef calls in sick, you swap that one person. The kitchen stays open. NVIDIA's glossary uses the same analogy, and it holds up in practice.
A MAS earns its keep when your problem has at least one of these traits:
- Task decomposition. The work can be split into distinct, parallel subtasks.
- Scale. Volume is too high for one process to handle sequentially.
- Heterogeneity. Different subtasks need different models, tools, or data sources.
- Open-ended workflows. The sequence of steps is not fixed in advance.
Real examples. A robotics fleet where each robot owns a zone. A client onboarding workflow where one agent pulls the data, one drafts the documents, and one checks the work. A game world where hundreds of characters act on their own. That extract, draft, review shape is the one most business workflows end up in. You can see more on scaling output without extra headcount.
Now the honest trade-off. A MAS costs you real complexity. Debugging gets harder. You have to build the tooling to watch it. Safety problems spread instead of stopping. If one well-prompted model can do the job, use one well-prompted model.
What are the core components of a multi-agent system?
Every MAS uses the same parts, no matter how big it gets.
Agents are the workers. Each agent has:
- A goal (what it is trying to achieve).
- Tools (functions it can call: APIs, databases, search, code execution).
- Memory (short-term context in its prompt window; long-term memory in a vector store or database).
- Autonomy (it decides how to use its tools to reach its goal, within guardrails).
The environment is everything outside the agent. Shared databases, message queues, external APIs, and whatever the other agents produce. Agents read the environment through sensors (querying a database, polling an API, receiving a message) and change it through actuators (writing a row, calling an API, sending a message).
Shared state is the single source of truth, and it is the part teams get wrong most often. Give each agent its own private context and the system drifts. One agent invents a fact the others never saw, and the rest build on top of it. A shared database or message store stops that at the root.
Goal and knowledge representations can be as simple as a JSON object or as involved as a structured memory store. For most builds, a normal database holds the state and every agent reads it before it acts.
A minimal agent loop looks like this:
while task_not_complete:
observation = sense(environment) # read shared state, receive message
plan = think(observation, goal) # LLM call with tools listed
action = select_tool(plan) # pick the right tool
result = act(action) # execute the tool call
learn(result) # update memory or shared state
Pro Tip: Put your validation and safety checks in the orchestration code, never in the model prompt. The model suggests. Your code decides whether it runs. That boundary matters more than any other choice you make in an agentic build.
What MAS architectures should you know about?
IBM names four main structures: centralised, decentralised, hierarchical, and holonic. Each trades control against resilience.
Centralised (star/orchestrator). One orchestrator takes every request and routes it to the right specialist. Easy to debug, because every decision passes through one place. The cost is a single point of failure, and that orchestrator eventually becomes your ceiling.
Decentralised (mesh). Agents talk straight to each other. No controller. It survives individual failures well. It is also much harder to watch and much harder to test. Only go here once distributed tracing is already running.
Pub-sub (publish-subscribe). Agents publish events to named channels. Other agents subscribe and react. Producers stop caring who consumes them. A message broker handles ordering and delivery. Good for high-volume pipelines where you want to add or drop an agent without rewiring anything.
Hierarchical. A top-level orchestrator hands work to sub-orchestrators, which manage their own specialists. This one fits approval and escalation workflows, because authority maps onto the tree the way an org chart does.
Holonic. Agents form nested groups (holons) that look like one agent from outside. Useful at very large scale, when you want to treat a cluster as a single unit.
| Architecture | Control | Observability | Single point of failure | Ease of testing | Scaling behaviour |
|---|---|---|---|---|---|
| Centralised | High | High | Yes | Easy | Vertical |
| Decentralised (mesh) | Low | Low | No | Hard | Horizontal |
| Pub-sub | Medium | Medium | No (but the broker is) | Moderate | Horizontal |
| Hierarchical | High | High | Partial | Moderate | Vertical + horizontal |
| Holonic | Medium | Medium | Partial | Moderate | Horizontal |
Pro Tip: Start centralised. It is the easiest pattern to build, test, and reason about. Move to pub-sub when scale forces you to split producers from consumers. Add mesh last, and only once distributed tracing is live.
What to weigh when you pick one:
- Latency. Centralised adds one hop; pub-sub adds broker latency.
- Fault tolerance. Decentralised patterns survive individual agent failures better.
- Debuggability. Centralised systems produce cleaner logs and traces.
- Scaling. Pub-sub and mesh scale horizontally; centralised scales vertically until the orchestrator becomes the bottleneck.
Our multi-agent system patterns explainer covers these structures in more detail. The Devwiz team also has a build-side view of multi-agent systems written for founders scoping a software project.
How do agents communicate and coordinate with each other?
Communication is where most MAS builds fall over. Typed payloads and explicit return formats are what stop one bad output from taking down everything behind it.
Message schemas. Treat every message between agents like an API contract. Define the fields, the types, and the version. Use JSON. Reject anything malformed at the boundary, before it reaches the next agent. This is the same discipline tool-calling already asks for: Anthropic's tool use docs show what a typed schema and a structured error look like in practice, and the Model Context Protocol standardises the same idea across tools and data sources.
Communication topologies map straight onto the architectures above:
- Star. All messages go through the orchestrator. Simple, auditable.
- Pub-sub. Agents publish to channels; subscribers react. Decoupled and scalable.
- Mesh. Direct agent-to-agent calls. Flexible but hard to trace.
Coordination mechanisms decide who does what:
- Master-orchestrator routing. The orchestrator reads the task and assigns it to the right agent based on capability or availability.
- Auction-based assignment. Agents bid on tasks based on their current load or confidence score. The orchestrator awards the task to the winning bidder.
- Consensus protocols. Multiple agents vote on an output before it is accepted. Useful for high-stakes decisions where a single agent's error would be costly.
- Negotiation primitives. Agents exchange proposals and counter-proposals to reach agreement on shared resources or task boundaries.
Here is how that runs in a document workflow. The extract agent reads the source and publishes a structured payload. The plan agent takes it, splits the work, and assigns each piece. The review agent checks the draft against a schema, then either approves it or sends it back with a reason a machine can read.
Pro Tip: Validate schemas at every boundary, not just on the way in. Have your tools return typed error objects, not raw exception strings. An agent that gets a typed error can recover. An agent that gets a stack trace just guesses.
How does planning and learning work across multiple agents?
Single-agent planning is simple. One model decides, one model acts. Planning across several agents is harder, because they have to stay out of each other's way without doubling up or contradicting each other.
Planner-worker pattern. A planner agent takes the top-level goal, splits it into subtasks, and hands each one to a worker. Workers run in parallel where they can. Results come back to the planner, which pulls them together and picks the next move. Anthropic's engineering team calls this the orchestrator-workers workflow, and rates parallelisation as one of the highest-value patterns available when subtasks are genuinely independent.
In pseudocode:
goal = receive_task()
subtasks = planner.decompose(goal)
results = parallel_execute([worker.run(t) for t in subtasks])
final_output = planner.aggregate(results)
Multi-agent reinforcement learning (MARL). Here agents learn by acting in a shared environment and collecting rewards. Each one updates its own policy from its own experience. The catch is that every agent keeps changing the environment the others are learning in, so the ground never sits still. MARL is worth the pain when:
- Agents must adapt to each other's behaviour over time (robotics, game AI, trading simulations).
- Simple coordination rules cannot cover the full range of situations.
- You have a simulation environment to train in safely before deploying.
For a business workflow, MARL is almost always overkill. Fixed rules plus a planner-worker pattern get you most of the value at a fraction of the cost.
Parallelisation patterns:
- Sectioning. Split the input into chunks; each agent processes one chunk.
- Voting. Multiple agents produce independent outputs; a meta-agent or simple majority rule selects the best.
- Evaluator-optimiser. One agent produces output; another scores it; the first revises based on the score.
Pro Tip: Build a stopping condition into every agent loop. Cap the iterations. Set a timeout. Put a human gate in front of anything you cannot undo. Give that gate three real actions (approve, reject, edit) and make the timeout do nothing by default.
Hands-on orchestration design checklist
Run this before you write a line of agent code. These are the decisions that cost the most to reverse later.
Step-by-step build checklist
- Define the goal. Write one sentence describing what the system must achieve and how you will measure success.
- Map the roles. List every agent you need. Give each one a name, a single responsibility, and a list of tools it is allowed to use.
- Define role boundaries. Decide what each agent is NOT allowed to do. Boundaries prevent agents from overstepping and creating conflicts.
- Design shared state. Choose a single source of truth: a database, a message store, or a structured cache. Every agent reads from and writes to this store.
- Write message schemas. Define the input and output format for every agent. Use typed JSON. Version your schemas from day one.
- Choose your architecture. Start with a centralised orchestrator unless you have a specific reason not to.
- Set up observability. Add structured logging and distributed tracing before you run the first end-to-end test. You cannot debug what you cannot see.
- Add human-in-the-loop gates. Identify every action that is irreversible or high-risk. Add an explicit pause-and-review checkpoint before each one.
- Write tests. Unit-test each agent in isolation. Write integration tests for each handoff. Run end-to-end tests in a sandboxed environment.
- Define fault behaviour. Decide what each agent does when it receives a malformed input, a tool error, or a timeout. Default to safe-fail.
Prototyping tips
- Build the simplest possible version first: one orchestrator, two agents, one tool each.
- Test each agent in isolation before connecting them.
- Add agents incrementally. Do not build the full system before testing the core loop.
- Use replay tests (feeding recorded inputs back through the system) to catch regressions early.
This is the same order our 90-day program runs in. Explore, Map, Transform. We map the IP you already own, prototype the first agents against it, then build the orchestration around them with observability and human gates in from day one. The output is a working prototype and a scaling roadmap, not a slide deck.
The point worth holding on to: the agents are only the visible part. What makes a MAS worth building in a consulting or education business is that your judgment stops living in your head and starts living in the system. Each agent carries a piece of how you decide. Together they become an AI Operating System, a set of AI employees that run your delivery without you sitting in every loop. That is the difference between automating a few tasks and lifting your ceiling.
Pro Tip: Put your hardest gate in front of anything that sends a message, moves money, or changes a record you cannot restore. If the human gate times out, the system does nothing. Never let silence count as a yes, and build that default into the orchestration layer, not the prompt.
Which tools and frameworks help you build a MAS?
No single tool covers the whole stack, so you are assembling rather than buying.
Start with the build surface. We use Claude Code as the primary one, and it is the tool we put in front of every client on the program. It gives you agent definitions, tool schemas, and orchestration as plain files you can read, version, and hand to someone else. That matters more than it sounds. A founder who is not a developer can sit down and describe an agent's job, its boundaries, and its tools in a file, then watch it run. Our guide on custom AI delivery systems with Claude Code walks through what that build looks like, and Claude Code for non-technical founders covers the starting point if you have never shipped software.
Around that, the supporting categories:
- Orchestration frameworks. Libraries that handle agent routing, tool calling, and workflow state. You get planner-worker and sequential pipelines without writing them. Pick one that supports typed tool schemas and validates structured output.
- Managed agent runtimes. Hosted services that handle agent execution, retries, and state persistence without you managing the infrastructure. Useful when you want to focus on agent logic rather than ops. See what managed runtimes mean for your build.
- Message brokers (pub/sub). Services like cloud-native queue systems that handle event delivery, ordering, and fan-out between agents. Use these when you move to a pub-sub architecture.
- Simulation environments. Sandboxed worlds where agents can act, fail, and learn without touching production. Non-negotiable for robotics, game AI, and anything where training on live data is unsafe.
- Observability tools. Distributed tracing, structured logging, and metrics dashboards. Without these, debugging a multi-agent system is guesswork.
- Testing frameworks. Tools that let you replay recorded agent interactions, inject failures, and assert on structured outputs.
Practical mapping:
| Tool category | Primary use case |
|---|---|
| Orchestration framework | Business workflow automation, document pipelines |
| Managed agent runtime | Production deployments needing reliability and retries |
| Message broker | High-throughput pipelines, event-driven architectures |
| Simulation environment | Robotics, game AI, MARL training |
| Observability stack | All production MAS, mandatory from day one |
| Testing framework | Regression checks, safety validation |
Start with a build surface and a plain database for shared state. Add a message broker when volume actually demands one, not before. Keep simulation away from production, always.
How do you evaluate and test a multi-agent system?
Testing a MAS is harder than testing one model. An error can start in any agent, any tool call, or any handoff between them. You need layers.
Core metrics to track:
- Throughput. Tasks completed per unit of time.
- Latency. End-to-end time from task submission to final output.
- Success rate. Percentage of tasks completed correctly without human intervention.
- Conflict rate. How often two agents produce contradictory outputs or attempt to modify the same resource simultaneously.
- Resource utilisation. CPU, memory, and API call costs per task.
- Safety incident rate. How often an agent attempts or completes a high-risk action without proper authorisation.
Testing methods:
- Sandboxed simulation. Run the full system against synthetic inputs in an isolated environment. No production data, no live API calls.
- Replay tests. Record real inputs and agent outputs, then replay them to check that the system produces the same results after a code change.
- A/B experiments. Route a percentage of real traffic to a new agent version and compare metrics against the control.
- Chaos and failure injection. Deliberately kill agents, return malformed tool outputs, and introduce network delays to verify that fault behaviour is safe.
| Test type | Risk category addressed |
|---|---|
| Sandboxed simulation | Functional correctness, safety |
| Replay tests | Regression, functional correctness |
| A/B experiments | Performance, quality |
| Chaos/failure injection | Fault tolerance, safety, security |
Pro Tip: Automate your regression tests and run them on every change. Give every request a unique ID that travels through each agent, each tool call, and each log line. When something breaks, you want the full chain in front of you in seconds, not after an afternoon of grep.
What are the risks, limitations, and ethical considerations?
A MAS brings risks a single model never had. Learning them now is cheaper than meeting them in production.
Limitations:
- Non-determinism. The same input can produce different outputs across runs. This makes debugging and regression testing harder.
- Scaling bottlenecks. A centralised orchestrator becomes a throughput ceiling as agent count grows. Pub-sub helps, but adds its own complexity.
- Emergent conflicts. Agents optimising for their own goals can produce system-level behaviour nobody designed. This is especially common in MARL systems.
- Observability gaps. Without deliberate tracing, it is impossible to know which agent caused a failure in a long chain.
Security concerns:
- Malicious agents. A compromised or poorly designed agent can inject bad data into shared state, affecting every downstream agent.
- Compromised tools. If an agent's tool (an API, a database connection) is compromised, the agent will faithfully execute malicious instructions.
- Data leaks. Agents with access to sensitive data can inadvertently include it in outputs sent to less-trusted agents or external systems.
- Permission boundaries. Every agent should have the minimum permissions it needs. An agent that only reads data should never have write access.
Ethics and governance:
Accountability is the hard one. In a long chain, working out which agent caused a decision is genuinely difficult, and "the system did it" is not an answer a regulator accepts. If you run in the UK, the ICO's guidance on automated decision-making and profiling applies the moment your MAS makes or heavily shapes a decision about a person. Audit logs stop being good practice there. They become a legal requirement.
MIT Sloan's work on agentic AI makes the same point about guardrails: they belong in the architecture, not bolted on once the thing is already running.
Pro Tip: Default every agent to safe-fail. In doubt, do nothing and tell a human. Demand an explicit yes for anything you cannot undo, anything expensive, and anything that touches a real person. A timeout is not consent.
The honest truth about when MAS is worth it
Most teams reach for a multi-agent build too early. One well-structured agent with good tools and a clear prompt beats a sloppy five-agent system every time. The complexity is not free: more failure modes, more tooling to watch it, more surface to test.
When the problem really does need parallel specialists, though, a MAS is the right call. What works in practice is not making any single agent cleverer. It is giving each one a clear role, a typed contract, and a shared source of truth, then leaving them alone. The value comes from the system being manageable, not from the agents being impressive.
The teams that get this right start small. One orchestrator. Two agents. One real workflow. They measure it, find where it chokes, and add complexity only where the numbers ask for it. The teams that struggle draw the whole system on a whiteboard and try to build all of it at once.
Here is the test before you commit to a build. If you cannot describe the workflow your MAS will run in two sentences, you are not ready to build it. Start with the IP assessment and map what you already own. Architecture is the second question, not the first.
Useful sources
Where to go deeper, in the order we would read them:
- Anthropic: Building effective AI agents. The most useful engineering guide out there on workflow patterns: chaining, parallelisation, orchestrator-workers, and evaluator-optimiser.
- Anthropic: Tool use with Claude. How typed tool schemas and structured errors actually work at the API level.
- Model Context Protocol. The open standard for connecting agents to tools and data sources without writing a bespoke integration each time.
- IBM: What is a multi-agent system?. Good coverage of architecture types, including holonic structures and fault-tolerance trade-offs.
- Google Cloud: What is a multi-agent system?. A clear vendor-neutral definition, with useful framing on scale and specialisation.
- NVIDIA glossary: Multi-agent systems. Short, plain, and a decent first read if the concept is new.
- MIT Sloan: Agentic AI explained. Readable overview of planning, tool use, memory, and guardrails.
- ICO: Automated decision-making and profiling. The UK regulator's own guidance. Read it before you let a MAS make decisions about people.
- Wikipedia: Multi-agent system. The academic foundations, including reinforcement learning approaches and LLM-based MAS research.
Frequently Asked Questions
James Killick
Founder
The AI Orchestrator. 10+ years building digital products and 200+ apps shipped, now helping $1M+ educators and consultants turn their IP into AI-powered delivery systems.
James Killick founded and runs The AI Orchestrators.
More from James Killick