Commit 6ec77e0
feat: swarm — big tasks decomposed across specialist agents running in parallel
run_team was one shallow round: up to three sequential delegations, no
dependencies, and no way for an agent to consult a peer mid-task. Fine for
"check X then answer", useless for "build me a thing".
aios_swarm.py adds a real swarm:
PLAN an agent turns the request into a DAG of subtasks, each assigned
to the specialist that suits it, with explicit dependencies
EXECUTE independent subtasks run CONCURRENTLY (ThreadPoolExecutor, wave by
wave); a subtask starts only once its deps have produced output,
and dependents receive those outputs as context
CONSULT a running agent can emit `ASK <agent>: <question>`, gets a real
answer back, and finishes with it — agents talking, not just
output chaining
SYNTHESIZE one agent reads the whole blackboard and writes the final answer
Triggered automatically for big asks on brain/team via a cheap heuristic so
ordinary chat never pays for a planning call, or forced with the 🐝 Swarm chip /
"swarm" target. A plan with one task is returned as a plain single-agent answer
rather than dressed up as a swarm. Live DAG in the dashboard's Swarm view, fed by
the same activity feed, plus GET/POST /api/swarm and `swarm.enabled` config.
The engine is injected with route/ask_llm/act so it never imports the hub back,
which also makes it testable against a stub router. Verified that way: peak
parallelism 2 on independent subtasks, correct dependency ordering, a real
consult round-trip (claudecode -> opencode -> claudecode), narrated-and-fenced
JSON still parsed, and a failing subtask unblocking its dependents instead of
deadlocking.
Two real bugs found while testing against live agents:
- llm_chat's 120s timeout was too short for claude-code, whose every call
cold-starts the Claude CLI. Planning is a big prompt and timed out, surfacing
as "no usable plan". Now 300s, overridable via AIOS_LLM_TIMEOUT.
- claude-code is an AGENT, not a chat model: given a planning prompt it replies
"I'll find and read the README..." or returns an empty body, so it is an
unreliable planner backend. The planner now puts its instructions in the user
turn (a long system prompt full of JSON braces reliably returned empty there),
retries once, and on failure reports it honestly instead of inventing a plan —
and the hub falls back to run_team so a swarm can never return a blank reply.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8939fc6 commit 6ec77e0
5 files changed
Lines changed: 400 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
86 | 92 | | |
87 | 93 | | |
88 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
478 | 478 | | |
479 | 479 | | |
480 | 480 | | |
| 481 | + | |
481 | 482 | | |
482 | 483 | | |
483 | 484 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
323 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
| |||
621 | 626 | | |
622 | 627 | | |
623 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
624 | 665 | | |
625 | 666 | | |
626 | 667 | | |
| |||
645 | 686 | | |
646 | 687 | | |
647 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
648 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
649 | 703 | | |
650 | 704 | | |
651 | 705 | | |
| |||
1446 | 1500 | | |
1447 | 1501 | | |
1448 | 1502 | | |
| 1503 | + | |
| 1504 | + | |
1449 | 1505 | | |
1450 | 1506 | | |
1451 | 1507 | | |
| |||
1692 | 1748 | | |
1693 | 1749 | | |
1694 | 1750 | | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
1695 | 1761 | | |
1696 | 1762 | | |
1697 | 1763 | | |
| |||
0 commit comments