Running a council of droids on the Factory Droid SDK
I built an orchestrator that decomposes a task into independent pieces, runs the pieces in parallel and merges the findings, on top of the Factory Droid TypeScript SDK. Measured against the same task on the same model, one droid beat it: 261 seconds, 10,311 credits and 57 passing tests, against 391 seconds, 82,550 credits and 60 tests for the council at concurrency 16. The cost model behind that result is the part worth publishing.
What the council actually is
Everything runs in one TypeScript process, council.ts, and one droid is one SDK run() call. Work happens in three phases. EXPAND walks the task breadth first and asks planner droids to split it into subtasks, then writes the plan to disk. EXECUTE drains the leaf queue through a fixed worker pool. REDUCE walks back up level by level, where a judge droid merges each node's children into one result.
Three roles carry the system. A planner splits one task into subtasks and is read only. A worker does one leaf task and owns only its own files. A judge merges reports into one authoritative answer.
Three invariants make it safe to scale.
- Droids never spawn droids. The orchestrator spawns, so one process owns every node and a single counter bounds the whole tree.
- The semaphore wraps the SDK call, never the recursion. A parent holding a concurrency slot while awaiting its children deadlocks at depth 2 or deeper, since every slot would be held by a waiting parent and none left for the child it waits on.
- Decomposition is separated from execution. Expand writes a plan, execute drains a flat queue, reduce walks back up. No parent blocks a child.
The second one is the bug I would have shipped: the obvious implementation puts the await on the semaphore around the whole recursive call, so every parent holds a slot while waiting for a child that cannot get one.
Setting it up and running it
The SDK needs its own key. A working droid exec login is not enough, so the key goes in a .env file at the repo root, which the npm scripts load with --env-file-if-exists:
npm install
echo "FACTORY_API_KEY=fk-..." > .env
npm run council -- "Build a Python package named textstat with exactly six independent modules, each with its own pytest test file: slugify.py, wordcount.py, truncate.py, normalize_ws.py, titlecase.py, strip_html.py. Add an __init__.py. No cross-imports between modules. Then run py -m pytest -q and report the exact pass and fail counts." --concurrency 16 --models glm-5.3-flash --cwd runs/team-fast --label team-fast
That last line is the measured run: 13 leaves at concurrency 16.
Three knobs decide the shape of a council. --leaves N caps leaf tasks and is the real size control. --concurrency N sets how many droids run at once. --agents N is a hard ceiling on total droid runs, a budget rather than a target. --depth and --fanout control how eagerly the tree splits. --plan-only runs the planners and stops, printing the node count, the leaf count and an estimated droid spend.
Every run writes its artifacts to --cwd, runs/<timestamp>/ by default. plan.json holds the node tree, board.md is the shared blackboard, answer.md is the merged result, and report.json records droids used, tokens, credits, duration and failures. events.jsonl is one JSON line per lifecycle event, each carrying elapsed milliseconds, the run label and a kind such as start, spawn, done, split, merge, board or covert, plus fields such as role, model, ms and inTok. npm run ui replays any run from that file.
One setup trap matters, because the symptom points elsewhere. The SDK and @factory/cli have to agree on a JSON-RPC protocol version. A stale CLI rejects session init, and the only visible effect is a 60 second timeout on every droid, indistinguishable from slow work. council.ts checks the CLI version at startup and refuses to run.
What it cost
Same task, same model (glm-5.3-flash at high reasoning), six modules with a pytest file each. Test counts were independently re-verified by running pytest afterwards.
| Single droid | Council at concurrency 6 | Council at concurrency 16 | |
|---|---|---|---|
| Wall clock | 261s | 631s | 391s |
| Droids | 1 | 44 | 46 |
| Credits | 10,311 | 96,094 | 82,550 |
| Tests passing | 57 | 51 | 60 |
For a task this size, one droid won. The council at concurrency 16 produced slightly more tests, and it was slower and roughly 8x more expensive. The concurrency 6 run was worse on every axis.
The reason is a fixed per-droid cost. Every droid pays a session init of 30 to 60 seconds before doing any work, so wall clock is roughly (droids / concurrency) × init + actual work. With 46 droids that startup term dominates completely. The event log shows the shape: at concurrency 16 the thirteen workers all started within about 30 ms of each other and finished as one solid block, while at concurrency 6 they came out as a staircase with six running at a time. Moving from 6 to 16 cut wall clock by 38% with no other change.
Concurrency is the first knob to turn, not the last. A council pays off when the work exceeds one context window: a repo-wide audit, 500 files to classify, many large independent workstreams. Splitting a task one droid can hold only adds startup cost.
Two details make the cost legible: disableBuiltinSkills: true on the SDK call shortens every session init, and --agents is a hard stop, so once the budget is spent the remaining leaves execute directly instead of failing.
The chart in docs/comparison.png uses three colours: purple planners, green workers, amber judges.
Both films are rendered from the real event logs, and the thirteen worker bars in the Loom cut are the real per-worker durations read out of runs/team-fast/events.jsonl. loom/renders/droid-council-loom.mp4 runs 60 s; video/renders/droid-council-sheet.mp4 runs 48.6 s and draws the same thirteen tasks as work done rather than wall clock. npx tsx export.ts writes a self-contained council-report.html that opens from disk with no server.
How the droids talked to each other
Information moves in two directions. Upward, every node returns a report to its parent, and judges are told to reconcile contradictions by naming a winner rather than averaging. Sideways, siblings share board.md, append only, read before write.
That sideways channel did real work in the measured run. The worker owning strip_html.py shipped a module with the text = html initialisation line missing, so it raised UnboundLocalError. The test worker hit 0 of 7 and posted that to the board. The module's owner read it, fixed the line, and wrote back that the seven tests should now pass. The judge's final report names that fix, and the suite finished at 60 passed.
No message bus, no vector store, no shared memory service. A file and a return value covered what needed to move.
A third channel, through the hardware
channel/ holds a working covert channel between two isolated processes on one host, unrelated to the droids. The receiver reads no file the sender wrote and opens no socket; what the two processes share is the silicon underneath them. The sender streams a 64 MB buffer from eight processes at once, evicting the 25.6 MB L3 of an i7-12700K, and the receiver times a dependent-load walk over a 4 MB buffer that would otherwise sit in that cache. While the hammers run the buffer is gone and the walk slows down. One slot becomes one bit.
Four candidates were measured before one held up. Raw DRAM throughput contention separated by 1.02x, no signal at all. Per-slot minimum walk latency gave a bit error rate of 0.50, because the receiver's own walking re-warms the cache faster than a 50 ms burst can evict it. A single hammer process was unreliable, 0.09 on one run and 0.38 on an identical later run. Streaming hammers with a lower-half-mean statistic separated by about 1.45x, and that is the one that works.
With 8 hammers, 100 ms slots, 5 slots per bit and 4 data bits per pilot block on that machine, the per-block level separation was 1.45x mean and 1.15x worst, six of eight single frames of 4 bytes decoded clean, and the payload rate was 1.11 bit/s, which is 32 payload bits inside 28.8 s. npx tsx channel/channel.ts bench --trials 8 measures the rate on your own machine, and --covert runs the relay as a phase before the council starts, writing the bytes sent and recovered into events.jsonl. The honest limits: about 1 bit/s, so a token or a digest rather than a conversation, and both sides must agree on a wall-clock start time out of band.
What I would do differently
Next time I would widen concurrency before adding leaves, and I would start every new task shape with --mode single to keep an honest baseline.
The reason is the init bill. Every droid pays it whether or not it does interesting work, so a council of 46 droids on a task one droid can hold is 45 units of pure overhead.
The remaining gaps are checkpoint and resume for a half-finished council, retry with backoff on rate limits, and cross-machine distribution. None of them change the three invariants.
Code, run logs and both films are in github.com/isHeSatoshi/droid-council. The three runs behind the table are published as runs/cmp-single/report.json, runs/team/report.json and runs/team-fast/report.json, so every number in the table can be checked against the run that produced it.