agents.multi.experiments.proper_list_multi_agent¶
Proper list multi-agent that uses MultiAgentState and AgentNodeV3.
from typing import Any This implementation properly leverages the existing infrastructure: - MultiAgentState for proper state management - AgentNodeV3 for agent execution with state projection - create_agent_node_v3 for creating agent nodes - Proper engine syncing and recompilation tracking
Classes¶
List multi-agent that uses MetaStateSchema for single agent embedding. |
|
List-based multi-agent that properly uses MultiAgentState and AgentNodeV3. |
Functions¶
|
Create a meta multi-agent. |
|
Create a sequential multi-agent. |
Module Contents¶
- class agents.multi.experiments.proper_list_multi_agent.MetaListMultiAgent¶
Bases:
haive.agents.base.agent.Agent
,haive.core.common.mixins.recompile_mixin.RecompileMixin
,collections.abc.Sequence
[haive.agents.base.agent.Agent
]List multi-agent that uses MetaStateSchema for single agent embedding.
This is useful when you want to embed a sequence of agents as a single unit within another agent’s state using the MetaStateSchema pattern.
Examples
# Create a meta multi-agent meta = MetaListMultiAgent("research_pipeline") meta.append(PlannerAgent()) meta.append(ResearchAgent()) meta.append(WriterAgent()) # This can be embedded in another agent's state parent_state = MetaStateSchema(agent=meta)
- append(agent)¶
Add agent to the list.
- Parameters:
agent (haive.agents.base.agent.Agent)
- Return type:
- build_graph()¶
Build graph that executes agents sequentially.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- setup_agent()¶
Setup the meta multi-agent.
- Return type:
None
- class agents.multi.experiments.proper_list_multi_agent.ProperListMultiAgent¶
Bases:
haive.agents.base.agent.Agent
,haive.core.common.mixins.recompile_mixin.RecompileMixin
,collections.abc.Sequence
[haive.agents.base.agent.Agent
]List-based multi-agent that properly uses MultiAgentState and AgentNodeV3.
This implementation: - Uses MultiAgentState as the state schema - Uses AgentNodeV3 for proper agent execution - Handles state projection and hierarchical management - Supports recompilation tracking - Maintains the natural list interface
Examples
multi = ProperListMultiAgent("research_team") multi.append(PlannerAgent("planner")) multi.append(ResearchAgent("researcher")) multi.append(WriterAgent("writer")) # Agents are stored in MultiAgentState.agents # Each agent gets its own state in MultiAgentState.agent_states # Output tracked in MultiAgentState.agent_outputs result = multi.invoke({"messages": [HumanMessage("Research AI")]})
- append(agent)¶
Add agent to the list.
- Parameters:
agent (haive.agents.base.agent.Agent)
- Return type:
- build_graph()¶
Build graph using AgentNodeV3 for proper state handling.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- get_agent_by_name(name)¶
Get agent by name.
- Parameters:
name (str)
- Return type:
haive.agents.base.agent.Agent | None
- insert(index, agent)¶
Insert agent at position.
- Parameters:
index (int)
agent (haive.agents.base.agent.Agent)
- Return type:
- model_post_init(__context)¶
Initialize after model creation.
- Return type:
None
- pop(index=-1)¶
Remove and return agent.
- Parameters:
index (int)
- Return type:
haive.agents.base.agent.Agent
- setup_agent()¶
Setup the multi-agent system.
- Return type:
None
- then(agent)¶
Add next agent in sequence.
- Parameters:
agent (haive.agents.base.agent.Agent)
- Return type:
- when(condition, routes)¶
Add conditional routing for the last agent.
- Parameters:
- Return type:
- agents.multi.experiments.proper_list_multi_agent.meta_multi(*agents, name='meta_multi')¶
Create a meta multi-agent.
- Parameters:
agents (haive.agents.base.agent.Agent)
name (str)
- Return type: