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>
10 KiB
10 KiB
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
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
- Keep agent count low (≤4)
- Use for sequential tasks
- Assign clear roles to agents
- 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
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
- Balance coordinator count (2-3)
- Minimize inter-coordinator communication
- Use for embarrassingly parallel tasks
- 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
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
- Keep hierarchy shallow (≤3 levels)
- Balance tree structure
- Clear responsibilities per level
- Minimize cross-branch communication
Hierarchy Design
# 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
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
- Limit agent count (≤6)
- Use for quality-critical tasks
- Set consensus thresholds
- Monitor communication overhead
Mesh Coordination
# 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
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
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
- Let system adapt naturally
- Monitor mode switching
- Set switching thresholds
- 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
# 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
# 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
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
# Fine-tune coordination behavior
swarm-benchmark run "Task" \
--mode distributed \
--coordinator-count 3 \
--sync-interval 500 \
--consensus-timeout 30
Mode Switching in Hybrid
# 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
# Enable fault tolerance features
swarm-benchmark run "Task" \
--mode distributed \
--enable-failover \
--coordinator-redundancy 2 \
--heartbeat-interval 10
📈 Monitoring Coordination
Key Metrics to Watch
- Coordination Overhead: Should be <15% of total time
- Message Count: Monitor inter-agent communication
- Decision Time: Time to assign tasks
- Synchronization Delay: Time agents wait for others
Monitoring Commands
# 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
- Start Simple: Use centralized for initial tests
- Match Mode to Task: Consider task characteristics
- Right-size Teams: Don't over-provision agents
- Monitor Overhead: Keep coordination efficient
- Test Thoroughly: Benchmark different modes
- 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!