Orchestration Patterns

Production-proven agent orchestration patterns in Aixgo

Agent Orchestration Patterns

Aixgo provides 13 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.

All patterns are fully implemented and production-ready in v0.2.0+.

📖 Complete Technical Documentation:

This page provides a marketing-friendly overview for evaluation and planning.

Pattern Overview

✅ Implemented (v0.2.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]

View Pattern Docs →

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]

View Pattern Docs →

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]

View Pattern Docs →

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-turbo

View Pattern Docs →

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]

View Pattern Docs →

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]

View Pattern Docs →

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: 5

View Pattern Docs →

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: 3

View Pattern Docs →

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: majority

View Pattern Docs →

Classifier Pattern

Intent-based routing

Classify user intent and route to specialized agents. Perfect for support ticket routing and content categorization.

Use cases: Ticket classification, intent-based routing, content categorization

orchestration:
  pattern: classifier
  classifier: intent-classifier
  routes:
    technical: tech-agent
    billing: billing-agent

View Pattern Docs →

Aggregation Pattern

Multi-agent synthesis

Combine outputs from multiple agents using consensus, weighted, or semantic strategies.

Use cases: Expert synthesis, multi-source analysis, decision fusion

orchestration:
  pattern: aggregation
  agents: [expert-1, expert-2, expert-3]
  strategy: consensus

View Pattern Docs →

Planning Pattern

Dynamic task decomposition

Break complex tasks into subtasks with dynamic replanning based on execution results.

Use cases: Multi-step research, data pipelines, software development

orchestration:
  pattern: planning
  planner: task-planner
  executors: [executor-1, executor-2]

View Pattern Docs →

MapReduce Pattern

Distributed batch processing

Process large datasets in parallel chunks and aggregate results.

Use cases: Batch processing, data analysis, document processing

orchestration:
  pattern: mapreduce
  mapper: chunk-processor
  reducer: result-aggregator

View Pattern Docs →

🔮 Future Patterns (Roadmap)

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

PatternComplexityCostLatencyAccuracyProduction Maturity
SupervisorLowLowMedium⭐⭐⭐⭐⭐ Very High
SequentialLowHighMedium⭐⭐⭐⭐⭐ Very High
ParallelMediumLowMedium⭐⭐⭐⭐⭐ Very High
RouterLow0.25-0.5×LowHigh⭐⭐⭐⭐⭐ Very High
SwarmMediumVariableMediumHigh⭐⭐⭐⭐ High
HierarchicalMediumMediumHigh⭐⭐⭐⭐ High
RAGMedium0.3×MediumHigh⭐⭐⭐⭐⭐ Very High
ReflectionMedium2-4×HighVery High⭐⭐⭐⭐ High
EnsembleMedium3-5×LowVery High⭐⭐⭐⭐ High
ClassifierLowLowHigh⭐⭐⭐⭐⭐ Very High
AggregationMediumMediumHigh⭐⭐⭐⭐ High
PlanningMediumOptimizedMediumHigh⭐⭐⭐⭐ High
MapReduceMediumLowHigh⭐⭐⭐⭐⭐ Very High
Debate (Roadmap)HighVery HighVery High🔮 Future
Nested (Roadmap)HighVariableVariableVariable🔮 Future

Cost Legend

  • = Single agent execution
  • = N agents (sequential or parallel)
  • 0.25-0.5× = Router savings (cheap models for most queries)
  • 0.3× = RAG token reduction vs full KB
  • 2-4×, 3-5×, = 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 CostsRouter (25-50% savings) or RAG (70% token reduction)

⚡ Improve SpeedParallel (3-4× speedup)

🎯 Improve AccuracyEnsemble (25-50% error reduction) or Reflection (20-50% improvement)

🔄 Adaptive RoutingSwarm (dynamic handoffs) or Supervisor (centralized control)

📊 Complex WorkflowsHierarchical (multi-level) or Sequential (ordered steps)

📚 Knowledge-IntensiveRAG (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.

Roadmap

All 13 core patterns are implemented and production-ready in v0.2.0+.

Future Patterns (v2.1+, 2025 H2)

  • 🔮 Debate Pattern - Adversarial collaboration for accuracy
  • 🔮 Nested/Composite Pattern - Encapsulate complex workflows as single agents

Getting Started

Installation

go get github.com/aixgo-dev/aixgo

Quick Example

# config/agents.yaml
supervisor:
  name: coordinator
  model: gpt-4-turbo
  max_rounds: 10

agents:
  - name: data-producer
    role: producer
    interval: 1s
    outputs:
      - target: analyzer

  - name: analyzer
    role: react
    model: gpt-4-turbo
    prompt: |
      You are a data analyst. Analyze incoming data and provide insights.
    inputs:
      - source: data-producer
    outputs:
      - target: logger

  - name: logger
    role: logger
    inputs:
      - source: analyzer
// main.go
package main

import (
    "github.com/aixgo-dev/aixgo"
    _ "github.com/aixgo-dev/aixgo/agents"
)

func main() {
    if err := aixgo.Run("config/agents.yaml"); err != nil {
        panic(err)
    }
}

Learn More

Support