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:- Experts analyze their input, concurrently
- Outputs are added to conversation history
- The next layer receives the original task plus the previous layer’s synthesis, not the whole transcript
- 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.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: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
Withlayers=3:
Output Types
Best Practices
Expert Selection: Choose agents with complementary expertise for maximum benefit
- Diverse Experts: Select agents with different perspectives/specializations
- Clear Prompts: Give each expert a specific focus area
- Quality Aggregator: Use strong model for synthesis (Claude Sonnet, GPT-4)
- Layer Count: Start with 1 layer, add more only if needed
- Aggregator Instructions: Provide clear synthesis guidelines
Reliability Checks
The system validates configuration on initialization:- 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.Related Architectures
- Concurrent Workflow - Parallel without synthesis
- Hierarchical Swarm - Director-worker pattern
- Heavy Swarm - Multi-phase analysis
- Agent Rearrange - Custom flow patterns