Overview
TheMixtureOfAgents class manages and executes multiple agents in parallel layers, aggregating their responses through a specialized aggregator agent. This architecture enables sophisticated multi-perspective analysis by running agents concurrently and synthesizing their outputs.
Class Definition
Parameters
str
default:"uuid.uuid4()"
Unique identifier for the mixture of agents instance
str
default:"MixtureOfAgents"
The name of the mixture of agents
str
A description of the mixture of agents purpose and functionality
List[Agent]
default:"None"
A list of reference agents to be used in the mixture. These agents will be executed in parallel layers
Agent
default:"None"
The aggregator agent to be used for synthesizing responses from all agents. If None, a default aggregator agent will be created
str
default:"AGGREGATOR_SYSTEM_PROMPT_MAIN"
The system prompt for the aggregator agent that guides how responses are synthesized
int
default:"3"
The number of processing layers to execute. Each layer runs all agents and passes context forward
int
default:"1"
Maximum number of execution loops for the aggregator agent
OutputType
default:"final"
Output format type. Options: “final”, “all”, “list”, etc.
str
default:"claude-sonnet-4-20250514"
The model name for the aggregator agent
Methods
reliability_check()
ValueError: If no agents are providedValueError: If no aggregator system prompt is providedValueError: If no layers are specified
step()
str
required
The task to be executed by all agents
str
Optional image input for the task
Dict[str, str]
Dictionary mapping agent names to their output responses
run()
str
required
The task to be executed by the mixture of agents
str
Optional image input for the task
str
The aggregated response from all agents after processing through all layers
- Adds initial task to conversation history
- For each layer:
- Runs all agents concurrently with full context
- Adds each agent’s output to conversation
- Updates context with latest conversation history
- Runs aggregator agent on complete conversation
- Returns formatted output based on output_type
run_batched()
List[str]
required
A list of tasks to be executed by the mixture of agents
List[str]
A list of aggregated responses from the mixture of agents, one for each task
run_concurrently()
List[str]
required
A list of tasks to be executed concurrently
List[str]
A list of aggregated responses from the mixture of agents
Usage Example
Architecture
The MixtureOfAgents architecture works as follows:- Layer Processing: Each layer runs all agents concurrently with the full conversation context
- Context Accumulation: Agent outputs are added to the conversation history after each layer
- Iterative Refinement: Subsequent layers build upon previous outputs, enabling deeper analysis
- Final Aggregation: An aggregator agent synthesizes all responses into a coherent final output