---
name: agent-orchestration-advanced
description: |
  Advanced agent orchestration patterns beyond basic multi-agent.
  Use for complex agent hierarchies, dynamic agent spawning,
  agent communication protocols, and swarm intelligence patterns.

allowed-tools:
  - Task
  - Read
---

# Advanced Agent Orchestration Skill

## Agent Hierarchies

### Three-Tier Architecture

```
┌─────────────────────────────────┐
│         ORCHESTRATOR            │ Strategic decisions
│      (Opus - reasoning)         │
└──────────────┬──────────────────┘
               │
    ┌──────────┴──────────┐
    │                     │
┌───┴───┐           ┌─────┴────┐
│MANAGER│           │ MANAGER  │ Tactical coordination
│(Sonnet)│           │ (Sonnet) │
└───┬───┘           └────┬─────┘
    │                    │
┌───┴───┐           ┌────┴────┐
│WORKERS│           │ WORKERS │ Task execution
│(Haiku)│           │ (Haiku) │
└───────┘           └─────────┘
```

### Dynamic Spawning

```python
# Spawn workers based on task complexity
if task.complexity > HIGH:
    workers = spawn_workers(count=5, model="sonnet")
else:
    workers = spawn_workers(count=10, model="haiku")
```

## Communication Patterns

### Blackboard Pattern
- Shared state all agents read/write
- Decoupled communication
- Good for collaborative problem-solving

### Message Passing
- Direct agent-to-agent communication
- Event-driven coordination
- Better for pipelines

### Broadcast
- One-to-many communication
- Good for fan-out tasks
- Parallel execution

## Swarm Intelligence

### Consensus Building

```python
# Multiple agents vote on solution
votes = [agent.evaluate(solution) for agent in swarm]
consensus = majority_vote(votes)
```

### Competitive Evolution

```python
# Agents compete, best survives
solutions = [agent.solve(problem) for agent in swarm]
best = evaluate_and_select(solutions)
```

## Best Practices

1. Match agent capability to task complexity
2. Minimize inter-agent communication
3. Use shared context efficiently
4. Implement graceful degradation
5. Monitor agent performance
