Back to Ruflo

Coordination Modes Guide

v2/benchmark/docs/coordination-modes.md

3.6.3010.3 KB
Original Source

Coordination Modes Guide

This guide explains the 5 coordination modes available for agent swarm orchestration and when to use each one.

🎯 Coordination Mode Overview

ModeStructureBest ForAgent CountOverhead
CentralizedSingle coordinatorSimple tasks2-4Low (~50ms)
DistributedMultiple coordinatorsParallel work4-8Medium (~100ms)
HierarchicalTree structureComplex projects5-10Medium (~80ms)
MeshPeer-to-peerCollaborative3-6High (~150ms)
HybridAdaptive mixVariable tasks4-8Variable

🎯 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

MetricCentralizedDistributedHierarchicalMeshHybrid
Setup Time⚑ FastMediumMediumSlowVariable
Coordination⚑ MinimalMediumMediumHighAdaptive
Scalability❌ Poorβœ… Goodβœ… Excellent❌ Poorβœ… Good
Reliability❌ Lowβœ… HighMediumβœ… Highestβœ… High
Complexity⚑ SimpleMediumMediumComplexComplex

Decision Matrix

If you need...Use this mode
Quick results with few agentsCentralized
Parallel processingDistributed
Complex project managementHierarchical
Collaborative decision makingMesh
Flexibility for various tasksHybrid

🎯 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!