agents.planning.proper_plan_execute¶
Proper Plan & Execute Implementation - Full-Featured Planning with Advanced Routing.
This module provides the advanced implementation for complex planning tasks that require sophisticated routing, state management, and search integration. It builds on the clean implementation with additional capabilities.
## Key Features
Advanced State Management: Rich state tracking with PlanExecuteState
Search Integration: Built-in web search capabilities via duckduckgo
Complex Routing: Sophisticated decision logic for replanning
Execution Tracking: Detailed tracking of step execution and results
Reusable Components: Leverages existing p_and_e models and prompts
## Architecture
- Planner (SimpleAgent with Plan model)
↓
- Executor (ReactAgent with tools + ExecutionResult)
↓
- Routing Decision (should_continue)
├──→ Continue: back to Executor ├──→ Replan: to Replanner └──→ End: final answer
↓
- Replanner (SimpleAgent with Act model)
↓
- Routing Decision (route_after_replan)
├──→ Execute: back to Executor └──→ End: final answer
## Usage
- ### With Search Integration
from haive.agents.planning import create_plan_execute_with_search
- agent = create_plan_execute_with_search(
name=”research_planner”, planner_model=”gpt-4”, executor_model=”gpt-3.5-turbo”
)
- result = agent.run(
“Research the latest AI developments and create a summary report”
)
- ### Custom Configuration
from haive.agents.planning import create_proper_plan_execute from haive.tools import custom_api_tool, database_tool
- agent = create_proper_plan_execute(
name=”data_planner”, planner_model=”gpt-4”, executor_model=”gpt-4”, tools=[custom_api_tool, database_tool], max_replanning_steps=5, allow_parallel_execution=True
)
result = agent.run(“Analyze customer data and generate insights”)
## Advanced Features
### State Processing Functions - process_planner_output: Extracts and validates plans - process_executor_output: Tracks execution results - process_replanner_output: Handles replanning decisions
### Routing Logic - should_continue: Determines next step after execution - route_after_replan: Routes after replanning decision
## When to Use
âś… Use this implementation when: - You need sophisticated planning with search - Complex routing logic is required - Detailed execution tracking is important - You need production-ready error handling
❌ Consider alternatives when: - Simple sequential planning suffices (use clean_plan_execute) - You need evidence-based planning (use ReWOO) - Tasks are very straightforward (use ReactAgent directly)
## Status: Recommended for Complex Planning Tasks
This is the go-to implementation for production systems requiring robust planning capabilities with search integration and advanced state management.
Functions¶
|
Create Plan & Execute agent with search tools. |
|
Create proper Plan & Execute agent using existing p_and_e components. |
|
Process executor output and update state. |
|
Process planner output and update state. |
|
Process replanner output and update state. |
|
Route after replanning: continue or end. |
|
Route after execution: continue, replan, or end. |
Module Contents¶
- agents.planning.proper_plan_execute.create_plan_execute_with_search(tools=None)¶
Create Plan & Execute agent with search tools.
- Parameters:
tools (list | None)
- Return type:
haive.agents.multi.archive.enhanced_base.MultiAgentBase
- agents.planning.proper_plan_execute.create_proper_plan_execute(name='ProperPlanExecute', planner_model='gpt-4o-mini', executor_model='gpt-4o-mini', replanner_model='gpt-4o-mini', tools=None)¶
Create proper Plan & Execute agent using existing p_and_e components.
- Parameters:
- Returns:
Complete Plan & Execute system
- Return type:
MultiAgentBase
- agents.planning.proper_plan_execute.process_executor_output(state, executor_result)¶
Process executor output and update state.
- Parameters:
state (haive.agents.planning.p_and_e.state.PlanExecuteState)
- Return type:
- agents.planning.proper_plan_execute.process_planner_output(state, planner_result)¶
Process planner output and update state.
- Parameters:
state (haive.agents.planning.p_and_e.state.PlanExecuteState)
- Return type:
- agents.planning.proper_plan_execute.process_replanner_output(state, replanner_result)¶
Process replanner output and update state.
- Parameters:
state (haive.agents.planning.p_and_e.state.PlanExecuteState)
- Return type:
- agents.planning.proper_plan_execute.route_after_replan(state)¶
Route after replanning: continue or end.
- Parameters:
state (haive.agents.planning.p_and_e.state.PlanExecuteState)
- Return type: