agents.planning.clean_plan_execute

Clean Plan and Execute Implementation following LangGraph patterns.

This module provides the recommended implementation for simple sequential planning tasks. It follows the standard LangGraph Plan and Execute pattern with minimal complexity and clear, understandable routing logic.

## Key Features

  • Simple Models: Clean Plan and Act models without overcomplication

  • MultiAgentBase: Leverages multi-agent orchestration for clean separation

  • React Agent: Uses ReactAgent for tool-based step execution

  • Simple Agent: Uses SimpleAgent for planning and replanning

  • Clean Routing: Straightforward routing logic with clear decision points

## Architecture

Planner (SimpleAgent)

Executor (ReactAgent) ←─┐

↓ │

Route Decision ─────────┘

Replanner (SimpleAgent)

END or back to Executor

## Usage

### Basic Example

from haive.agents.planning import create_simple_plan_execute from haive.tools import calculator_tool

agent = create_simple_plan_execute(tools=[calculator_tool]) result = agent.run(“Calculate the compound interest on $1000 at 5% for 10 years”)

### Advanced Example

from haive.agents.planning import create_clean_plan_execute_agent

agent = create_clean_plan_execute_agent(

name=”MyPlanner”, planner_model=”gpt-4”, executor_model=”gpt-3.5-turbo”, tools=[web_search, calculator, file_reader]

)

result = agent.run(“Research tech stocks and calculate potential returns”)

## When to Use

Use this implementation when: - You need simple, sequential planning - Tasks have clear step-by-step execution - You want minimal complexity - You’re starting with planning agents

Consider alternatives when: - You need parallel execution (use ReWOO) - You need complex replanning logic (use proper_plan_execute) - You need DAG-based planning (use llm_compiler)

## Status: Recommended for Simple Planning Tasks

This is the go-to implementation for straightforward planning needs.

Classes

Act

Action to take - either respond or replan.

Plan

A simple plan with list of steps.

PlanExecuteState

Clean state schema for Plan and Execute.

Functions

create_clean_plan_execute_agent([name, planner_model, ...])

Create a clean Plan and Execute agent following LangGraph patterns.

create_simple_plan_execute([tools])

Create a simple Plan and Execute agent with default settings.

route_after_replan(state)

Route after replanning decision.

should_continue(state)

Decide whether to continue executing or move to replanning.

Module Contents

class agents.planning.clean_plan_execute.Act(/, **data)

Bases: pydantic.BaseModel

Action to take - either respond or replan.

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.clean_plan_execute.Plan(/, **data)

Bases: pydantic.BaseModel

A simple plan with list of steps.

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.clean_plan_execute.PlanExecuteState(messages=None, **data)

Bases: haive.core.schema.prebuilt.messages.messages_state.MessagesState

Clean state schema for Plan and Execute.

Initialize with optional messages parameter for compatibility.

Parameters:

messages (list[dict[str, Any]] | None)

agents.planning.clean_plan_execute.create_clean_plan_execute_agent(name='PlanExecute', planner_model='gpt-4o-mini', executor_model='gpt-4o-mini', tools=None)

Create a clean Plan and Execute agent following LangGraph patterns.

Parameters:
  • name (str) – Name for the agent

  • planner_model (str) – Model for planning

  • executor_model (str) – Model for execution

  • tools (list | None) – Tools available to executor

Returns:

Clean Plan and Execute system

Return type:

MultiAgentBase

agents.planning.clean_plan_execute.create_simple_plan_execute(tools=None)

Create a simple Plan and Execute agent with default settings.

Parameters:

tools (list | None)

Return type:

haive.agents.multi.archive.enhanced_base.MultiAgentBase

agents.planning.clean_plan_execute.route_after_replan(state)

Route after replanning decision.

Parameters:

state (PlanExecuteState)

Return type:

str

agents.planning.clean_plan_execute.should_continue(state)

Decide whether to continue executing or move to replanning.

Parameters:

state (PlanExecuteState)

Return type:

str