agents.multi.enhanced_parallel_agent¶
Enhanced ParallelAgent implementation using Agent[AugLLMConfig].
ParallelAgent = Agent[AugLLMConfig] + parallel execution of agents.
Classes¶
Init . |
|
Enhanced ParallelAgent that executes agents concurrently. |
Module Contents¶
- class agents.multi.enhanced_parallel_agent.MockExpert(name, specialty)¶
Init .
- class agents.multi.enhanced_parallel_agent.ParallelAgent¶
Bases:
haive.agents.simple.enhanced_simple_real.EnhancedAgentBase
Enhanced ParallelAgent that executes agents concurrently.
ParallelAgent = Agent[AugLLMConfig] + parallel execution + result aggregation.
All agents receive the same input and execute concurrently. Results can be aggregated using various strategies (all, first, best, majority).
- agents¶
List of agents to execute in parallel
- aggregation_strategy¶
How to combine results
- timeout_per_agent¶
Timeout for each agent
- min_agents_for_consensus¶
Minimum agents for consensus strategies
Examples
Parallel analysis with multiple experts:
experts = ParallelAgent( name="expert_panel", agents=[ FinanceExpert(), TechExpert(), MarketExpert() ], aggregation_strategy="all" ) # All experts analyze simultaneously results = experts.run("Analyze startup investment opportunity")
Consensus-based decision making:
validators = ParallelAgent( name="validation_ensemble", agents=[Validator1(), Validator2(), Validator3()], aggregation_strategy="majority", min_agents_for_consensus=2 ) # Returns majority consensus decision = validators.run("Is this transaction valid?")
- add_agent(agent)¶
Add an agent to the parallel group.
- Parameters:
agent (haive.agents.simple.enhanced_simple_real.EnhancedAgentBase) – Agent to add
- Return type:
None
- build_graph()¶
Build parallel execution graph.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- async execute_parallel(input_data)¶
Execute all agents in parallel.
- Parameters:
input_data (Any) – Input for all agents
- Returns:
Aggregated results based on strategy
- Return type:
list[Any] | Any
- remove_agent(agent)¶
Remove an agent from the parallel group.
- Parameters:
agent (haive.agents.simple.enhanced_simple_real.EnhancedAgentBase) – Agent to remove
- Returns:
True if removed, False if not found
- Return type:
- setup_agent()¶
Setup parallel coordinator.
- Return type:
None