agents.planning.rewoo_tree_agent_v3¶

ReWOO Tree Agent V3 - Pure Agent Composition for Evidence-Based Planning.

This module provides the recommended implementation for research and evidence-based planning tasks. It represents the latest and most elegant approach to the ReWOO (Reasoning WithOut Observation) pattern using pure agent composition.

## Key Features

  • Pure Agent Composition: No manual nodes - agents are automatically wrapped

  • Evidence-Based Planning: Gather evidence before reasoning for better decisions

  • Parallel Execution: Evidence collection can happen in parallel

  • Tool Aliasing: Map abstract tool names to actual implementations

  • Type Safety: Full Pydantic validation and type checking

  • Clean Architecture: Leverages MultiAgent patterns for orchestration

## ReWOO Pattern

Problem Analysis

↓

Evidence Planning (what info needed?)

↓

Parallel Evidence Collection

↓

Reasoning with Evidence

↓

Final Answer

## Usage

### Basic Research Task

from haive.agents.planning import create_rewoo_agent_with_tools_v3 from haive.tools import web_search_tool, calculator_tool

agent = create_rewoo_agent_with_tools_v3(

name=”researcher”, tools=[web_search_tool, calculator_tool], model=”gpt-4”

)

result = agent.run(“What is the economic impact of renewable energy?”)

### Advanced with Tool Aliases
agent = ReWOOTreeAgent(

name=”advanced_researcher”, available_tools=[web_search, db_query, api_call], tool_aliases={

“research”: ToolAlias(

alias=”research”, actual_tool=”web_search”, force_choice=True

), “data”: ToolAlias(

alias=”data”, actual_tool=”db_query”, parameters={“limit”: 100}

)

}, max_parallelism=4

)

## When to Use

âś… Use ReWOO V3 when: - You need evidence-based decision making - Research tasks with multiple information sources - Tasks benefit from parallel evidence gathering - You want clean, maintainable code

❌ Consider alternatives when: - Simple sequential tasks (use clean_plan_execute) - No evidence gathering needed (use simple planning) - Very simple single-step tasks (use ReactAgent directly)

## Advantages over V2

  1. Cleaner Code: Pure agent composition, no manual node management

  2. Better Type Safety: Proper Pydantic field initialization

  3. More Maintainable: Follows framework patterns consistently

  4. Easier Testing: Standard agent testing patterns apply

## Status: Recommended for Research Tasks

This is the preferred implementation for any task requiring evidence gathering and research before making decisions.

Classes¶

ParallelReWOOAgent

Enhanced ReWOO agent with maximum parallelization.

ReWOOPlan

Structured plan output.

ReWOOTreeAgent

ReWOO Tree Agent using pure MultiAgent composition.

ReWOOTreeState

State for ReWOO tree execution.

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 ReWOO agent with tools.

Module Contents¶

class agents.planning.rewoo_tree_agent_v3.ParallelReWOOAgent(name='parallel_rewoo', max_parallelism=8, **kwargs)¶

Bases: ReWOOTreeAgent

Enhanced ReWOO agent with maximum parallelization.

Init .

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

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

class agents.planning.rewoo_tree_agent_v3.ReWOOPlan(/, **data)¶

Bases: pydantic.BaseModel

Structured plan output.

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_v3.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 pure MultiAgent composition.

No manual nodes - everything is agents that get automatically wrapped.

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 using pure MultiAgent flow.

Parameters:

problem (str)

Return type:

dict[str, Any]

class agents.planning.rewoo_tree_agent_v3.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_v3.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_v3.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.

Parameters:

v (str) – [TODO: Add description]

Returns:

Add return description]

Return type:

[TODO

model_config¶

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

agents.planning.rewoo_tree_agent_v3.create_rewoo_agent_with_tools(tools, tool_aliases=None, max_parallelism=4)¶

Factory function to create ReWOO agent with tools.

Parameters:
  • tools (list[langchain_core.tools.BaseTool])

  • tool_aliases (dict[str, str] | None)

  • max_parallelism (int)

Return type:

ReWOOTreeAgent