Skip to content

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.

ModelSource
opuspack: swarms
Full Reference

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.


ItemValue
PatternEvery agent reviews every other agent
Review countN × (N-1)
Hard limitN ≤ 4
PhasesPhase 1: parallel work → Phase 2: cross-review
Revision cyclesMax 2, then escalate
SpeedSlowest topology — use only when quality demands it

I want to…File
Understand the topology diagram and review matrixreference/topology-and-review-matrix.md
Implement Phase 1 dispatch and Phase 2 cross-reviewreference/implementation.md
Know when to use mesh vs other topologiesreference/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.


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 heavy weight (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:

  1. Phase 1 — each agent works independently on assigned domain
  2. Phase 2 — every agent reviews every other agent’s output (collaboration_mode: peer_review)
  3. Consensus — all agents must agree before output is accepted
  4. Max 2 revision cycles, then escalate to hierarchical

┏━ ⚡ swarm-mesh ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ [one-line description of what’s being peer-reviewed] ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛