swarm-mesh
Use when multiple perspectives are needed on the same work — every agent reviews every other agent’s output. Also use when security-critical code, complex algorithms, or multi-domain changes need peer review from multiple angles.
| Model | Source |
|---|---|
| opus | pack: swarms |
Full Reference
Swarm — Mesh Topology
Section titled “Swarm — Mesh Topology”Full peer review. Every agent reviews every other agent’s work. Consensus required before any output is accepted. High-trust, high-quality — at the cost of O(N²) reviews. Hard limit: N ≤ 4. More agents means exponentially more reviews; beyond 4, switch to hierarchical with selective review.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Pattern | Every agent reviews every other agent |
| Review count | N × (N-1) |
| Hard limit | N ≤ 4 |
| Phases | Phase 1: parallel work → Phase 2: cross-review |
| Revision cycles | Max 2, then escalate |
| Speed | Slowest topology — use only when quality demands it |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Understand the topology diagram and review matrix | reference/topology-and-review-matrix.md |
| Implement Phase 1 dispatch and Phase 2 cross-review | reference/implementation.md |
| Know when to use mesh vs other topologies | reference/when-to-use.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.
Agent Teams
Section titled “Agent Teams”For heavy multi-domain tasks, mesh agents can be organized into Agent Teams — small groups of 3-5 agents that collaborate with a shared collaboration_mode before cross-reviewing each other’s output.
When to use Agent Teams:
- Task is
heavyweight (5+ files, multi-domain, parallelizable) - Work spans domains that benefit from both specialization and peer review
- You need consensus across perspectives before accepting output
Team size: 3-5 agents. Below 3 is just peer review. Above 5 is exponential review overhead — switch to hierarchical.
Configuration:
{ "collaboration_mode": "peer_review", "agents": [ { "role": "security-reviewer", "focus": "auth flows and input validation" }, { "role": "architect", "focus": "data model and API design" }, { "role": "implementer", "focus": "code correctness and test coverage" } ]}Flow:
- Phase 1 — each agent works independently on assigned domain
- Phase 2 — every agent reviews every other agent’s output (
collaboration_mode: peer_review) - Consensus — all agents must agree before output is accepted
- Max 2 revision cycles, then escalate to hierarchical
Announcement
Section titled “Announcement”┏━ ⚡ swarm-mesh ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ [one-line description of what’s being peer-reviewed] ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛