Training Small AI Agents to Work Together: Lessons from Hugging Face's Swarm Experiment

Four agents share one Qwen3-0.6B model and learn to pool private numbers. Team success rose from 6.6% to 82.3% while token use fell 37.4%. What the experiment shows, and what it does not.

Last updated

Training Small AI Agents to Work Together: Lessons from Hugging Face's Swarm Experiment

A small shared model can learn to cooperate. That is not the same as a swarm beating a single agent.

TL;DR

Hugging Face's Swarms, Flocks, Gangs: How to build, train, and evaluate multi-agent systems explores whether small language models can learn to cooperate effectively.

In its first experiment, four agents share a Qwen3-0.6B model, but each receives a different private number. They must exchange information so that at least one agent can submit the complete, correctly sorted list.

After 75 training updates, team success increased from 6.6% to 82.3%, while generated token use fell by 37.4%. The agents communicated more frequently, particularly through broadcasts, yet used fewer tokens overall.

The important caveat: this does not demonstrate that a swarm outperforms a single agent at the same compute budget. Instead, it shows that a small shared policy can learn useful communication, and that training can be substantially more effective than giving a poorly coordinated team more retries.

Why More Agents Are Not Automatically Better

Multi-agent systems are often presented as a straightforward way to improve AI performance: add more agents, let them collaborate, and expect better results.

The article challenges that assumption.

Adding agents also adds separate contexts, communication overhead, and more opportunities to spend tokens. Even when a team performs better, the improvement may come from making more attempts rather than from meaningful cooperation.

For example, four agents independently attempting a problem have more chances to find a correct answer than one agent making a single attempt, provided there is a reliable way to identify the correct result. But that does not establish that collaboration helped.

A more informative comparison asks:

At the same total token budget, can communicating agents outperform independent attempts or a single agent?

That is the larger question behind the blog series. This first experiment addresses a smaller prerequisite: can a small model learn to share information effectively in the first place?

The Setup: Four Agents, Four Private Numbers

The researchers built a simple information-sharing task inspired by s3: Simple Scaling of Swarms via Cooperative Multi-agent RL.

Each of four agents receives:

  • One private integer between 1 and 99.
  • The names of its teammates.
  • Instructions explaining the task and available communication tools.

The agents do not initially know one another's numbers. Their goal is to produce a sorted list containing all four values, preserving duplicates.

For example, if their private assignments are 5, 26, 5, and 78, the correct answer is:

[5, 5, 26, 78]

The team succeeds when at least one agent submits the complete, correct list. All four agents do not need to answer correctly.

This makes communication essential. An agent cannot reliably reconstruct the full list from its own number alone.

One Model, Not Four Separate Models

Although there are four logical agents, they all use the same Qwen3-0.6B policy.

Each agent has a separate context and private input, but training updates one shared set of model weights. The experiment is therefore about teaching a shared model how to act as a member of a team, not about independently training four different models.

The team is also decentralized: there is no designated leader assigning work or collecting answers.

How the Agents Communicate

The agents have three main communication tools:

  • message(to, text) to send information directly or broadcast it to everyone.
  • read_messages() to retrieve incoming messages.
  • check_notifications() to check whether unread messages exist.

This distinction matters because sending a message does not automatically place its contents into another agent's context. Recipients need to read their inboxes to use the information.

The model therefore needs to learn more than what to say. It also needs to learn when to send information, when to retrieve it, and when it has enough evidence to answer.

Communication is part of the behavior being trained, rather than a guaranteed benefit of connecting agents.

How Training Rewards Cooperation

The training objective combines task success with token efficiency.

A failed team receives zero reward. A successful team receives a positive reward that decreases with the number of generated tokens it uses.

Each team has an allowance of:

4 x (8,192 work tokens + 1,024 final-answer tokens)
= 36,864 tokens

The reward is:

reward = success * (
    1 - 0.25 * min(1, generated team tokens / 36,864)
)

A successful team using half its allowance, for example, receives a reward of 0.875.

There is no separate reward for sending messages. Communication is useful only insofar as it helps the team solve the task efficiently.

Comparing Eight Attempts at the Same Problem

For each training problem, the system collects eight independent team attempts. Their rewards are normalized within that group:

  • Attempts performing above the group average receive a positive advantage.
  • Attempts performing below the average receive a negative advantage.
  • All four agents within an attempt receive the same team-level advantage.

That last point introduces a familiar challenge in cooperative learning: credit assignment. An agent can receive a positive learning signal even if its own final answer was wrong, because another agent made the team succeed.

The setup follows the broad pattern of centralized training with decentralized execution: learning uses a shared team outcome, while each agent acts using its own available context.

The Results: Higher Success, Lower Token Use

The original experiment ran for 75 training updates. Comparing the first five updates with the final five shows a substantial improvement:

Training metricUpdates 1-5Updates 71-75
Team success rate6.56%82.34%
Generated tokens per team12,826.98,026.0
Messages per team3.486.28
Broadcasts per team2.385.73
Teams with exactly one broadcast per agent4.06%18.20%

At checkpoint 75, the trained team also solved 26 of 32 held-out problems, giving an 81.25% held-out success rate.

The token reduction is particularly notable: teams generated 37.4% fewer tokens per attempt late in training than early on.

However, that efficiency figure comes from training measurements. The authors did not retain held-out token-efficiency measurements for the trained checkpoint.

More Messages Can Still Mean Fewer Tokens

The agents became more communicative as training progressed. Both message counts and broadcasts increased, even as overall token consumption fell.

There is no contradiction here. Total generated tokens include reasoning and tool calls as well as message bodies. A team can send more messages while spending fewer tokens elsewhere.

The results therefore illustrate why message count alone is not a sufficient measure of communication cost.

They also do not show convergence to a perfectly clean protocol. Only 18.2% of late-training teams had every agent send exactly one broadcast. Performance improved substantially, but the communication pattern still had room to improve.

Is Training Better Than Simply Adding Retries?

The article also compares late-training performance with giving an early-training team more attempts.

Because answers are easy to verify, a problem can be counted as solved if any of eight attempts succeeds.

ApproachSuccess rateGenerated tokens per problem
Early-training team, best of eight attempts37.5%~103,000
Late-training team, one attempt82.3%~8,000

The trained team solved more problems in one attempt while using roughly one-thirteenth as many tokens.

That is a useful practical finding: repeatedly running a poorly coordinated team can be far less effective than training the team to coordinate.

Still, this comparison is an estimate rather than a clean held-out benchmark. Both rows use training problems, and the early-training window includes updates from a policy that had already begun learning.

What the Experiment Does, and Does Not, Prove

The strongest conclusion is narrow but meaningful:

A small shared language model can learn to pool private information across multiple agents, improving team success while reducing generated token use.

The experiment does not establish that:

  • Four agents outperform a single agent with the same total information.
  • Communication beats independent attempts at a matched compute budget.
  • Similar gains will automatically transfer to coding, research, or other open-ended tasks.
  • The learned communication pattern is optimal.

The central limitation is built into the task: essential information is distributed across agents. An isolated agent cannot reliably solve it, regardless of how many retries it receives.

That makes this a useful test of learned communication, but not a general demonstration of swarm superiority. The authors explicitly leave the matched-budget, single-agent comparison for later work on tasks that one agent can solve alone.

Reproducing the Experiment

The article includes a practical walkthrough using:

  • TRL for training.
  • vLLM for serving the shared policy and generating rollouts.
  • Hugging Face Jobs for execution.
  • Hugging Face Buckets for storing results and checkpoints.
  • Trackio for tracking training metrics.

The walkthrough uses two H200 GPUs: one serves the model, and the other trains it. It runs for 50 updates and evaluates the base model and trained checkpoint on the same 192 held-out problems.

A reported TRL run of this shorter configuration took about 4.8 hours on two H100s and reached 60.9% held-out success at checkpoint 50.

Those results should not be confused with the original 75-update experiment, which used one trainer GPU and seven rollout GPUs. The walkthrough is a smaller reproduction, and implementation details differ.

This also highlights a practical point: a small model does not necessarily mean a lightweight training workload. Multi-agent conversations can generate millions of tokens per update, with long contexts and repeated attempts.

Takeaways for Building Multi-Agent Systems

The article offers several useful lessons for anyone experimenting with agent teams:

  1. Start with a verifiable task. A simple environment makes it easier to determine whether communication actually contributes to success.
  2. Measure costs alongside accuracy. Higher success is less informative without token usage and a clear account of the available budget.
  3. Do not equate more messages with more overhead. Message frequency, message length, reasoning, and tool use all contribute differently to total cost.
  4. Distinguish training gains from retry gains. More attempts can improve results, but they do not demonstrate cooperation.
  5. Keep conclusions aligned with the benchmark. Learning to combine distributed information is an important result, but it is not the same as outperforming a single agent on a general task.

Final Thoughts

Hugging Face's experiment provides a concrete starting point for understanding trainable agent teams: four agents, one small shared model, a checkable task, and a reward that balances success with token use.

Its most interesting result is not simply that the agents improved. They became more successful and less token-intensive while communicating more actively.

The broader question remains open: when does cooperation offer an advantage over spending the same resources on one agent or on independent attempts? This first experiment does not settle that question, but it provides a reproducible way to study one of its foundations.


Based on "Swarms, Flocks, Gangs: How to build, train, and evaluate multi-agent systems", by Ben Burtenshaw and Kashif Rasul, published on Hugging Face on November 26, 2026.

References

  1. Ben Burtenshaw and Kashif Rasul, "Swarms, Flocks, Gangs: How to build, train, and evaluate multi-agent systems", Hugging Face, November 26, 2026.
  2. TRL: Transformer Reinforcement Learning, Hugging Face.
  3. vLLM, the inference engine used for rollouts.