Skip to main content
Swarm Type: MixtureOfAgents

Overview

The MixtureOfAgents swarm type brings together multiple specialized agents to work collaboratively on the same task. This architecture leverages the collective intelligence and diverse perspectives of multiple agents, combining their expertise to produce more comprehensive and nuanced solutions than any single agent could achieve alone. Key features:
  • Collaborative Analysis: Multiple agents work together on the same task
  • Diverse Perspectives: Different viewpoints and expertise areas
  • Comprehensive Solutions: Combined insights from multiple specialists
  • Enhanced Quality: Better results through collective intelligence

Architecture

Every specialist sees the same task, and the last agent in agents acts as the aggregator that combines their perspectives into one answer.
The last agent you list in agents is the aggregator. It does not answer the task as a specialist; it reads the specialists’ outputs and writes the final answer. Put your synthesizer last. The swarm-level max_loops sets the number of specialist layers: on each layer after the first, the specialists answer again with the previous layer’s outputs in context, and the aggregator runs once at the end.

Use Cases

  • Complex problem analysis requiring multiple viewpoints
  • Content creation with multiple expert perspectives
  • Research projects needing interdisciplinary approaches
  • Decision-making with diverse stakeholder input

API Usage

Basic MixtureOfAgents Example

Example Response:

Output Shape

Every swarm run is executed through a SwarmRouter with output_type forced to "dict" server-side (see api/swarm_completions.py), so output is a list of {"role": ..., "content": ...} conversation turns rather than a single string. MixtureOfAgents runs every agent in agents except the last in parallel as specialists, then the last agent, the aggregator, synthesizes their outputs into a consolidated answer. output contains one turn per specialist per layer, followed by the aggregator’s turn; in the example above, Policy Expert is the aggregator. When max_loops is above 1, specialist turns are labelled with their layer, e.g. "Technology Analyst (layer 1/2)". number_of_agents counts every agent you supplied, including the aggregator.

Best Practices

  • Design agents with complementary but distinct expertise areas
  • Use for complex tasks requiring multiple perspectives
  • Ensure agents can work collaboratively on the same problem
  • Ideal for comprehensive analysis and decision-making