agents.multi.experiments.implementations.multi_agent_v2¶
Multi-agent V2 with proper state management and rebuilding support.
This module provides a rebuilt MultiAgent that uses MultiAgentState without schema flattening, maintaining type safety and hierarchical access.
Classes¶
Execution modes for multi-agent systems. |
|
Rebuilt multi-agent system using proper state management. |
Module Contents¶
- class agents.multi.experiments.implementations.multi_agent_v2.ExecutionMode¶
-
Execution modes for multi-agent systems.
Initialize self. See help(type(self)) for accurate signature.
- class agents.multi.experiments.implementations.multi_agent_v2.MultiAgentV2¶
Bases:
haive.agents.base.agent.Agent
Rebuilt multi-agent system using proper state management.
Key improvements: - Uses MultiAgentState without schema flattening - Each agent maintains its own schema - Supports rebuilding with class methods - Proper hierarchical state access
- add_agent(agent, rebuild=True)¶
Add an agent and optionally rebuild.
- Parameters:
agent (haive.agents.base.agent.Agent) – Agent to add
rebuild (bool) – Whether to rebuild the graph
- Returns:
Self or new instance if rebuilt
- Return type:
- build_graph()¶
Build the multi-agent graph based on execution mode.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- classmethod from_agents(agents, name=None, execution_mode=ExecutionMode.SEQUENCE, **kwargs)¶
Create MultiAgent from a list or dict of agents.
- Parameters:
agents (list[haive.agents.base.agent.Agent] | dict[str, haive.agents.base.agent.Agent]) – List or dict of agents to coordinate
name (str | None) – Optional name for the multi-agent
execution_mode (ExecutionMode) – How to execute agents
**kwargs – Additional configuration
- Returns:
MultiAgentV2 instance
- Return type:
- classmethod from_config(config, agents=None)¶
Create MultiAgent from configuration dict.
- get_agent(agent_name)¶
Get an agent by name.
- Parameters:
agent_name (str)
- Return type:
haive.agents.base.agent.Agent | None
- classmethod rebuild_with_agents(original, new_agents, **kwargs)¶
Rebuild MultiAgent with new agents.
- Parameters:
original (MultiAgentV2) – Original MultiAgent to rebuild from
new_agents (list[haive.agents.base.agent.Agent] | dict[str, haive.agents.base.agent.Agent]) – New agents to use
**kwargs – Additional config overrides
- Returns:
New MultiAgentV2 instance
- Return type:
- remove_agent(agent_name, rebuild=True)¶
Remove an agent and optionally rebuild.
- Parameters:
- Returns:
Self or new instance if rebuilt
- Return type:
- setup_agent()¶
Setup hook - MultiAgent uses MultiAgentState by default.
- Return type:
None
- setup_multi_agent()¶
Set up the multi-agent system.
- Return type: