agents.planning.rewoo_tree_agent_v2¶
ReWOO Tree-based Planning Agent V2 - Using MultiAgent Pattern.
This agent implements the ReWOO (Reasoning without Observation) methodology using proper agent composition without manual node creation. All nodes are created automatically by wrapping agents.
Key improvements: - No manual node functions - everything is agents - Uses MultiAgent pattern for composition - Automatic parallelization through agent dependencies - Tool aliasing and forced tool choice - Structured output models with field validators - Recursive planning through agent composition
Reference: - ReWOO: https://langchain-ai.github.io/langgraph/tutorials/rewoo/rewoo/#solver - LLM Compiler: https://langchain-ai.github.io/langgraph/tutorials/llm-compiler/LLMCompiler/
Classes¶
Enhanced ReWOO agent with advanced parallel execution capabilities. |
|
A task in the planning tree - simplified for agent-based execution. |
|
Agent that executes individual tasks with tool support. |
|
Complete execution plan with tasks and dependencies. |
|
Specialized agent for creating ReWOO plans. |
|
ReWOO Tree Agent using proper MultiAgent composition. |
|
State for ReWOO tree execution. |
|
Priority levels for tasks. |
|
Status of tasks in the planning tree. |
|
Types of tasks in the planning tree. |
|
Tool alias configuration for forced tool choice. |
Functions¶
|
Factory function to create a ReWOO agent with tools. |
Module Contents¶
- class agents.planning.rewoo_tree_agent_v2.ParallelReWOOAgent(name='parallel_rewoo', max_parallelism=8, **kwargs)¶
Bases:
ReWOOTreeAgent
Enhanced ReWOO agent with advanced parallel execution capabilities.
This version focuses on maximizing parallelization by: - Creating multiple executor instances dynamically - Using Send objects for true parallel execution - Optimizing task distribution - Real-time performance tracking
Init .
- class agents.planning.rewoo_tree_agent_v2.PlanTask(/, **data)¶
Bases:
pydantic.BaseModel
A task in the planning tree - simplified for agent-based 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)
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.planning.rewoo_tree_agent_v2.ReWOOExecutorAgent(name='rewoo_executor', tools=None, tool_aliases=None, **kwargs)¶
Bases:
haive.agents.react.agent.ReactAgent
Agent that executes individual tasks with tool support.
Init .
- Parameters:
- class agents.planning.rewoo_tree_agent_v2.ReWOOPlan(/, **data)¶
Bases:
pydantic.BaseModel
Complete execution plan with tasks and dependencies.
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)
- get_ready_tasks(completed_tasks)¶
Get tasks that are ready for execution.
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.planning.rewoo_tree_agent_v2.ReWOOPlannerAgent(name='rewoo_planner', available_tools=None, **kwargs)¶
Bases:
haive.agents.simple.agent.SimpleAgent
Specialized agent for creating ReWOO plans.
Init .
- Parameters:
- class agents.planning.rewoo_tree_agent_v2.ReWOOTreeAgent(name='rewoo_tree_agent', available_tools=None, tool_aliases=None, max_planning_depth=3, max_parallelism=4, **kwargs)¶
Bases:
haive.agents.multi.agent.MultiAgent
ReWOO Tree Agent using proper MultiAgent composition.
This agent creates and executes tree-based plans using multiple specialized agents: - Planner: Creates structured execution plans - Executor: Executes individual tasks with tools - Coordinator: Manages parallel execution - Validator: Validates results
Init .
- Parameters:
- add_tool_alias(alias, actual_tool, force_choice=True, **params)¶
Add a tool alias for forced tool choice.
- class agents.planning.rewoo_tree_agent_v2.ReWOOTreeState(/, **data)¶
Bases:
haive.core.schema.prebuilt.multi_agent_state.MultiAgentState
State for ReWOO tree 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.planning.rewoo_tree_agent_v2.TaskPriority¶
-
Priority levels for tasks.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent_v2.TaskStatus¶
-
Status of tasks in the planning tree.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent_v2.TaskType¶
-
Types of tasks in the planning tree.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent_v2.ToolAlias(/, **data)¶
Bases:
pydantic.BaseModel
Tool alias configuration for forced tool choice.
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)
- model_config¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- agents.planning.rewoo_tree_agent_v2.create_rewoo_agent_with_tools(tools, tool_aliases=None, max_parallelism=4)¶
Factory function to create a ReWOO agent with tools.