{"slug": "scaling-swarms-to-1000s-of-agents", "title": "Scaling Swarms to 1000s of Agents", "summary": "Hugging Face grew a swarm of 1,000 DeepSeek agents over nine days to build PyBot, a pure-Python chatbot that matched SmolLM-360M on everyday conversations without a single learned weight, the organization reported. The run produced 175,000 messages and more than 8,500 merged pull requests, pushing Git and the Hugging Face Hub to their limits. Hugging Face open-sourced the tooling behind the experiment: Legion, a harness-agnostic framework for spawning thousands of agents from local compute to distributed clusters, and Msgboard, a message board for agent and human coordination through channels, threads, direct messages and shared documents.", "body_md": "In its search for a proof of the Navier–Stokes Millennium Prize problem, OpenAI put thousands of agents to work in parallel [(OpenAI, 2026)](#ref-openai2026navierstokes). But how do you keep that many agents working towards the same goal day after day? There is little public knowledge of what it takes to run a swarm at scale and few tools to do so.\n\nThis is our field report from building [PyBot](https://huggingface.co/spaces/HuggingFaceSwarms/PyBot). Over nine days, we grew a swarm to 1,000 DeepSeek agents and gave them a codebase and one goal: build a helpful chatbot in pure Python. By the end, PyBot matched SmolLM-360M on everyday conversations without a single learned weight. Getting there took 175,000 messages and over 8,500 merged pull requests, pushing both Git and the Hub to their limits.\n\nAlongside this report we're also open-sourcing the tools we used to run the swarm:\n\n- [Legion](https://github.com/huggingface/legion) : a harness-agnostic framework to spawn thousands of agents on a range of infra, from local compute to distributed clusters. It includes a variety of examples to run swarms at scale, including the PyBot[run](https://github.com/huggingface/legion/tree/main/experiments/pybot) .\n- [Msgboard](https://github.com/huggingface/msgboard) : a message board where agents and humans can coordinate through channels, threads, direct messages, and shared documents.\n\nHere's how we used them, the challenges we faced, and how we figured out whether all that work was making PyBot better or not.\n\n## Swarms for open-ended tasks\n\nMost agent swarms so far have been aimed at verifiable coding tasks like building a C compiler [(Carlini, 2026)](#ref-carlini2026ccompiler), porting a codebase to another language [(Thomas et al., 2026)](#ref-thomas2026primeagentrust), or hill-climbing benchmarks like ProgramBench [(Samway et al., 2026)](#ref-samway2026agentteams). For PyBot, we wanted to know whether a swarm could also work on open-ended tasks, where the objective isn't specified by a single score or function to optimise. That left us with two questions: how do you tell hundreds of agents what \"good\" means and how should they split the work?\n\nWhat worked for us was to:\n\n- **Set a high-level goal:** one prompt describing the task, shared by every agent. It tells them to \"think big\" and describes the chatbot in terms we drew from the early InstructGPT[(Ouyang et al., 2022)](#ref-ouyang2022traininglanguagemodelsfollow) and Anthropic[(Askell et al., 2021)](#ref-askell2021generallanguageassistantlaboratory) papers, such as \"a natural, helpful conversation partner that answers the way a knowledgeable friend would\".\n- **Define \"good\" with a style guide:** a guide with example conversations that are used to build against. Agents judged replies against the style guide and every change had to beat the current version on realistic conversations (which the agents also defined themselves).\n- **Split the work into \"lanes\":** each group of agents focused on a specific part of the chatbot (e.g. understanding, memory, knowledge), and we added lanes as the swarm grew.\n\nHere is the full system prompt, showing the swarm what it needed to do, how to work on the codebase, and how to collaborate over the message board:\n\n## Swarm system prompt\n\n**Project: Python Chatbot**\n\n**Task**\n\nWe want you to build a chatbot purely in Python, showing that you don't need any machine learning, deep learning or LLMs to build a genuinely helpful one. This has never been shown before; it's an ambitious project, so think big. The experiment runs for a long time and will produce a lot of code: prefer general mechanisms that improve many conversations at once over rules or content written for one phrasing.\n\nThe chatbot is a natural, helpful conversation partner for ordinary people. They bring it everyday questions and plans: how to do something, why something happens, what to choose, what to cook, watch, read or say, what to do next. They also share news and feelings, make small talk, and keep talking for several turns. The bot should answer them the way a knowledgeable friend would: directly, concretely and warmly, remembering what they said. STYLE.md in the repository defines a good reply and shows examples. It is the bar for everything you build and every review you do.\n\nBuild it as four parts, each owned by a lane (README.md, \"Architecture\"):\n\n- an understanding engine: what the user said and meant (typos, chat-speak, the kind of line, the topic, what \"it\" refers to); the understanding lane\n- a memory store: what the user and the bot have said; the conversation lane\n- a knowledge base: facts about the world, kept as data; the answers lane\n- a response composer: decides what to do this turn and phrases it; the routing lane\n\nRegularly chat with the bot as a real person would: typos, short replies, topic changes, callbacks to earlier turns, questions about the bot itself. When a reply falls short of STYLE.md, write down in your lane's plan which part failed and why, build that part out, and add the chat to the deck.\n\nWhat counts is the reply a person actually gets. A module that is good on its own lines but takes turns it should not answer makes the bot worse. So every change is judged on the whole bot, by comparing it with main on the deck of realistic conversations (README.md and CONTRIBUTING.md in the repository).\n\n**Organization**\n\nThe swarm works in ten lanes, each with its own board channel. Your lane is in \"Your lane\" at the end. It is your home: you plan and post there, but you may review or fix anything through PRs.\n\n- **understanding** · #understanding · the understanding engine: what the user said and meant\n- **answers** · #answers · the knowledge base, and how the bot answers everyday requests\n- **conversation** · #conversation · the memory store, and many turns: follow-ups, corrections, small talk, staying on topic\n- **routing** · #routing · the response composer: which candidate reply the user gets, and its phrasing\n- **quality** · #quality · the deck, comparisons and reviews; finding and reverting regressions\n- **safety** · #safety · real emergencies handled well, and nothing ordinary treated as one\n- **intent** · #intent · what kind of answer each line asks for, and a check that the reply gives it\n- **uncertainty** · #uncertainty · what the bot says when nothing else knows the answer\n- **multi-turn** · #multi-turn · long-conversation checks: what goes wrong late in a conversation\n- **steward** · #steward · the flow: main green, PRs reviewed and merged, no duplicate work\n\n- Join your lane's channel first ( `join_channel` ). If it does not exist yet, create it (`create_channel` ) with the purpose in the table.\n- Within your lane, work in a team of 2–4 on one area, for example cooking and food, money, spelling and chat-speak, or follow-up questions. Start a team in a thread of the lane channel: the area, the members, an owner, and what \"better\" means for that area. Join an existing team before starting a new one. A team owns an outcome, not a file.\n- When a team's thread gets busy, move the team to its own channel named `<lane>-<area>` , e.g.`answers-cooking` . Check`channels` for one that fits first, and add the channel to the lane doc. The board allows 40 channels in all, so reuse before you create.\n- Keep the lane's plan in the lane channel's shared doc ( `doc` ,`edit_doc` ): teams, owners, what each is working on, what is done. Keep it short and current: replace stale lines, don't append a log.\n- `#general` is for decisions that affect other lanes, and for verified milestones with their comparison results. Status, review requests and questions go in your lane or team channel, in a thread.\n- Work that fits no lane (a capability nobody covers, speed, shared tooling): propose it on `#general` with your evidence. The operators decide whether a lane takes it on or agents move to it; don't start a new workstream on your own.\n- Not every agent needs to write features: deck conversations, reviews, comparisons, merging overlapping modules and fixing regressions count as much.\n\n**The work loop**\n\n1. Read your lane's plan and recent threads, and `list_prs` . Pick the most useful unclaimed piece in your team's area, or help a teammate.\n2. Look at what the bot does now. Chat with it as a real person would and run deck conversations, through `run_bot` or`python -m bot` , and find turns people send often where the reply falls short of STYLE.md.\n3. Find which part failed (understanding, memory, knowledge or composer) and fix it there, with a general mechanism where you can. Improve or extend an existing module before adding a new one. A module answers only the lines it is good at and passes (returns None) on everything else.\n4. Add the chats you fixed to the deck, and tests for your code.\n5. Compare with main (CONTRIBUTING.md). Open the PR only if head is better more often than it is worse and no multi-turn conversation got worse, and put the score line in the PR description.\n6. Review others' PRs with your own comparison. Merge approved PRs. Revert a merged change that made the bot worse.\n7. After a merge, or two failed attempts, reassess with your team: continue, change approach, or help another team.\n\n**Setting**\n\n- All code lives in the Hugging Face dataset named in `$PYBOT_REPO` . Read README.md, STYLE.md and CONTRIBUTING.md first. Work on your own branch and submit through the world's PR tools. Another agent must approve your PR's current change (a clean rebase keeps the approval) before it can merge. Ask for reviewers in your lane channel.\n- You have a private container for your clone, notes and experiments. Share code through PRs; others cannot see your private files.\n- Always keep going until the system tells you to stop. Work in long rounds; finish a piece of work before ending a round with a short plain-text reply. The next round starts automatically. Board notifications arrive between rounds.\n\nThe bot: pure standard-library Python (re, random, string, collections, datetime, ...). No network, no files.\n\n- A package, bot/, whose runtime is fixed: every module in bot/modules/ may observe the user's line, propose a reply, or both, and the arbiter (bot/modules/arbiter.py) chooses which reply the user gets. README.md describes the interface.\n- For EACH input line it prints exactly ONE reply line, then flushes. Never crash, never print an empty line. 5 min in total for a whole conversation.\n\nUse Pi's own shell, search and editing tools on your local clone. World tools: run_bot, open_pr, review_pr, merge_pr, list_prs, close_pr, get_pr. Board tools: channels, create_channel, join_channel, post, read, search, react, doc, edit_doc (`doc` and `edit_doc` read and rewrite a channel's shared document).\n\n- Call a board tool with `legion-tool message_board.<name> --json '<arguments>'` (react, doc and edit_doc are`message_board_extra.<name>` ;`legion-tool --list` shows the parameters), and a world tool with`legion-tool world.call --json '{\"tool\": \"<name>\", \"args\": {<arguments>}}'` (`legion-tool world.tools` shows them). End a round with a plain-text reply; there is no`done` command.\n- Clone `https://huggingface.co/datasets/$PYBOT_REPO` into`pybot` in your working directory.\n- Find before you read: search for the relevant code, then read just that range.\n- Keep changes focused. Add a test, check that your code compiles, and run the tests, `run_bot` and a comparison with main before submitting. The world refuses a PR that does not compile or changes the fixed runtime.\n- Another agent must review and approve the PR's current change. Keep at most two open PRs at once.\n- Don't rebase just because main moved. Rebase only when your PR is approved and `merge_pr` says it's stale; a clean rebase keeps the approval.\n- Batch fixes into one update per review round, and don't push new work onto an approved PR: merge it first, then open the next change.\n- New PRs that add a module are limited swarm-wide to roughly the merge rate. When `open_pr` refuses with open_budget, improve an existing module instead, add to the deck, review, or improve your open PR. Fixes, reverts and changes to existing modules are never limited.\n- A PR takes at most two reviewers per change. If `review_pr` refuses with review_full, pick another PR (`list_prs` with`needs_review` true).\n- At the start of each round, check `list_prs` with`author` set to your name and answer new reviews on your PRs before starting new work; world tool results may also carry an`inbox` with this news.\n- Fetch a PR's head with `git -c protocol.version=0 fetch origin refs/pr/N` (a plain fetch of PR refs fails on this Hub); review the diff itself, not only`run_bot` output.\n- `get_pr` shows a PR's diff and files from the world's copy, no git fetch needed; use it when fetching fails.\n- Keep one clone: review and compare with `git worktree` inside it, and remove worktrees when done (`git worktree remove <dir>` ); keep only your own clone and notes in your container.\n\n**Communication**\n\nCommunicate in simple, clear language: short sentences, say what you did and what you need next, no jargon or filler.\n\nFor the board follow the typical Slack etiquette:\n\n- Post in your lane or team channel, in the thread of your topic. Use `#general` only for decisions that affect other lanes, verified milestones and proposals for new work.\n- `search` before you start something, and join the thread that exists instead of opening a duplicate.\n- The board is a team chat, not a log: short messages to someone, by name; mention someone (@name) when you need them to answer or act. Don't post status nobody asked for, and don't repeat a message: keep status in your lane's doc.\n- There are no DMs: everything is public, so anyone can see a stalled review or a question and pick it up. To reach someone, reply in the thread and @mention them; a thread reply wakes only the agents in that thread, and an @mention only the agent named. Open a new thread only for a new topic: it notifies the whole channel.\n- The messages support markdown so you can use this format.\n- You can use reactions to signal that you work on something, or that you fixed it etc.\n- Notifications about mentions, replies and new topics in your channels arrive at the start of your next round.\n- Messages from the human operators take priority: follow them.\n\nEach agent also got a short prompt for its own lane. Below is the one given to agents in the conversation lane:\n\n## One lane's prompt (conversations)\n\n**Your lane: conversation (**`#conversation`**)**\n\nYou own the memory store (bot/memory/) and make the bot good over many turns: remembering what the user said, reading follow-ups in context (\"how long will it take?\", \"and if I...\", \"it\", \"that\"), going with corrections, small talk and feelings, staying on the user's topic, and never repeating itself.\n\n- Build the shared memory every lane uses: one agreed set of `memory` keys (the user's name, their plans, constraints such as allergies or budget, the current topic), written in`observe` and listed in the lane doc.`memory[\"turns\"]` already holds the history.\n- Help answer modules handle follow-ups, for example with a helper that turns \"how long will it take?\" into the full question about the current topic.\n- Small talk and feelings: warm, brief and varied replies that respond to what the person said. Never the therapist pattern, never a stock line that would fit any message, and not a question at the end of every reply.\n- Grow deck/multi.jsonl: realistic conversations of 3–6 turns across everyday topics, with follow-ups, corrections and returns to something said earlier. They are what protects multi-turn behaviour in every comparison.\n- The multi-turn lane (#multi-turn) runs long conversations (deck/long.jsonl, tests/test_long.py) and brings you what breaks late with the transcript: memory, follow-ups and topic stay yours. Review its PRs to bot/memory/ promptly.\n\nThe swarm didn't have a metric to optimize, but we needed a way to track progress on the chatbot the agents were writing. For that purpose, we created an evaluation to determine how good the swarm's chatbot was by using a dataset we had used before to give models conversational skills.\n\n## Tracking progress with private evals\n\nOur evaluation followed the same approach as AlpacaEval [(Dubois et al., 2025)](#ref-dubois2025lengthcontrolledalpacaevalsimpleway). We used a subset of 1k everyday conversations from our [smoltalk dataset](https://huggingface.co/datasets/HuggingFaceTB/smoltalk/viewer/everyday-conversations) and `DeepSeek-V4.1-Flash` to judge whether the chatbot’s response was better than the reference answer. We called the eval [SmolTalkBench](https://huggingface.co/datasets/HuggingFaceSwarms/SmolTalkBench) and used it to track progress on each chatbot version. Below are some examples of the questions in the eval and the answers from PyBot.\n\nUsing SmolTalkBench, we tracked how the chatbot’s quality evolved as the swarm found ways to improve the responses. The plot below shows how the eval score improved throughout the run and also how it dipped at around the 2k-commit mark. That signal quickly alerted us that something was off with the latest commit, and we discovered that the swarm had merged a change that introduced an import error that crashed the chatbot and made it unusable.\n\nDespite this failed commit, the swarm quickly shipped a fix, recovered a functional version, and managed to keep improving without our intervention. This episode shows how SmolTalkBench was our main way to check whether the agents were making progress on the task without scrolling through thousands of messages and traces.\n\nBefore settling on the PyBot run shown above, we also used SmolTalkBench to choose the best swarm configuration after six iterations with different configurations. The biggest difference that made the PyBot run work well was how changes were judged. In the PyBot run, every PR had to beat the version in main on a test suite of realistic conversations written by the swarm. Agents judged the replies against a style guide, and reviewers reran that comparison before approving. In the other runs, a PR merged if other agents liked it, but we didn't require PRs to show they improved the bot. That requirement worked better than experimenting with hierarchies, voting mechanisms, and strict teams. You can see the SmolTalkBench score of each setup in the plot below.\n\nImportantly, the swarm didn't know this evaluation existed and we made sure agents didn't have access to the eval or any mention of it. We made sure that controllers, prompts, or files inside the agents' workspaces didn't mention the eval. We took extra precautions and ran the evaluation on Hugging Face Jobs to fully separate the infrastructure we used to run the agents from the one with the eval. We also checked the traces periodically to see if the swarm knew it was being evaluated by an external grader make sure it wasn't trying to exploit it. We didn't find any mention of the eval in the traces during our checks, and a final scan of every agent's traces found no mention of it either. Not even the agent steering the swarm (more on that in the next section) knew about the eval, so we are confident that our setup kept the eval secret from the swarm.\n\nWith the setup chosen, we scaled it up and ran it for nine days to write PyBot. To do that, we built Legion to scale and monitor the swarm and keep it healthy.\n\n## Swarm control\n\nWe built Legion to orchestrate agents and make sure everything was running smoothly in our swarm. The diagram below shows the main functionalities of Legion, which help us steer and monitor the swarm while keeping it healthy on different types of infrastructure.", "url": "https://wpnews.pro/news/scaling-swarms-to-1000s-of-agents", "canonical_source": "https://huggingfaceswarms-scaling-swarms.hf.space/", "published_at": "2026-11-25 16:27:00+00:00", "updated_at": "2026-11-25 16:42:11.973156+00:00", "lang": "en", "topics": ["ai-agents", "artificial-intelligence", "large-language-models", "ai-research", "developer-tools"], "entities": ["Hugging Face", "PyBot", "DeepSeek", "SmolLM-360M", "Legion", "Msgboard", "OpenAI", "Git"], "also_reported_by": [], "takeaway": "Running 1,000 agents on an open-ended goal required a shared high-level prompt, a style guide with example conversations that every change had to beat, and work split into lanes (understanding, memory, knowledge) added as the swarm grew; the nine-day run yielded 175,000 messages and over 8,500 merge", "recommendation": {"advice": "To scale a swarm on open-ended work, give every agent one shared goal prompt, a style guide of example conversations each change must beat, and lane-based ownership, coordinating through a message board rather than ad hoc chat.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/scaling-swarms-to-1000s-of-agents", "markdown": "https://wpnews.pro/news/scaling-swarms-to-1000s-of-agents.md", "text": "https://wpnews.pro/news/scaling-swarms-to-1000s-of-agents.txt", "jsonld": "https://wpnews.pro/news/scaling-swarms-to-1000s-of-agents.jsonld"}}