Orchestration Patterns
Production-proven agent orchestration patterns in Aixgo
Agent Orchestration Patterns
Aixgo provides 12 production-proven orchestration patterns for building AI agent systems. Each pattern solves specific problems and is backed by real-world usage from industry-leading frameworks.
Pattern Overview
✅ Implemented (v1.0)
Supervisor Pattern
Centralized orchestration with specialized agents
Route tasks to expert agents, aggregate results, and maintain conversation state. Perfect for customer service and multi-agent workflows.
orchestration:
pattern: supervisor
agents: [billing, tech-support, sales]Sequential Pattern
Ordered pipeline execution
Execute agents in sequence where each step’s output feeds the next. Ideal for ETL, content pipelines, and multi-stage workflows.
orchestration:
pattern: sequential
agents: [extract, transform, validate, load]🚧 Coming in v2.0
Parallel Pattern
Concurrent execution with aggregation
Execute multiple agents simultaneously and aggregate results. 3-4× speedup for independent tasks.
Use cases: Multi-source research, batch processing, A/B testing
orchestration:
pattern: parallel
agents: [competitive-analysis, market-sizing, tech-trends]Phase 3 · Expected Q1 2025
Router Pattern
Intelligent routing for cost optimization
Route simple queries to cheap models, complex to expensive. 25-50% cost reduction in production.
Use cases: Cost optimization, intent-based routing, model selection
orchestration:
pattern: router
classifier: intent-classifier
routes:
simple: gpt-3.5-turbo
complex: gpt-4-turboPhase 3 · Expected Q1 2025
Swarm Pattern
Decentralized agent handoffs
Dynamic agent-to-agent handoffs based on conversational context. Popularized by OpenAI Swarm.
Use cases: Customer service handoffs, adaptive routing, collaborative problem-solving
orchestration:
pattern: swarm
agents: [general, billing, technical]Phase 3 · Expected Q1 2025
RAG Pattern
Retrieval-Augmented Generation
Retrieve relevant docs from vector store, then generate grounded answers. Most common enterprise pattern.
Use cases: Enterprise chatbots, documentation Q&A, knowledge retrieval
orchestration:
pattern: rag
retriever: vector-store
generator: answer-agent
top_k: 5Phase 3 · Expected Q1 2025
Reflection Pattern
Iterative refinement with self-critique
Generator creates output, critic reviews it, generator refines. 20-50% quality improvement.
Use cases: Code generation, content creation, complex reasoning
orchestration:
pattern: reflection
generator: code-generator
critic: code-reviewer
max_iterations: 3Phase 3 · Expected Q1 2025
Hierarchical Pattern
Multi-level delegation
Managers delegate to sub-managers who delegate to workers. Perfect for complex decomposition.
Use cases: Enterprise workflows, project management, organizational hierarchies
orchestration:
pattern: hierarchical
manager: project-manager
teams:
frontend: [ui-engineer, ux-engineer]
backend: [api-engineer, db-engineer]Phase 4 · Expected Q2 2025
Ensemble Pattern
Multi-model voting for accuracy
Multiple models vote on outputs to reduce errors. 25-50% error reduction in high-stakes decisions.
Use cases: Medical diagnosis, financial forecasting, content moderation
orchestration:
pattern: ensemble
models: [gpt-4, claude-3.5, gemini-1.5]
voting: majorityPhase 4 · Expected Q2 2025
🔮 Future (v2.1+)
Debate Pattern
Adversarial collaboration for accuracy
Agents with different perspectives debate to reach consensus. 20-40% improvement in factual accuracy.
Use cases: Research synthesis, legal analysis, complex decision-making
Phase 5 · v2.1+ (2025 H2)
Plan-and-Execute Pattern
Strategic planning before execution
Planner decomposes task, executors handle sub-tasks, planner adjusts based on results.
Use cases: Multi-step research, data pipelines, software development
Phase 2 or v2.1 · TBD
Nested/Composite Pattern
Encapsulate complex workflows as single agents
Complex multi-agent workflows packaged as reusable components.
Use cases: Modular agent development, workflow reuse, testing
Phase 6 · v2.2+ (2025 H2)
Pattern Comparison
| Pattern | Complexity | Cost | Latency | Accuracy | Production Maturity |
|---|---|---|---|---|---|
| Supervisor | Low | 1× | Low | Medium | ⭐⭐⭐⭐⭐ Very High |
| Sequential | Low | N× | High | Medium | ⭐⭐⭐⭐⭐ Very High |
| Parallel | Medium | N× | Low | Medium | ⭐⭐⭐⭐ High |
| Router | Low | 0.25-0.5× | Low | High | ⭐⭐⭐⭐⭐ Very High |
| Swarm | Medium | Variable | Medium | High | ⭐⭐⭐ Medium |
| Hierarchical | Medium | N× | Medium | High | ⭐⭐⭐ Medium |
| RAG | Medium | 0.3× | Medium | High | ⭐⭐⭐⭐⭐ Very High |
| Reflection | Medium | 2-4× | High | Very High | ⭐⭐⭐ Medium |
| Ensemble | Medium | 3-5× | Low | Very High | ⭐⭐⭐⭐ High |
| Debate | High | 9× | Very High | Very High | ⭐⭐ Low |
| Plan-Execute | Low | Optimized | Medium | High | ⭐⭐⭐ Medium |
| Nested | High | Variable | Variable | Variable | ⭐⭐ Low |
Cost Legend
1×= Single agent executionN×= N agents (sequential or parallel)0.25-0.5×= Router savings (cheap models for most queries)0.3×= RAG token reduction vs full KB2-4×,3-5×,9×= Multiple iterations/agents
Latency Legend
- Low: < 1s overhead
- Medium: 1-5s overhead
- High: 5-15s overhead
- Very High: > 15s overhead
Pattern Selection Guide
Choose by Goal
💰 Reduce Costs → Router (25-50% savings) or RAG (70% token reduction)
⚡ Improve Speed → Parallel (3-4× speedup)
🎯 Improve Accuracy → Ensemble (25-50% error reduction) or Reflection (20-50% improvement)
🔄 Adaptive Routing → Swarm (dynamic handoffs) or Supervisor (centralized control)
📊 Complex Workflows → Hierarchical (multi-level) or Sequential (ordered steps)
📚 Knowledge-Intensive → RAG (retrieval-augmented)
Decision Tree
Need to reduce costs? → Router or RAG
Need high accuracy? → Ensemble or Reflection
Have independent sub-tasks? → Parallel
Need ordered steps? → Sequential
Need dynamic routing? → Swarm
Need multi-level management? → Hierarchical
Need knowledge base access? → RAG
General orchestration? → Supervisor (default)Real-World Examples
Cost Optimization with Router
// Before: Always using GPT-4
// Cost: $0.03 per request
// After: Router to GPT-3.5 for 80% of queries
// Cost: $0.006 per request (80% savings)
router := orchestration.NewRouter(
"cost-optimizer",
runtime,
"complexity-classifier",
map[string]string{
"simple": "gpt-3.5-turbo-agent",
"complex": "gpt-4-turbo-agent",
},
)Result: 25-50% cost reduction in production deployments.
Speed Improvement with Parallel
// Before: Sequential execution
// Time: 10s (sum of all agents)
// After: Parallel execution
// Time: 3s (max of all agents)
parallel := orchestration.NewParallel(
"market-research",
runtime,
[]string{"competitors", "market-size", "trends", "regulations"},
)Result: 3-4× speedup for independent research tasks.
Accuracy Improvement with Ensemble
// Before: Single model (GPT-4)
// Error rate: 15%
// After: 3-model ensemble
// Error rate: 6% (60% reduction)
ensemble := orchestration.NewEnsemble(
"medical-diagnosis",
runtime,
[]string{"gpt4-diagnostic", "claude-diagnostic", "gemini-diagnostic"},
orchestration.WithVotingStrategy(orchestration.VotingMajority),
)Result: 25-50% error reduction for high-stakes decisions.
Implementation Roadmap
v2.0 (Q1-Q2 2025)
Phase 1 (Weeks 1-2): Foundation
- Agent interface redesign
- LocalRuntime implementation
Phase 2 (Weeks 2-3): Observability
- Automatic cost tracking
- Langfuse integration
Phase 3 (Weeks 3-5): Core Patterns
- ✅ Parallel
- ✅ Router
- ✅ Swarm
- ✅ RAG
- ✅ Reflection
Phase 4 (Weeks 5-7): Advanced Patterns
- ✅ Hierarchical
- ✅ Ensemble
Phase 5 (Weeks 7-9): Distributed Runtime
- gRPC-based deployment
- Local → Distributed migration
Phase 6 (Weeks 9-10): Documentation
- Pattern catalog
- Migration guide
- Examples for each pattern
Phase 7 (Weeks 10-11): Testing
- Unit, integration, E2E tests
- Race condition tests
- Benchmarks
Phase 8 (Week 12): Release
- v2.0.0-alpha
- Documentation
- Examples
v2.1+ (2025 H2)
Phase 5: Future Patterns
- 🔮 Debate
- 🔮 Plan-Execute (possibly Phase 2)
Phase 6: Modularity
- 🔮 Nested/Composite
Getting Started
Installation
go get github.com/aixgo-dev/aixgo@v2.0.0-alphaQuick Example
package main
import (
"context"
"github.com/aixgo-dev/aixgo/internal/runtime"
"github.com/aixgo-dev/aixgo/internal/orchestration"
)
func main() {
// Create runtime
rt := runtime.NewLocalRuntime()
rt.Register("agent1", agent1)
rt.Register("agent2", agent2)
// Create orchestrator
orchestrator := orchestration.NewParallel(
"parallel-workflow",
rt,
[]string{"agent1", "agent2"},
)
// Execute
result, _ := orchestrator.Execute(context.Background(), input)
println(result.Payload)
}Learn More
Support
- GitHub Issues: github.com/aixgo-dev/aixgo/issues
- Documentation: aixgo.dev
- Discord: Join our community (coming soon)