Agent Planning
Enable agents to break down complex tasks into executable steps before acting
Planning enables agents to think before acting – decomposing complex tasks into manageable steps, then executing them systematically.
graph LR
subgraph "Planning Flow"
Task[📋 Complex Task] -->|1\. Analyze| Planner[🧠 Planner]
Planner -->|2\. Decompose| Steps[📝 Steps]
Steps -->|3\. Execute| Agent[🤖 Agent]
Agent -->|4\. Complete| Result[✅ Result]
end
classDef task fill:#6366F1,stroke:#7C90A0,color:#fff
classDef planner fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
class Task,Steps task
class Planner planner
class Agent,Result agentQuick Start
- Enable Planning
python from praisonaiagents import Agent agent = Agent( name="Planner Agent", instructions="You solve complex problems step by step", planning=True # Enable planning ) agent.start("Build a REST API with authentication") - With Configuration
python from praisonaiagents import Agent, PlanningConfig agent = Agent( name="Advanced Planner", instructions="You are a strategic problem solver", planning=PlanningConfig( llm="gpt-4o", # Use powerful model for planning reasoning=True, # Show reasoning process auto_approve=False, # Require approval before execution ) )
How Planning Works
sequenceDiagram
participant User
participant Agent
participant Planner
participant Executor
User->>Agent: Complex task
Agent->>Planner: Analyze task
Note over Planner: 1. Understand goal
Note over Planner: 2. Identify subtasks
Note over Planner: 3. Order dependencies
Planner-->>Agent: Step-by-step plan
opt Auto-approve disabled
Agent-->>User: Show plan for approval
User->>Agent: Approve/modify
end
loop For each step
Agent->>Executor: Execute step
Executor-->>Agent: Step result
end
Agent-->>User: Final resultThe Planning Process
| Phase | What Happens | Output |
|---|---|---|
| Analyze | Understand the task requirements | Goal definition |
| Decompose | Break into subtasks | List of steps |
| Order | Determine dependencies | Execution order |
| Execute | Run each step | Intermediate results |
| Synthesize | Combine results | Final output |
Configuration Options
from praisonaiagents import PlanningConfig
config = PlanningConfig(
llm="gpt-4o", # LLM for planning (can differ from execution)
tools=[search_tool], # Tools available during planning
reasoning=True, # Enable reasoning display
auto_approve=False, # Require user approval
read_only=False, # Read-only mode (no modifications)
)| Option | Type | Default | Description |
|---|---|---|---|
llm | str | None | LLM model for planning (uses agent’s LLM if not set) |
tools | list | None | Tools available during planning phase |
reasoning | bool | False | Show reasoning process |
auto_approve | bool | False | Auto-approve plans without confirmation. In non-interactive environments (no TTY on stdin), plans are auto-approved even when this is False. |
read_only | bool | False | Only allow read operations |
Non-interactive environments
flowchart TD
Plan[Plan ready] --> TTY{stdin is TTY?}
TTY -->|Yes| Prompt[Prompt user]
TTY -->|No| Auto[Auto-approve]
Prompt --> Execute[Execute plan]
Auto --> Execute
classDef phase fill:#189AB4,stroke:#7C90A0,color:#fff
classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef result fill:#10B981,stroke:#7C90A0,color:#fff
class Plan phase
class TTY,Prompt,Auto decision
class Execute resultForce explicit approval everywhere (e.g. fail CI instead of auto-approving):
import sys
from praisonaiagents.planning import ApprovalCallback
def deny_non_interactive(plan):
return sys.stdin is not None and sys.stdin.isatty()
handler = ApprovalCallback(approve_fn=deny_non_interactive)
# Pass handler into your planning flow where ApprovalCallback is acceptedPlanning Modes
graph TB
subgraph "Planning Modes"
Simple[🎯 Simple<br/>planning=True]
Config[⚙️ Configured<br/>PlanningConfig]
ReadOnly[🔒 Read-Only<br/>read_only=True]
end
Simple -->|"Default settings"| Execute[Execute Plan]
Config -->|"Custom LLM, tools"| Execute
ReadOnly -->|"No modifications"| Execute
classDef mode fill:#189AB4,stroke:#7C90A0,color:#fff
classDef exec fill:#10B981,stroke:#7C90A0,color:#fff
class Simple,Config,ReadOnly mode
class Execute execSimple Planning
# Just enable it
agent = Agent(
instructions="You are a helpful assistant",
planning=True
)Configured Planning
# With specific settings
agent = Agent(
instructions="You are a code architect",
planning=PlanningConfig(
llm="gpt-4o",
reasoning=True,
auto_approve=True,
)
)Read-Only Planning
# Safe mode - no file modifications
agent = Agent(
instructions="You analyze code",
planning=PlanningConfig(
read_only=True, # Only read operations allowed
)
)Multi-Agent Planning
Enable planning for multi-agent workflows:
from praisonaiagents import Agent, Task, AgentTeam
researcher = Agent(name="Researcher", instructions="Research topics")
writer = Agent(name="Writer", instructions="Write content")
team = AgentTeam(
agents=[researcher, writer],
planning=True, # Enable planning for the workflow
)
team.start("Write a blog post about AI trends")graph LR
subgraph "Multi-Agent Planning"
Task[📋 Task] --> Planner[🧠 Planner]
Planner --> Plan[📝 Plan]
Plan --> A1[🤖 Agent 1]
Plan --> A2[🤖 Agent 2]
A1 --> Result[✅ Result]
A2 --> Result
end
classDef task fill:#6366F1,stroke:#7C90A0,color:#fff
classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
class Task,Plan task
class Planner,A1,A2,Result agentWhen to Use Planning
✅ Use Planning For
- Complex multi-step tasks
- Tasks requiring coordination
- Code refactoring projects
- Research and analysis
- Content creation workflows
- Simple Q&A
- Single-step operations
- Real-time responses needed
- Trivial tasks
Best Practices
Use a powerful model for planning
Planning benefits from stronger reasoning. Use gpt-4o or similar for planning even if using a smaller model for execution.
Enable reasoning for complex tasks
Set reasoning=True to see the agent’s thought process and catch issues early.
Review plans before execution
Keep auto_approve=False for critical tasks to review and modify plans.
Use read-only mode for analysis
When analyzing code or data, use read_only=True to prevent accidental modifications.