agents.planning.enhanced_plan_execute_v5

Enhanced Plan & Execute V5 - Modern Haive Implementation with Custom Models and Agents.

This module provides a completely redesigned Plan & Execute implementation using the latest Haive architecture patterns, enhanced agents, and modern multi-agent orchestration.

## Key Features

  • MultiAgent: Latest multi-agent orchestration with state management

  • SimpleAgentV3: Enhanced planning and replanning with hooks system

  • ReactAgent: Advanced tool-based execution with real-time feedback

  • Custom Pydantic Models: Structured output designed for planning workflows

  • Modern Prompt Engineering: Context-aware prompts with structured templates

  • Comprehensive Monitoring: Full hooks system for execution tracking

  • Dynamic Recompilation: Real-time agent updates and tool management

## Architecture

PlannerAgentV3 (SimpleAgentV3)

↓ (structured Plan model)

ExecutorAgentV3 (ReactAgent) ←─┐

↓ (execution results) │

Routing Logic ──→ Continue ────┘

ReplannerAgentV3 (SimpleAgentV3)

↓ (structured Decision model)

Final Response or Loop Back

## Usage

### Basic Usage

from haive.agents.planning.enhanced_plan_execute_v5 import create_enhanced_plan_execute_v5

# Create with default tools agent = create_enhanced_plan_execute_v5() result = await agent.arun(“Calculate compound interest on $1000 at 5% for 10 years”)

# Create with custom tools from haive.tools import web_search_tool, calculator_tool agent = create_enhanced_plan_execute_v5(

name=”research_planner”, tools=[web_search_tool, calculator_tool]

) result = await agent.arun(“Research Tesla stock performance and calculate ROI”)

### Advanced Configuration
agent = create_enhanced_plan_execute_v5(

name=”advanced_planner”, planner_config=AugLLMConfig(

model=”gpt-4”, temperature=0.2, system_message=”You are an expert strategic planner.”

), executor_config=AugLLMConfig(

model=”gpt-4-turbo”, temperature=0.1

), tools=[custom_tool1, custom_tool2], max_iterations=10, enable_hooks=True

)

# Add custom hooks @agent.before_run def track_execution(context):

print(f”Starting planning workflow: {context.agent_name}”)

result = await agent.arun(“Complex multi-step research task”)

## Custom Models

The implementation uses custom Pydantic models designed specifically for planning:

  • TaskPlan: Structured plan with steps, priorities, and dependencies

  • ExecutionStatus: Rich execution tracking with success/failure states

  • PlanningDecision: Intelligent routing decisions with reasoning

  • PlanExecuteState: Enhanced state management for multi-agent coordination

## When to Use

Use this implementation when: - You need modern Haive architecture patterns - Enhanced monitoring and debugging is important - You want structured output and type safety - Dynamic agent recompilation is needed - Production-ready error handling is required

Consider alternatives when: - Simple tasks that don’t need planning (use ReactAgent directly) - Legacy compatibility is required (use clean_plan_execute) - Minimal complexity is preferred (use SimpleAgent)

## Status: Next-Generation Planning

This is the future of planning agents in Haive, showcasing the full power of the enhanced base agent pattern and modern multi-agent orchestration.

Submodules

Classes

EnhancedPlanExecuteState

Enhanced state for plan and execute workflow with rich tracking.

ExecutionResult

Rich execution result with detailed feedback.

PlanningDecision

Intelligent decision model for routing and replanning.

TaskPlan

Comprehensive task plan with metadata and tracking.

TaskStep

Individual step in a task plan with rich metadata.

Functions

create_enhanced_plan_execute_v5([name, ...])

Create enhanced Plan & Execute agent using modern Haive patterns.

create_research_plan_execute([tools])

Create a plan and execute agent optimized for research tasks.

create_simple_enhanced_plan_execute([tools])

Create a simple enhanced plan and execute agent with default settings.

get_next_step_id(plan, completed_steps)

Get the next step ID to execute based on plan and completed steps.

should_continue_enhanced(state)

Enhanced routing logic based on current state and decisions.

test_enhanced_plan_execute()

Test the enhanced plan and execute system.

Module Contents

class agents.planning.enhanced_plan_execute_v5.EnhancedPlanExecuteState(/, **data)

Bases: haive.core.schema.prebuilt.multi_agent_state.MultiAgentState

Enhanced state for plan and execute workflow with rich tracking.

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.enhanced_plan_execute_v5.ExecutionResult(/, **data)

Bases: pydantic.BaseModel

Rich execution result with detailed feedback.

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.enhanced_plan_execute_v5.PlanningDecision(/, **data)

Bases: pydantic.BaseModel

Intelligent decision model for routing and replanning.

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.enhanced_plan_execute_v5.TaskPlan(/, **data)

Bases: pydantic.BaseModel

Comprehensive task plan with metadata and tracking.

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.enhanced_plan_execute_v5.TaskStep(/, **data)

Bases: pydantic.BaseModel

Individual step in a task plan with rich metadata.

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)

agents.planning.enhanced_plan_execute_v5.create_enhanced_plan_execute_v5(name='EnhancedPlanExecuteV5', planner_config=None, executor_config=None, replanner_config=None, tools=None, max_iterations=20, enable_hooks=True)

Create enhanced Plan & Execute agent using modern Haive patterns.

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

  • planner_config (haive.core.engine.aug_llm.AugLLMConfig | None) – Configuration for the planning agent

  • executor_config (haive.core.engine.aug_llm.AugLLMConfig | None) – Configuration for the execution agent

  • replanner_config (haive.core.engine.aug_llm.AugLLMConfig | None) – Configuration for the replanning agent

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

  • max_iterations (int) – Maximum planning iterations

  • enable_hooks (bool) – Whether to enable the hooks system

Returns:

Complete planning workflow system

Return type:

MultiAgent

Examples

Basic usage:

agent = create_enhanced_plan_execute_v5()
result = await agent.arun("Calculate compound interest")

With custom configuration:

agent = create_enhanced_plan_execute_v5(
    name="research_planner",
    planner_config=AugLLMConfig(model="gpt-4", temperature=0.2),
    tools=[web_search_tool, calculator_tool],
    max_iterations=15
)
result = await agent.arun("Research and analyze market trends")
agents.planning.enhanced_plan_execute_v5.create_research_plan_execute(tools=None)

Create a plan and execute agent optimized for research tasks.

Parameters:

tools (list | None)

Return type:

haive.agents.multi.enhanced.multi_agent_v4.MultiAgent

agents.planning.enhanced_plan_execute_v5.create_simple_enhanced_plan_execute(tools=None)

Create a simple enhanced plan and execute agent with default settings.

Parameters:

tools (list | None)

Return type:

haive.agents.multi.enhanced.multi_agent_v4.MultiAgent

agents.planning.enhanced_plan_execute_v5.get_next_step_id(plan, completed_steps)

Get the next step ID to execute based on plan and completed steps.

Parameters:
Return type:

str | None

agents.planning.enhanced_plan_execute_v5.should_continue_enhanced(state)

Enhanced routing logic based on current state and decisions.

Parameters:

state (EnhancedPlanExecuteState)

Return type:

str

async agents.planning.enhanced_plan_execute_v5.test_enhanced_plan_execute()

Test the enhanced plan and execute system.