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 the current context
- Outputs are added to conversation history
- Next layer sees all previous analysis
- Aggregator synthesizes final result
Key Parameters
Name for the MoA instance
List of expert agents to run in parallel
Agent that synthesizes expert outputs
Number of processing layers (iterations)
Maximum loops per layer
Output format (final, all, list, dict)
Custom system prompt for aggregator (uses default if not provided)
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
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
Full context flows through layers:Related Architectures
- Concurrent Workflow - Parallel without synthesis
- Hierarchical Swarm - Director-worker pattern
- Heavy Swarm - Multi-phase analysis
- Agent Rearrange - Custom flow patterns