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

ParallelReWOOAgent

Enhanced ReWOO agent with advanced parallel execution capabilities.

PlanTask

A task in the planning tree - simplified for agent-based execution.

ReWOOExecutorAgent

Agent that executes individual tasks with tool support.

ReWOOPlan

Complete execution plan with tasks and dependencies.

ReWOOPlannerAgent

Specialized agent for creating ReWOO plans.

ReWOOTreeAgent

ReWOO Tree Agent using proper MultiAgent composition.

ReWOOTreeState

State for ReWOO tree execution.

TaskPriority

Priority levels for tasks.

TaskStatus

Status of tasks in the planning tree.

TaskType

Types of tasks in the planning tree.

ToolAlias

Tool alias configuration for forced tool choice.

Functions

create_rewoo_agent_with_tools(tools[, tool_aliases, ...])

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 .

Parameters:
  • name (str) – [TODO: Add description]

  • max_parallelism (int) – [TODO: Add description]

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)

classmethod validate_id(v)

Validate task ID format.

Parameters:

v (str)

Return type:

str

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:
  • name (str) – [TODO: Add description]

  • tools (list[langchain_core.tools.BaseTool] | None) – [TODO: Add description]

  • tool_aliases (dict[str, ToolAlias] | None) – [TODO: Add description]

execute_task(task, context=None)

Execute a single task.

Parameters:
Return type:

Any

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)

add_task(task)

Add a task to the plan.

Parameters:

task (PlanTask)

Return type:

None

get_ready_tasks(completed_tasks)

Get tasks that are ready for execution.

Parameters:

completed_tasks (set[str])

Return type:

list[PlanTask]

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:
  • name (str) – [TODO: Add description]

  • available_tools (list[langchain_core.tools.BaseTool] | None) – [TODO: Add description]

create_plan(problem, context=None)

Create a ReWOO plan for the given problem.

Parameters:
Return type:

ReWOOPlan

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:
  • name (str) – [TODO: Add description]

  • available_tools (list[langchain_core.tools.BaseTool] | None) – [TODO: Add description]

  • tool_aliases (dict[str, ToolAlias] | None) – [TODO: Add description]

  • max_planning_depth (int) – [TODO: Add description]

  • max_parallelism (int) – [TODO: Add description]

add_tool_alias(alias, actual_tool, force_choice=True, **params)

Add a tool alias for forced tool choice.

Parameters:
  • alias (str)

  • actual_tool (str)

  • force_choice (bool)

async create_and_execute_plan(problem)

Create and execute a plan for the given problem.

Parameters:

problem (str)

Return type:

dict[str, Any]

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

Bases: str, enum.Enum

Priority levels for tasks.

Initialize self. See help(type(self)) for accurate signature.

class agents.planning.rewoo_tree_agent_v2.TaskStatus

Bases: str, enum.Enum

Status of tasks in the planning tree.

Initialize self. See help(type(self)) for accurate signature.

class agents.planning.rewoo_tree_agent_v2.TaskType

Bases: str, enum.Enum

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)

classmethod validate_alias(v)

Validate alias format.

Parameters:

v (str)

Return type:

str

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.

Parameters:
  • tools (list[langchain_core.tools.BaseTool]) – List of tools available to the agent

  • tool_aliases (dict[str, str] | None) – Mapping of alias names to actual tool names

  • max_parallelism (int) – Maximum parallel executions

Returns:

Configured ReWOOTreeAgent

Return type:

ReWOOTreeAgent