agents.patterns.hybrid_multi_agent_patterns¶
Hybrid Multi-Agent Patterns - Advanced compositions using base patterns.
This module demonstrates advanced multi-agent patterns that combine different agent types and execution modes, using the base agent.py and SimpleAgentV3 patterns as building blocks.
Patterns include: 1. Parallel-then-Sequential workflows 2. Conditional routing with multiple branches 3. Hierarchical agent structures 4. Dynamic agent composition
Classes¶
Adaptive multi-agent that changes behavior based on context. |
|
Collaborative multi-agent where agents work together. |
|
Hybrid multi-agent with mixed execution patterns. |
|
Results from parallel agent execution. |
|
Task classification result. |
Functions¶
|
Create an adaptive multi-agent. |
|
Create a collaborative multi-agent. |
|
Create a hybrid multi-agent. |
Example of adaptive processing. |
|
Example of collaborative multi-agent. |
|
Example of classification-based processing. |
Module Contents¶
- class agents.patterns.hybrid_multi_agent_patterns.AdaptiveMultiAgent(**kwargs)¶
Bases:
haive.agents.multi.agent.MultiAgent
Adaptive multi-agent that changes behavior based on context.
This agent dynamically adjusts its execution pattern based on input characteristics and intermediate results.
Init .
- class agents.patterns.hybrid_multi_agent_patterns.CollaborativeMultiAgent(**kwargs)¶
Bases:
haive.agents.multi.agent.MultiAgent
Collaborative multi-agent where agents work together.
Agents share information and build on each other’s work.
Init .
- class agents.patterns.hybrid_multi_agent_patterns.HybridMultiAgent¶
Bases:
haive.agents.base.agent.Agent
Hybrid multi-agent with mixed execution patterns.
This agent can combine parallel and sequential execution, conditional routing, and dynamic agent selection.
Examples
>>> agent = HybridMultiAgent( ... name="hybrid_processor", ... initial_agents=[classifier], ... processing_agents=[simple_proc, complex_proc, research_proc], ... synthesis_agents=[combiner, formatter], ... execution_pattern="classify_then_process" ... )
- build_graph()¶
Build hybrid execution graph.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- setup_agent()¶
Setup hybrid agent structure.
- Return type:
None
- class agents.patterns.hybrid_multi_agent_patterns.ParallelResults(/, **data)¶
Bases:
pydantic.BaseModel
Results from parallel agent execution.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class agents.patterns.hybrid_multi_agent_patterns.TaskClassification(/, **data)¶
Bases:
pydantic.BaseModel
Task classification result.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- agents.patterns.hybrid_multi_agent_patterns.create_adaptive_agent(name='adaptive', debug=True)¶
Create an adaptive multi-agent.
- Parameters:
- Return type:
- agents.patterns.hybrid_multi_agent_patterns.create_collaborative_agent(name='collaborative', collaboration_mode='consensus', debug=True)¶
Create a collaborative multi-agent.
- Parameters:
- Return type:
- agents.patterns.hybrid_multi_agent_patterns.create_hybrid_agent(name='hybrid', execution_pattern='classify_then_process', debug=True)¶
Create a hybrid multi-agent.
- Parameters:
- Return type:
- async agents.patterns.hybrid_multi_agent_patterns.example_adaptive_processing()¶
Example of adaptive processing.
- async agents.patterns.hybrid_multi_agent_patterns.example_collaborative()¶
Example of collaborative multi-agent.
- async agents.patterns.hybrid_multi_agent_patterns.example_hybrid_classify_process()¶
Example of classification-based processing.