Plan-Then-Execute Pattern
Has the LLM fix the full sequence of tool calls before it reads untrusted data, then runs that sequence so tool outputs change only parameters
Add to Pack
Saved locally in this browser for now.
Cite This Pattern
Nikola Balic (@nibzard) (2026). Plan-Then-Execute Pattern. In *Awesome Agentic Patterns*. Retrieved October 14, 2026, from https://agentic-patterns.com/patterns/plan-then-execute-pattern
@misc{agentic_patterns_plan-then-execute-pattern,
title = {Plan-Then-Execute Pattern},
author = {Nikola Balic (@nibzard)},
year = {2026},
howpublished = {\url{https://agentic-patterns.com/patterns/plan-then-execute-pattern}},
note = {Awesome Agentic Patterns}
} Use when
- Tool outputs contain untrusted content that can carry prompt injections
- The set of actions is known up front but parameters vary
- Complex tasks benefit from a reviewed plan before execution
Avoid when
- The next action depends on what earlier tool results reveal
- Poisoned output content, such as a bad email body, is the main risk
- Simple task that a capable model can one-shot
Problem
When planning and execution are interleaved in one loop, untrusted tool outputs can influence which action is selected next. That makes the control flow itself attackable: a malicious intermediate result can redirect the agent into unsafe tools or unauthorized operations.
Solution
Split reasoning into two phases:
- Plan phase – LLM generates a fixed sequence of tool calls before it sees any untrusted data.
- Execution phase – Controller runs that exact sequence. Tool outputs may shape parameters, but cannot change which tools run.
This separates strategic decisions from data-dependent execution. The planner commits to a bounded action graph up front, and the executor enforces that graph deterministically, which preserves flexibility on arguments while protecting control-flow integrity.
Benefits: Fixing the action sequence up front keeps untrusted tool output out of control-flow decisions. He et al. (2025) study plan-then-execute daily-assistant agents empirically (N = 248) across tasks with different risk levels.
plan = LLM.make_plan(prompt) # frozen list of calls
for call in plan:
result = tools.run(call)
stash(result) # outputs isolated from planner
How to use it
Great for email-and-calendar bots, SQL assistants, code-review helpers—any task where the action set is known but parameters vary.
Claude Code Plan Mode
Claude Code implements this pattern through "plan mode" which shifts the agent into planning-only mode:
- User shifts to plan mode: Explicitly request planning (e.g., shift+tab in Claude Code CLI)
- Agent generates detailed plan: Creates step-by-step approach without executing
- Human reviews and approves: Can modify plan before execution
- Execution phase: Agent follows the approved plan
Effectiveness:
- Can 2-3x success rates for complex tasks by aligning on approach first
- Prevents wasted work from wrong assumptions
- Allows human expertise to guide agent execution
Dynamic boundary:
The threshold of what requires planning changes with each model generation:
"The boundary changes with every model in a surprising way. Newer models are more intelligent, so the boundary of what you need plan mode for got pushed out a little bit. Before you used to need to plan, now you don't." —Boris Cherny (Anthropic)
This means simpler tasks that once required planning can now be one-shot with more capable models (e.g., Sonnet 4.5 vs. Opus 4.1).
LangGraph Plan-and-Execute
The archived langchain.experimental.plan_and_execute package has been superseded by LangGraph, which implements this pattern with separate planner and executor nodes over a shared state graph. See the LangGraph plan-and-execute tutorial.
Trade-offs
- Pros: Strong control-flow integrity; moderate flexibility.
- Cons: Content of outputs can still be poisoned (e.g., bad email body).
References
- Beurer-Kellner et al. (2025), §3.1 (2) Plan-Then-Execute.
- He et al. (2025), "Plan-Then-Execute: An Empirical Study of User Trust and Team Performance When Using LLM Agents As A Daily Assistant" – https://arxiv.org/abs/2502.01390
- LangGraph plan-and-execute tutorial: https://langchain-ai.github.io/langgraph/tutorials/plan-and-execute/plan-and-execute/
- Boris Cherny (Anthropic): "Plan mode... you kind of have to understand the limits and where you get in the loop. Plan mode can 2-3x success rates pretty easily if you align on the plan first."
- Boris Cherny: "The boundary changes with every model... newer models are more intelligent so the boundary of what you need plan mode for got pushed out."
- AI & I Podcast: How to Use Claude Code Like the People Who Built It
- Related patterns: Discrete Phase Separation splits one task into separate research, planning, and implementation conversations with fresh context; this pattern freezes a single plan before untrusted tool output arrives.