Multi-Agent Systems: How to Build and Train AI Teams
Learn how to build and train multi-agent systems, measure whether communication helps, and reproduce a practical four-agent experiment with a shared model.

How to Build and Train a Multi-Agent AI System That Works
Multi-agent AI systems are easy to describe and hard to evaluate. Put a few models into different roles, let them trade messages, and it's tempting to call that "cooperation." But a bigger team usually means more tokens, more context to process, and more ways to wander off-task. And a higher success rate doesn't automatically tell you why it improved - maybe the system just got more chances to try.
One way to make the problem concrete is to start small: four agents, one shared model, private inputs that each agent has to work with, and an answer you can verify automatically. That setup lets you see what the agents learn, how expensive communication is, and whether performance improves compared with a reasonable baseline.
This article walks through the design choices behind that experiment, the reinforcement-learning method used to train the team, what the results do (and don't) prove, and how to run a shorter reproduction. The goal isn't to assume swarms are better. It's to help you test it.
Why do multi-agent systems need careful evaluation?
A multi-agent system can help when a task naturally breaks into pieces that can run in parallel, or when no single agent has access to all the information it needs. But adding agents isn't free. Each agent uses compute, and messages add context that other agents then have to process. Sometimes a team looks better simply because it had more attempts.
That matters in real deployments. If an agent team reviews more code, searches more documents, or generates more proposals than a single model, then a higher raw success rate may just reflect a bigger budget. The system might still be worth using - but you should understand what's driving the improvement before you scale.
Compare systems at an equal budget
Imagine four agents each tackling the task on their own. If you have a reliable verifier, the chance that at least one attempt is correct can be higher than a single attempt. That's a useful baseline for parallel retries, but it doesn't tell you whether the agents learned from one another.
To compare more fairly, keep the total budget the same. If the team gets a fixed number of tokens, compare that against a single agent using the same token allowance. Then measure success, token use, and result quality. The outcome depends on both the task and the model: splitting work can help, but coordination overhead can erase the savings.
The same caution applies to "big" published demos. OpenAI's reported large-scale mathematical-agent work and Anthropic's vulnerability-finding experiments sparked a lot of interest in agent cooperation. But scale by itself doesn't prove that communication drove better outcomes. In one analysis of coordinated vulnerability search, the agents found more bugs largely because they searched more code and used more tokens; when the comparison was restricted to the same code areas and token budgets, the picture was more limited.
Treat agent count as a system variable
A practical evaluation should track at least four things:
- Task success: Did the system produce an answer that passes a verifier or human review?
- Total cost: How many tokens, GPU hours, or dollars did the full run consume?
- Coordination overhead: How much context and time went into messages, tool calls, and resolving conflicts?
- Quality at a matched budget: Does the team beat a simpler baseline when both get comparable resources?
In product settings, you'll often also care about latency and reliability. A system that's slightly more accurate but several times slower may not work for a customer-facing workflow. The point is to evaluate the whole setup, not only the final answer.
How should you design a small agent swarm?
The experiment uses four agents that share one small language model. Each agent has its own context and receives one private integer in the range 1 to 99. Everyone knows the task and the agents' names, but at first no one knows the other agents' numbers. The team has to return the four numbers in ascending order, keeping duplicates.
For example, if the private inputs are 5, 26, 5, and 78, the correct output is [5, 5, 26, 78]. The team is considered successful if at least one agent produces the complete correct list. The task is intentionally simple: it's easy to check, and the information needed to solve it is split across agents.
Choose a structure that fits the question
There are two common starting structures. A hierarchical team uses an orchestrator that assigns subtasks to workers, collects results, and produces the final answer. This tends to fit analysis and research workflows, where you can give one agent a "lead" role to manage the process. Anthropic's research setup is one example of that kind of pattern. Kimi's PARL approach also shows that you can train an orchestrator while leaving subagents unchanged; a multi-agent system doesn't automatically mean updating every model.
A distributed team lets peers exchange information without a single agent assigning every step. The number-ordering experiment uses this structure. It tests whether agents learn when to message, what to share, and when they already have enough information to answer.
Neither approach is universally better. Hierarchies often make control and debugging easier, but the orchestrator can become a bottleneck. Peer-to-peer setups avoid one decision-maker, but coordination can get harder to reason about as the team grows. Pick the simplest structure that lets you evaluate the behavior you care about.
Make communication an action, not an assumption
In the experiment, agents can either send a direct message or broadcast to the team. They can also check whether a notification arrived and then read their inbox. That distinction matters: a message doesn't magically become useful context. The agent has to notice it, pull it in, interpret it, and act on it.
This also isolates a key limitation. Without communication, no agent can reliably infer the other private assignments. So this setup tests whether a shared policy can learn to exchange information. It does not prove that a swarm beats a single agent on a task that one agent could solve on its own. If you want to answer that "matched-budget, single-agent vs team" question, you need a separate experiment - and you shouldn't infer it from this one.
How do you train agents to communicate?
Multi-agent reinforcement learning gives you a workable framework for this. In the simplest case, one agent observes the environment, takes an action, and gets a reward. For a team, each agent sees only part of the state, while the group receives a shared outcome. That's similar to a decentralized partially observable Markov decision process: agents act with limited views, but they're trying to hit the same objective.
There are three practical challenges here. First, agents change as they learn, so teammates become moving targets. Second, credit assignment is tricky because a shared reward doesn't say which action helped. Third, communication changes what other agents know, so choosing when to talk and what to send is part of the behavior the training needs to learn.
Use a shared team reward
In the experiment, the team gets a reward only if it produces the correct list. If the team succeeds, the reward is reduced based on how many tokens it generated; if it fails, the reward is zero. The total allowance is 36,864 generated tokens: four agents, each with 8,192 work tokens and 1,024 final-answer tokens.
The reward is:
success × (1 − 0.25 × min(1, generated team tokens / 36,864))
A correct team that uses half its allowance, for instance, earns 0.875. There's no extra reward just for sending messages. The incentives push agents to solve the task while keeping token use down, rather than "communicating because it sounds smart."
For each problem, training collects eight independent team attempts. Rewards are normalized within that set: attempts that do better than the group average get a positive advantage, and worse attempts get a negative one. Every agent in an attempt receives the same team advantage, even if that agent's own answer was wrong. This is a straightforward shared-credit approach, but it doesn't pinpoint which agent or which message caused the success.
Train one policy across separate agent contexts
All four agents use one shared Qwen3-0.6B policy, not four separately trained models. Each agent still has its own context and private input. That keeps the number of trainable models small, while letting the policy learn a repeatable communication strategy.
Training follows centralized training with decentralized execution. During training, the system updates the shared policy using the team outcome. During each episode, every agent acts from its own context and incoming messages, without seeing the full team state.
The implementation uses TRL's asynchronous Group Relative Policy Optimization workflow. Each agent's generated tokens become a training row, with incoming messages and tool results included as context. Loss is averaged within a team, then averaged across teams - so a long conversation doesn't automatically give that team more weight than a short one.
This design is practical, not magical. Shared reward can teach useful coordination patterns, but it can also reward the right combination by luck. That's why training metrics should be paired with held-out evaluation and with checks on communication behavior. Success is the target; message count is a diagnostic, not proof.
What did the four-agent experiment show?
In the recorded experiment, training ran for 75 updates. Success rose from 6.6% across the first five updates to 82.3% across the final five. At checkpoint 75, the trained team solved 26 out of 32 held-out problems (81.25%). The underlying paper reports 93.2% success for four agents after 200 updates, so the 75-update result looks like an intermediate checkpoint rather than a final ceiling.
Token use dropped at the same time. Average generated tokens per team fell from about 12,827 in updates 1-5 to 8,026 in updates 71-75, a 37.4% reduction. Messages per team increased from 3.48 to 6.28, and broadcasts increased from 2.38 to 5.73.
| Training metric | Updates 1-5 | Updates 71-75 |
|---|---|---|
| Success rate | 6.56% | 82.34% |
| Generated tokens per team | 12,826.9 | 8,026.0 |
| Messages per team | 3.48 | 6.28 |
| Broadcasts per team | 2.38 | 5.73 |
| Teams with one broadcast per agent | 4.06% | 18.20% |
More messages alongside fewer tokens isn't contradictory. Agents can share information in a way that cuts down redundant reasoning or repeated attempts. Still, token totals include reasoning and tool calls as well as the message bodies, so message count alone can't explain the savings. The measurements suggest the team learned a more active sharing pattern, but they don't tell you every causal detail.
Separate learning from the benefit of retries
In this task, no agent can solve everything alone. So the closest retry baseline is an untrained team that just gets multiple attempts. Across the first five updates, the best of eight untrained-team attempts solved 37.5% of problems and used about 103,000 generated tokens per problem. The trained team in updates 71-75 solved 82.3% with one attempt and about 8,000 tokens.
That difference is big, but it's worth reading carefully. These numbers come from training problems, not a held-out comparison, and updates 2-5 already reflect some degree of training. So this is evidence that training helped in this setup - it's not a universal claim that trained swarms beat single agents at equal budgets.
The run used one H200 for training and seven H200s for rollout generation. The shorter walkthrough uses two GPUs and fewer updates. Compute requirements will vary with hardware, software versions, rollout concurrency, and pricing. The source experiment estimated roughly five hours and about $50 for a smaller run, but you shouldn't treat that as a fixed current cost.
How can you reproduce the experiment?
A practical reproduction needs a Hugging Face account with Jobs access, a storage bucket for outputs, and access to suitable GPUs. In the walkthrough, the shared model is served with vLLM on one GPU, and trained on the other. It evaluates the base and trained checkpoints on the same held-out problems, then saves scores, training metrics, the model checkpoint, and the exact TRL revision.
The walkthrough uses 50 updates and 128 teams per update. That's an approximate setting because TRL packs micro-batches by token count rather than by team. The original experiment used 75 updates and 256 team attempts per update. Those differences affect scale and implementation details, including the system prompt, so expect comparable behavior rather than an exact numerical match.
Follow a reproducible run sequence
- Create a fresh results bucket. Use a distinct bucket for each run so earlier experiment artifacts don't get mixed together.
- Pin the code and dependencies. Record the TRL commit and use the versions specified in the walkthrough. Agent-training code changes quickly; without a recorded revision, it's hard to diagnose differences.
- Evaluate the base policy. Run the untrained model on the held-out task before training. This gives you a baseline using the same evaluator and problem set.
- Train the shared policy. Run the asynchronous GRPO example for 50 updates using the two-GPU job configuration. Track success, messages, and generated tokens at each update.
- Evaluate the checkpoint. Run the trained model on the same 192 held-out problems used for the base evaluation. Compare success and inspect individual attempt logs, not just the overall percentage.
- Save artifacts and inspect the run. Keep the checkpoint, evaluation files, training dashboard data, and the code revision together. That makes the reproduction useful beyond a single number.
The shorter run took about 4.8 hours on two H100s in the reported walkthrough and reached 60.9% held-out success at checkpoint 50. Treat that as a reference point, not a guarantee: GPU availability, implementation changes, and random sampling can shift outcomes. If you want something closer to the longer experiment, plan for more rollouts and a higher job timeout, which means a noticeably larger compute bill.
Decide what the result should justify
Before you copy the approach into a business workflow, decide what counts as a real improvement. For code review, you might track verified defect discovery per dollar, using the same repositories and token budget. For document analysis, you might track accuracy on a fixed set of cases, plus latency and the rate of unsupported claims.
Keep the first evaluation focused. Compare a single-agent baseline, independent parallel attempts, and a communicating team. Match budgets where you can, use a held-out test set, and log enough detail to understand why failures happen. If communication boosts accuracy but doubles cost, that might still be worthwhile for high-impact work - and a terrible idea for high-volume, low-stakes tasks.
Conclusion
The useful takeaway from this experiment isn't "you should always use a swarm." It's that communication, compute, and task structure need to be evaluated together. In this setup, a four-agent team pooled private information, increased success on a checkable task, and used fewer generated tokens in later training. Those results support a workable training approach - not a guaranteed advantage over single-agent systems.
Start with a task you can verify, set a budget, and establish a baseline before adding agents. Then measure whether communication improves results enough to justify its cost. If the team can't beat a simpler system under the conditions that matter to your product, more agents usually isn't the next step.