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 their input, concurrently
  2. Outputs are added to conversation history
  3. The next layer receives the original task plus the previous layer’s synthesis, not the whole transcript
  4. Aggregator synthesizes the final result

Key Parameters

str
default:"MixtureOfAgents"
Name for the MoA instance
List[Agent]
required
List of expert agents to run in parallel
Agent
default:"None"
Agent that synthesizes expert outputs. If omitted, a default aggregator is created automatically from aggregator_system_prompt and aggregator_model_name.
int
default:"3"
Number of processing layers (iterations)
int
default:"1"
Maximum loops per layer
OutputType
default:"final"
Output format (final, all, list, dict)
str
Custom system prompt for aggregator (uses default if not provided)
str
default:"claude-sonnet-4-20250514"
Model for the aggregator agent
int
default:"None"
Cap on how many worker agents run concurrently within a single layer. Forwarded to run_agents_concurrently(). When omitted, the pool is sized by agent count.
Dict[str, Any]
default:"None"
Extra Agent keyword arguments forwarded to the automatically created aggregator. Ignored entirely when you pass your own aggregator_agent.
The parameter is spelled aggegrator_args in the code — note the transposed letters. That misspelling is the name you must type; aggregator_args is not accepted and raises TypeError.

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:
Use aggegrator_args to pass any other Agent keyword argument through to that auto-created aggregator:
aggegrator_args only applies when the aggregator is auto-created. If you pass your own aggregator_agent, configure it on that Agent directly — aggegrator_args is ignored.

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

Layers do not receive the full transcript. The first layer gets the task alone; each later layer gets the original task plus the previous layer’s synthesis. This deliberately avoids re-sending a growing transcript to every worker on every layer.