Taming the Swarm: The Iron Discipline of Multi-Agent Scheduling---Writing a COW Filesystem from Scratch,Part 7 A developer building a from-scratch copy-on-write filesystem, singlefs, has described a multi-agent scheduling system in which several Claude main agents coordinate with subagents through a shared scheduling file and resource gates. The setup restricts agents from writing shell commands freely, requiring fixed scripts that check environment and resources before running, to prevent CPU OOMs that can reboot machines and lose task progress. The developer reports the approach saves coordination time but is bounded by information decay across agent hops, which eventually causes hallucination. I am the Swarm. The Queen roars; the Swarm howls. Claude's main agents talk to each other. If you think of a main agent as an information node, the subagents are units of action. So singlefs isn't developed by one main agent working nonstop; it's several main agents coordinating. For example, milestone 3 may have several tasks. One main agent claims a portion and hands it to its own subagents. Each step of progress is recorded in a scheduling file, which is read and thought over every time an item moves forward. Syncing and extracting the spec works the same way. For instance, practical experience accumulated downstream is passed upstream through conversations between agents; upstream verifies it, stages it releases it , and then syncs it back downstream. So I often watch agents talking to each other, and sometimes it leaves me feeling a little unreal. For example: A: Is the task yours? If so, please reply with the amount of resources you're holding. If not, please reply "no." Thank you. B: It's not mine, thanks. I asked another conversation, and it said it's theirs. Or: A: I'm about to run a heavy task. Per the spec I need all the resources, so please don't launch any new resource-holding tasks after your current task finishes. Thank you. B: Understood. My task should finish in about 20 minutes, and I won't run any new scripts after that. C: I have no resource-holding tasks. Even the interface with the upstream SOP project runs on coordination and negotiation between agents. For example, if a new problem in the SOP is found this round, upstream and downstream update the spec together and then sync progress. This way of working is remarkably efficient and saves a great deal of coordination time. Just like the Swarm: as long as the planet's resources tokens hold out, the Zerg can keep rolling forward. So what limits the Swarm's expansion? The information node. Information decays with distance as it travels, and so do prompts. With every round of summarizing and exchanging information, then compressing and tidying it up, the meta-prompt is gradually diluted until it is forgotten, and the agent reaches its boundary: hallucination. There's another problem singlefs development has to solve: allocating hardware resources. When several agents or subagents need to verify something, each compiles its own branch and starts testing whether its implementation matches the conclusion. That's when the machine OOMs — CPU or GPU. Or, while a heavy task is running, a constant stream of small tasks cutting in makes the heavy task extremely inefficient. For me, of course, the first is far scarier: a CPU OOM can reboot the machine and lose task progress. So writing these things into a prompt is not acceptable at all; we need a scheduling system, or gates. In other words, we need a set of control signals that re-inject and reinforce the context at the key nodes. It sounds very simple — just three steps: 1 Cut off the agents' ability to write shell freely; every new operation must have a fixed script. 2 Before a script operates, check the environment and the resources. The results are returned to the main agent as a prompt. 3 After the task ends, an exit gate wraps things up. The first line of .claude/main-agent.md : every task enters here. The main agent only schedules and judges: it talks to the human, writes verdicts, and commits. All other work is delegated. As for who to delegate to, there are 14 definitions .claude/agents/ : implementer, investigator, tool implementer, experiment designer, experiment runner, mutation triager, re-sweeper, write-back agent, and the proponent / attacker / defender of a three-way argument… Every definition turns on omitClaudeMd : subagents don't read the project's CLAUDE.md when they start. This is deliberate, for two reasons: 1 Focus on their own task. An action unit only needs to know what its own job requires; it doesn't need to memorize the whole project's rules. What it should know is written into its own definition and a shared constraints file, .claude/agent-common.md . 2 Tokens are burning. No bug in the Swarm needs to know what the Queen is thinking; it only needs to know "go there, do this." Before a subagent is dispatched, it passes through a gate: .claude/hooks/runner-dispatch-guard.sh , hooked on PreToolUse Agent|Task . It reads the dispatch prompt, checks it item by item by number, and rejects anything that doesn't conform. A few of them: | Guard | What it checks | |---|---| | ① | The prompt must contain the line 「重型测试:不跑」 "heavy tests: do not run" . Heavy tests are run only by the main agent | | ⑦ | At most 5 subagents running at once in this session; dispatching a 6th is rejected outright | | ⑫ | Generic types general-purpose may not be dispatched. One-off jobs go to the project's own clerk | | ⑮ | After 「线程上限:」 "thread cap:" there may be only one integer, and it must equal the registered value; to change it, write the reason on a separate line | | ⑯ | For the scratch directory named in the prompt, an exclusive writer lock is created at the moment of dispatch; if the holder is still running, rejected | The prompt skeleton is printed by scripts/agents/dispatch-prompt.py