Planning Strategies in AI Agents
How an agent plans before acting determines its effectiveness on complex tasks. A simple reactive loop works for linear tasks, but multi-step problems with branching choices need richer planning. OpenClaw supports five planning strategies — from the default sequential loop to full hierarchical multi-agent pipelines.
Why Planning Matters
Without a plan, agents jump straight into action. This works for simple tasks but fails for problems that require:
- Breaking a goal into sub-tasks
- Deciding which path to take based on unknown information
- Distributing work across multiple specialised agents
- Recovering gracefully from partial failures
Chain-of-Thought (CoT)
CoT prompts the model to reason through each step explicitly before acting. The reasoning trace is included in the context for subsequent steps. It's the lightest planning strategy — no extra LLM calls, just better prompting.
planning:
strategy: "cot"
cot_prompt: "Think step-by-step before deciding which tool to use."Tree-of-Thought (ToT)
ToT generates multiple candidate next steps (branches), evaluates each, and selects the best. It's much more thorough than CoT but uses significantly more tokens and time.
planning:
strategy: "tot"
tot_branches: 3 # Generate 3 candidate steps per node
tot_depth: 2 # Explore 2 levels deep
tot_evaluator: "gpt-4o-mini" # Cheaper model for evaluationGood for: creative problem solving, debugging complex systems, ambiguous problems with no obvious next step.
Plan-and-Execute
The agent first generates a complete multi-step plan, then executes each step in sequence. If a step fails, it can re-plan from the current state.
from openclaw import PlanAndExecuteAgent
agent = PlanAndExecuteAgent(
planner_model="gpt-4o",
executor_model="gpt-4o-mini", # Cheaper model for execution
tools=["web_search", "code_exec", "file_writer"],
)
result = agent.run(
"Research the top 5 Python testing frameworks, compare them, "
"and write a Markdown summary to report.md"
)
print(result.plan) # Show the generated planSequential (Default)
The default strategy in OpenClaw: observe → think → act → repeat until done. Simple, transparent, and sufficient for most single-agent tasks. No upfront planning — the agent adapts based on what it observes.
Hierarchical Multi-Agent
An orchestrator agent delegates to specialised sub-agents. Each sub-agent runs its own loop and returns a structured result to the orchestrator.
planning:
strategy: "hierarchical"
orchestrator_model: "gpt-4o"
sub_agents:
- name: "researcher"
model: "gpt-4o-mini"
tools: ["web_search", "wiki"]
- name: "coder"
model: "gpt-4o"
tools: ["code_exec", "file_writer"]
- name: "writer"
model: "gpt-4o-mini"
tools: ["file_writer"]Planning Failure Modes
| Strategy | Common Failure | Mitigation |
|---|---|---|
| CoT | Reasoning drift over many steps | Re-anchor with a goal-check every N steps |
| ToT | Exponential cost on deep trees | Limit depth to 2, use cheaper evaluator |
| Plan-and-Execute | Plan becomes stale after first error | Enable replan_on_error: true |
| Hierarchical | Orchestrator misroutes tasks | Give each sub-agent a precise system prompt |
- Sequential planning is sufficient for most tasks — start simple.
- Use Plan-and-Execute for complex multi-step tasks with a clear final deliverable.
- Tree-of-Thought is powerful but expensive — use only when other strategies fail.
- Hierarchical planning is the right model for tasks that span multiple domains.
Comparing Planning Strategies
| Strategy | LLM calls | Best for | Failure mode |
|---|---|---|---|
| ReAct (default) | 1 per step | Tool-heavy, iterative tasks | Gets stuck in loops on ambiguous tasks |
| Plan-and-Execute | 1 plan + N execution | Tasks with clear decomposition | Brittle if step 2 depends on step 1 output |
| Tree-of-Thought | N branches × depth | Creative/strategic decisions | Very expensive; overkill for most tasks |
| Hierarchical | 1 orchestrator + N sub-agents | Cross-domain enterprise workflows | Coordination overhead; network latency |
Plan-and-Execute Pattern
Plan-and-Execute separates reasoning from acting, which improves reliability for tasks with multiple deterministic steps. The planning phase creates a structured task list; the execution phase works through it linearly with minimal re-planning.
from openclaw import Agent
planner = Agent(model="gpt-4o",
system_prompt="You are a planning agent. Decompose the task into numbered steps."
)
plan = planner.run(f"Plan: {user_request}").output
executor = Agent(model="gpt-4o", tools=[search, code_exec, file_write])
result = executor.run(f"Execute this plan:\n{plan}").output