mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
- Reorganize v3/ into implementation/ subfolders: - planning/, architecture/, migration/, integration/ - security/, adrs/, research/, swarm-plans/ - Add 15-agent concurrent swarm implementation plans: - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x) - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies - Update .claude/settings.json with proper hooks format - Add bash aliases for claude --dangerously-skip-permissions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
407 lines
10 KiB
Markdown
407 lines
10 KiB
Markdown
# Coordination Modes Guide
|
||
|
||
This guide explains the 5 coordination modes available for agent swarm orchestration and when to use each one.
|
||
|
||
## 🎯 Coordination Mode Overview
|
||
|
||
| Mode | Structure | Best For | Agent Count | Overhead |
|
||
|------|-----------|----------|-------------|----------|
|
||
| Centralized | Single coordinator | Simple tasks | 2-4 | Low (~50ms) |
|
||
| Distributed | Multiple coordinators | Parallel work | 4-8 | Medium (~100ms) |
|
||
| Hierarchical | Tree structure | Complex projects | 5-10 | Medium (~80ms) |
|
||
| Mesh | Peer-to-peer | Collaborative | 3-6 | High (~150ms) |
|
||
| Hybrid | Adaptive mix | Variable tasks | 4-8 | Variable |
|
||
|
||
## 🎯 Centralized Mode
|
||
|
||
### Overview
|
||
A single coordinator agent manages all tasks and delegates to worker agents.
|
||
|
||
```
|
||
[Coordinator]
|
||
/ | \
|
||
[Agent1] [Agent2] [Agent3]
|
||
```
|
||
|
||
### Characteristics
|
||
- **Structure**: Star topology with central coordinator
|
||
- **Communication**: All through coordinator
|
||
- **Decision Making**: Centralized
|
||
- **Fault Tolerance**: Low (single point of failure)
|
||
|
||
### Usage Example
|
||
```bash
|
||
swarm-benchmark run "Build user login form" \
|
||
--mode centralized \
|
||
--max-agents 3
|
||
```
|
||
|
||
### When to Use
|
||
- ✅ Small teams (2-4 agents)
|
||
- ✅ Simple, well-defined tasks
|
||
- ✅ Tasks requiring consistency
|
||
- ✅ Quick coordination needed
|
||
- ❌ NOT for complex parallel work
|
||
|
||
### Performance Profile
|
||
- **Coordination Overhead**: ~50ms
|
||
- **Communication Latency**: ~25ms
|
||
- **Scalability**: Limited (up to 5 agents)
|
||
- **Efficiency**: High for small teams
|
||
|
||
### Best Practices
|
||
1. Keep agent count low (≤4)
|
||
2. Use for sequential tasks
|
||
3. Assign clear roles to agents
|
||
4. Monitor coordinator load
|
||
|
||
## 🌐 Distributed Mode
|
||
|
||
### Overview
|
||
Multiple coordinators share responsibility for task management.
|
||
|
||
```
|
||
[Coordinator1] [Coordinator2]
|
||
/ \ / \
|
||
[A1] [A2] [A3] [A4]
|
||
```
|
||
|
||
### Characteristics
|
||
- **Structure**: Multiple coordination points
|
||
- **Communication**: Regional coordination
|
||
- **Decision Making**: Distributed consensus
|
||
- **Fault Tolerance**: High (redundancy)
|
||
|
||
### Usage Example
|
||
```bash
|
||
swarm-benchmark run "Research cloud providers and pricing" \
|
||
--mode distributed \
|
||
--max-agents 8 \
|
||
--parallel
|
||
```
|
||
|
||
### When to Use
|
||
- ✅ Medium teams (4-8 agents)
|
||
- ✅ Parallel, independent tasks
|
||
- ✅ Research and exploration
|
||
- ✅ Fault tolerance needed
|
||
- ❌ NOT for tightly coupled work
|
||
|
||
### Performance Profile
|
||
- **Coordination Overhead**: ~100ms + network
|
||
- **Communication Latency**: ~50ms
|
||
- **Scalability**: Good (up to 10 agents)
|
||
- **Efficiency**: High for parallel work
|
||
|
||
### Best Practices
|
||
1. Balance coordinator count (2-3)
|
||
2. Minimize inter-coordinator communication
|
||
3. Use for embarrassingly parallel tasks
|
||
4. Enable result aggregation
|
||
|
||
## 🌳 Hierarchical Mode
|
||
|
||
### Overview
|
||
Tree structure with multiple levels of coordination.
|
||
|
||
```
|
||
[Root Coordinator]
|
||
/ \
|
||
[Manager1] [Manager2]
|
||
/ \ / \
|
||
[W1] [W2] [W3] [W4]
|
||
```
|
||
|
||
### Characteristics
|
||
- **Structure**: Multi-level tree
|
||
- **Communication**: Up/down the hierarchy
|
||
- **Decision Making**: Delegated by level
|
||
- **Fault Tolerance**: Medium
|
||
|
||
### Usage Example
|
||
```bash
|
||
swarm-benchmark run "Develop microservices architecture" \
|
||
--mode hierarchical \
|
||
--max-agents 10 \
|
||
--quality-threshold 0.9
|
||
```
|
||
|
||
### When to Use
|
||
- ✅ Large teams (5-10 agents)
|
||
- ✅ Complex, multi-part projects
|
||
- ✅ Tasks with clear subtasks
|
||
- ✅ Need for oversight
|
||
- ❌ NOT for simple tasks
|
||
|
||
### Performance Profile
|
||
- **Coordination Overhead**: ~80ms per level
|
||
- **Communication Latency**: ~40ms per hop
|
||
- **Scalability**: Excellent (10+ agents)
|
||
- **Efficiency**: Good for structured work
|
||
|
||
### Best Practices
|
||
1. Keep hierarchy shallow (≤3 levels)
|
||
2. Balance tree structure
|
||
3. Clear responsibilities per level
|
||
4. Minimize cross-branch communication
|
||
|
||
### Hierarchy Design
|
||
```python
|
||
# Optimal hierarchy structure
|
||
if agent_count <= 4:
|
||
levels = 2 # Root + workers
|
||
elif agent_count <= 10:
|
||
levels = 3 # Root + managers + workers
|
||
else:
|
||
levels = 3 # Keep at 3, add more managers
|
||
```
|
||
|
||
## 🕸️ Mesh Mode
|
||
|
||
### Overview
|
||
Peer-to-peer network where agents communicate directly.
|
||
|
||
```
|
||
[Agent1] ←→ [Agent2]
|
||
↕ ╳ ↕
|
||
[Agent3] ←→ [Agent4]
|
||
```
|
||
|
||
### Characteristics
|
||
- **Structure**: Fully connected network
|
||
- **Communication**: Direct peer-to-peer
|
||
- **Decision Making**: Consensus-based
|
||
- **Fault Tolerance**: Very high
|
||
|
||
### Usage Example
|
||
```bash
|
||
swarm-benchmark run "Analyze dataset collaboratively" \
|
||
--mode mesh \
|
||
--max-agents 6 \
|
||
--consensus-threshold 0.8
|
||
```
|
||
|
||
### When to Use
|
||
- ✅ Collaborative tasks
|
||
- ✅ Peer review needed
|
||
- ✅ Consensus decisions
|
||
- ✅ High reliability required
|
||
- ❌ NOT for time-critical tasks
|
||
|
||
### Performance Profile
|
||
- **Coordination Overhead**: ~150ms + negotiation
|
||
- **Communication Latency**: ~30ms per peer
|
||
- **Scalability**: Limited (up to 6 agents)
|
||
- **Efficiency**: Lower due to overhead
|
||
|
||
### Best Practices
|
||
1. Limit agent count (≤6)
|
||
2. Use for quality-critical tasks
|
||
3. Set consensus thresholds
|
||
4. Monitor communication overhead
|
||
|
||
### Mesh Coordination
|
||
```python
|
||
# Communication complexity
|
||
connections = n * (n - 1) / 2 # Full mesh
|
||
# For 6 agents: 15 connections
|
||
# For 10 agents: 45 connections (too many!)
|
||
```
|
||
|
||
## 🔄 Hybrid Mode
|
||
|
||
### Overview
|
||
Adaptive coordination that switches between modes based on task requirements.
|
||
|
||
```
|
||
Task Analysis → Mode Selection → Dynamic Coordination
|
||
↓ ↓ ↓
|
||
[Centralized] [Distributed] [Hierarchical]
|
||
```
|
||
|
||
### Characteristics
|
||
- **Structure**: Adaptive topology
|
||
- **Communication**: Mode-dependent
|
||
- **Decision Making**: Context-aware
|
||
- **Fault Tolerance**: Adaptive
|
||
|
||
### Usage Example
|
||
```bash
|
||
swarm-benchmark run "Complete project with research, development, and testing" \
|
||
--mode hybrid \
|
||
--max-agents 8 \
|
||
--adaptive
|
||
```
|
||
|
||
### When to Use
|
||
- ✅ Mixed task types
|
||
- ✅ Unknown optimal approach
|
||
- ✅ Long-running projects
|
||
- ✅ Variable workloads
|
||
- ❌ NOT for simple, uniform tasks
|
||
|
||
### Performance Profile
|
||
- **Coordination Overhead**: 100-200ms (variable)
|
||
- **Communication Latency**: Mode-dependent
|
||
- **Scalability**: Good (adaptive)
|
||
- **Efficiency**: Optimizes per task
|
||
|
||
### Mode Selection Logic
|
||
```python
|
||
def select_mode(task, agents):
|
||
if agents <= 3:
|
||
return "centralized"
|
||
elif task.is_parallel():
|
||
return "distributed"
|
||
elif task.is_complex():
|
||
return "hierarchical"
|
||
elif task.needs_consensus():
|
||
return "mesh"
|
||
else:
|
||
return "centralized" # default
|
||
```
|
||
|
||
### Best Practices
|
||
1. Let system adapt naturally
|
||
2. Monitor mode switching
|
||
3. Set switching thresholds
|
||
4. Review mode selection patterns
|
||
|
||
## 📊 Mode Comparison
|
||
|
||
### Performance Metrics
|
||
|
||
| Metric | Centralized | Distributed | Hierarchical | Mesh | Hybrid |
|
||
|--------|-------------|-------------|--------------|------|---------|
|
||
| Setup Time | ⚡ Fast | Medium | Medium | Slow | Variable |
|
||
| Coordination | ⚡ Minimal | Medium | Medium | High | Adaptive |
|
||
| Scalability | ❌ Poor | ✅ Good | ✅ Excellent | ❌ Poor | ✅ Good |
|
||
| Reliability | ❌ Low | ✅ High | Medium | ✅ Highest | ✅ High |
|
||
| Complexity | ⚡ Simple | Medium | Medium | Complex | Complex |
|
||
|
||
### Decision Matrix
|
||
|
||
| If you need... | Use this mode |
|
||
|----------------|---------------|
|
||
| Quick results with few agents | Centralized |
|
||
| Parallel processing | Distributed |
|
||
| Complex project management | Hierarchical |
|
||
| Collaborative decision making | Mesh |
|
||
| Flexibility for various tasks | Hybrid |
|
||
|
||
## 🎯 Optimization Strategies
|
||
|
||
### 1. Agent Pool Optimization
|
||
|
||
```bash
|
||
# Centralized: Minimize agents
|
||
swarm-benchmark run "Task" --mode centralized --max-agents 3
|
||
|
||
# Distributed: Balance load
|
||
swarm-benchmark run "Task" --mode distributed --max-agents 6
|
||
|
||
# Hierarchical: Optimal tree
|
||
swarm-benchmark run "Task" --mode hierarchical --max-agents 9
|
||
|
||
# Mesh: Limit connections
|
||
swarm-benchmark run "Task" --mode mesh --max-agents 4
|
||
```
|
||
|
||
### 2. Communication Optimization
|
||
|
||
```python
|
||
# Reduce coordination overhead
|
||
optimization_tips = {
|
||
"centralized": "Batch task assignments",
|
||
"distributed": "Minimize coordinator sync",
|
||
"hierarchical": "Reduce tree depth",
|
||
"mesh": "Limit peer connections",
|
||
"hybrid": "Cache mode decisions"
|
||
}
|
||
```
|
||
|
||
### 3. Mode Selection Guide
|
||
|
||
```python
|
||
def recommend_mode(task_type, agent_count, priority):
|
||
if priority == "speed" and agent_count <= 3:
|
||
return "centralized"
|
||
elif priority == "reliability":
|
||
return "mesh" if agent_count <= 5 else "distributed"
|
||
elif priority == "scalability":
|
||
return "hierarchical"
|
||
elif task_type == "research":
|
||
return "distributed"
|
||
elif task_type == "development":
|
||
return "hierarchical"
|
||
else:
|
||
return "hybrid" # Let system decide
|
||
```
|
||
|
||
## 💡 Advanced Features
|
||
|
||
### Custom Coordination Parameters
|
||
|
||
```bash
|
||
# Fine-tune coordination behavior
|
||
swarm-benchmark run "Task" \
|
||
--mode distributed \
|
||
--coordinator-count 3 \
|
||
--sync-interval 500 \
|
||
--consensus-timeout 30
|
||
```
|
||
|
||
### Mode Switching in Hybrid
|
||
|
||
```bash
|
||
# Configure hybrid mode behavior
|
||
swarm-benchmark run "Task" \
|
||
--mode hybrid \
|
||
--mode-switch-threshold 0.7 \
|
||
--preferred-modes "distributed,hierarchical" \
|
||
--adaptation-rate 0.2
|
||
```
|
||
|
||
### Fault Tolerance Settings
|
||
|
||
```bash
|
||
# Enable fault tolerance features
|
||
swarm-benchmark run "Task" \
|
||
--mode distributed \
|
||
--enable-failover \
|
||
--coordinator-redundancy 2 \
|
||
--heartbeat-interval 10
|
||
```
|
||
|
||
## 📈 Monitoring Coordination
|
||
|
||
### Key Metrics to Watch
|
||
|
||
1. **Coordination Overhead**: Should be <15% of total time
|
||
2. **Message Count**: Monitor inter-agent communication
|
||
3. **Decision Time**: Time to assign tasks
|
||
4. **Synchronization Delay**: Time agents wait for others
|
||
|
||
### Monitoring Commands
|
||
|
||
```bash
|
||
# Real-time coordination monitoring
|
||
swarm-benchmark run "Task" --mode hierarchical --monitor-coordination
|
||
|
||
# Post-execution analysis
|
||
swarm-benchmark analyze <benchmark-id> --coordination-metrics
|
||
|
||
# Compare mode efficiency
|
||
swarm-benchmark compare-modes <task-type> --agent-counts 3,5,8
|
||
```
|
||
|
||
## 🎉 Best Practices Summary
|
||
|
||
1. **Start Simple**: Use centralized for initial tests
|
||
2. **Match Mode to Task**: Consider task characteristics
|
||
3. **Right-size Teams**: Don't over-provision agents
|
||
4. **Monitor Overhead**: Keep coordination efficient
|
||
5. **Test Thoroughly**: Benchmark different modes
|
||
6. **Document Findings**: Record what works best
|
||
|
||
Remember: The optimal coordination mode depends on your specific task requirements, team size, and performance goals. Always benchmark to find the best fit! |