Multi-Agent Swarms
Multi-agent swarms let you decompose large tasks into a dependency graph of subtasks, each handled by an independent agent. CodeCLI orchestrates execution using wave-based DAG scheduling, worktree isolation, and automated merge strategies.
Architecture
A swarm is composed of three layers:
- Orchestrator — Decomposes the top-level task into subtasks, builds the DAG, and schedules waves
- Agent Pool — A set of worker agents that execute subtasks in parallel within each wave
- Merger — Collects results from all agents and merges changes back into the main working tree
Starting a Swarm
Wave Execution
The orchestrator analyzes dependencies between subtasks and groups them into waves. All tasks within a wave run in parallel. A new wave begins only when all tasks in the previous wave have completed.
Configuration
| Setting | Default | Description |
|---|---|---|
| maxConcurrentAgents | 4 | Maximum parallel agents per wave |
| timeoutPerAgent | 300s | Per-agent timeout |
| mergeStrategy | sequential-rebase | Merge approach: sequential-rebase, patch-merge, fail |
| worktreeIsolation | true | Isolate each agent in its own git worktree |
| onConflict | fail-and-report | Conflict resolution: fail-and-report, prefer-newest, prefer-oldest |
| retryFailedWaves | true | Retry failed tasks before aborting the swarm |
| maxWaveRetries | 2 | Maximum retries per failed task |
Merge Process
1
swarm/agent-{id}2
3
4
onConflict policy is applied5
!Warning
Swarm mode with worktree isolation creates multiple git worktrees. Ensure your disk has enough space for the additional checkouts. Each worktree is approximately the size of the full repository.