Skip to main content
The MixtureOfAgents architecture runs multiple expert agents in parallel and synthesizes their diverse outputs through an aggregator agent. This collaborative approach achieves superior results through multi-perspective analysis.

When to Use

  • Complex problem-solving: Tasks requiring multiple expert perspectives
  • Quality through collaboration: Combine diverse viewpoints for better outcomes
  • State-of-the-art performance: Achieve highest quality through synthesis
  • Expert systems: Leverage specialized knowledge from multiple domains
  • Comprehensive analysis: Get well-rounded insights

Key Features

  • Parallel execution of expert agents
  • Automatic aggregation and synthesis
  • Multi-layer processing (optional)
  • Team awareness capabilities
  • Flexible output formatting
  • Conversation history tracking

Basic Example

Multi-Layer Processing

Use multiple layers for iterative refinement:
Each layer:
  1. Experts analyze the current context
  2. Outputs are added to conversation history
  3. Next layer sees all previous analysis
  4. Aggregator synthesizes final result

Key Parameters

name
str
default:"MixtureOfAgents"
Name for the MoA instance
agents
List[Agent]
required
List of expert agents to run in parallel
aggregator_agent
Agent
required
Agent that synthesizes expert outputs
layers
int
default:"3"
Number of processing layers (iterations)
max_loops
int
default:"1"
Maximum loops per layer
output_type
OutputType
default:"final"
Output format (final, all, list, dict)
aggregator_system_prompt
str
Custom system prompt for aggregator (uses default if not provided)
aggregator_model_name
str
default:"claude-sonnet-4-20250514"
Model for the aggregator agent

Methods

run()

Execute the mixture of agents with a task.

run_batched()

Process multiple tasks sequentially.

run_concurrently()

Process multiple tasks in parallel.

Use Cases

Investment Analysis

Medical Diagnosis

Research Synthesis

Custom Aggregator Prompt

Automatic Aggregator Setup

If no aggregator agent is provided, one is created automatically:

Architecture Flow

Multi-Layer Flow

With layers=3:

Output Types

Best Practices

Expert Selection: Choose agents with complementary expertise for maximum benefit
  1. Diverse Experts: Select agents with different perspectives/specializations
  2. Clear Prompts: Give each expert a specific focus area
  3. Quality Aggregator: Use strong model for synthesis (Claude Sonnet, GPT-4)
  4. Layer Count: Start with 1 layer, add more only if needed
  5. Aggregator Instructions: Provide clear synthesis guidelines
More experts and layers increase cost and latency - balance quality with efficiency

Reliability Checks

The system validates configuration on initialization:
Validations:
  • At least one expert agent required
  • Aggregator system prompt must be provided
  • Layers must be specified

Performance Considerations

Concurrent Execution

Experts run in true parallel using ThreadPoolExecutor:

Conversation Context

Full context flows through layers: