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 evaluation

Good 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 plan

Sequential (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

StrategyCommon FailureMitigation
CoTReasoning drift over many stepsRe-anchor with a goal-check every N steps
ToTExponential cost on deep treesLimit depth to 2, use cheaper evaluator
Plan-and-ExecutePlan becomes stale after first errorEnable replan_on_error: true
HierarchicalOrchestrator misroutes tasksGive each sub-agent a precise system prompt
Key takeaways:
  • 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

StrategyLLM callsBest forFailure mode
ReAct (default)1 per stepTool-heavy, iterative tasksGets stuck in loops on ambiguous tasks
Plan-and-Execute1 plan + N executionTasks with clear decompositionBrittle if step 2 depends on step 1 output
Tree-of-ThoughtN branches × depthCreative/strategic decisionsVery expensive; overkill for most tasks
Hierarchical1 orchestrator + N sub-agentsCross-domain enterprise workflowsCoordination 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