agents.planning.rewoo_tree_agentΒΆ
ReWOO Tree-based Planning Agent with Parallelizable Execution.
This agent implements the ReWOO (Reasoning without Observation) methodology with tree-based planning for parallelizable execution. It features:
Hierarchical tree planning with recursive decomposition
Parallelizable node execution with proper dependencies
Tool aliasing and forced tool choice
Structured output models with field validators
Plan-and-execute pattern with dynamic recompilation
LLM Compiler inspired parallelization
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ΒΆ
A node in the planning tree representing a task. |
|
A tree structure representing the complete execution plan. |
|
ReWOO Tree-based Planning Agent with Parallelizable Execution. |
|
Enhanced state for ReWOO tree agent. |
|
Structured output for the ReWOO tree executor. |
|
Structured output for the ReWOO tree planner. |
|
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. |
Module ContentsΒΆ
- class agents.planning.rewoo_tree_agent.PlanNode(/, **data)ΒΆ
Bases:
pydantic.BaseModel
A node in the planning tree representing a task.
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)
- can_execute(completed_nodes)ΒΆ
Check if this node can be executed given completed nodes.
- mark_completed(result=None)ΒΆ
Mark the task as completed.
- Parameters:
result (Any)
- Return type:
None
- mark_started()ΒΆ
Mark the task as started.
- Return type:
None
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.planning.rewoo_tree_agent.PlanTree(/, **data)ΒΆ
Bases:
pydantic.BaseModel
A tree structure representing the complete execution plan.
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_parallelizable_nodes()ΒΆ
Get nodes organized by parallelizable execution levels.
- mark_node_completed(node_id, result=None)ΒΆ
Mark a node as completed.
- Parameters:
node_id (str)
result (Any)
- Return type:
None
- mark_node_failed(node_id, error)ΒΆ
Mark a node as failed.
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.planning.rewoo_tree_agent.ReWOOTreeAgent(**kwargs)ΒΆ
Bases:
haive.agents.base.agent.Agent
ReWOO Tree-based Planning Agent with Parallelizable Execution.
This agent implements the ReWOO methodology with enhancements: - Hierarchical tree planning with recursive decomposition - Parallelizable execution with dependency management - Tool aliasing for forced tool choice - Structured output models with validation - LLM Compiler inspired optimizations
Initialize ReWOO Tree Agent.
- add_tool_alias(alias, actual_tool, force_choice=True, **params)ΒΆ
Add a tool alias for forced tool choice.
- build_graph()ΒΆ
Build the execution graph for ReWOO tree agent.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- class agents.planning.rewoo_tree_agent.ReWOOTreeAgentState(/, **data)ΒΆ
Bases:
haive.core.schema.prebuilt.messages_state.MessagesState
Enhanced state for ReWOO tree agent.
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.ReWOOTreeExecutorOutput(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Structured output for the ReWOO tree executor.
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.ReWOOTreePlannerOutput(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Structured output for the ReWOO tree planner.
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)
- validate_consistency()ΒΆ
Validate consistency between plan components.
- Return type:
- model_configΒΆ
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class agents.planning.rewoo_tree_agent.TaskPriorityΒΆ
-
Priority levels for tasks.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent.TaskStatusΒΆ
-
Status of tasks in the planning tree.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent.TaskTypeΒΆ
-
Types of tasks in the planning tree.
Initialize self. See help(type(self)) for accurate signature.
- class agents.planning.rewoo_tree_agent.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].