Planning for agents
Plan first or decide as you go — how to choose a planning pattern, and why plans fail.
What this guide covers
Planning means deciding the step sequence first, then executing step by step. The opposite is deciding as you go: each round the model looks only at the current situation and picks the next step. The two paradigms have no superiority — only fit — and the criterion is: can the number of steps be stated in advance.
Pattern one: fixed paths
Anthropic calls systems with a predefinable flow workflows. Anthropic official text: "Workflows are systems where LLMs and tools are orchestrated through predefined code paths."
Anthropic official text: the contrasting agent is "LLMs dynamically direct their own processes and tool usage". The three planning patterns that follow:
Prompt chaining: decompose the task into a fixed sequence of subtasks, each step's output feeding the next. Anthropic official text: "Prompt chaining decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one." The price is latency; what you gain is each step becoming simpler and more controllable. The official advice adds programmatic checks (gates) at intermediate steps to confirm the flow is still on track.
Routing: classify first, then branch. Fits "inputs have clear categories, each category handled differently" scenarios.
Orchestrator-workers: a central LLM dynamically decomposes tasks, dispatches workers, then synthesizes results. Fits cases where subtasks cannot be enumerated in advance — like changing code: how many files to touch and how to change each one only becomes clear after seeing the task. The official docs draw the key difference from parallelization: Anthropic official text: "the key difference from parallelization is its flexibility— subtasks aren't pre-defined, but determined by the orchestrator based on the specific input."
Pattern two: decide as you go
When must you abandon a fixed flow? The official criterion:
"Agents can be used for open-ended problems where it's difficult or impossible to predict the required number of steps, and where you can't hardcode a fixed path."
If the step count cannot be stated, don't draw a flowchart. But deciding-as-you-go has three old problems: drifting off course, looping, quitting halfway. The matching engineering answer is adding a feedback loop to execution.
Anthropic's evaluator-optimizer is one LLM generating, another LLM evaluating and giving feedback, polishing in a loop. The two fit signals the official docs give: feedback can materially improve the output; the model can produce that feedback itself.
The Reflexion paper (arXiv 2303.11366) systematizes feedback. The agent verbally reviews task feedback, stores the reflection text in an episodic memory buffer, and reads the lessons before attempting a similar task next time. The paper reports 91% pass@1 on the HumanEval coding benchmark, beating GPT-4's 80% at the time. Note these are paper results on a specific benchmark, not a general promise.
Human checkpoints
Making the flow interruptible and resumable is the most practical engineering investment in planning. LangGraph's official docs list human-in-the-loop alongside fault tolerance and time travel as checkpointer uses: only with state snapshots can you pause at a step for human approval and continue from the origin.
Key steps go to the flow, dangerous steps stay with humans. How to judge a dangerous step: irreversible, costs money, or goes outbound.
Why plans fail
- Stale plans: the environment changed, the old plan runs to the end anyway.
- Over-planning: writing a five-thousand-word plan for something doable in five minutes.
- Fake feedback: the evaluator only says "looks good", the optimization loop spins in place.
- No recovery point: it crashes halfway and you can only start over.
The general principle, from Anthropic official text: "Success in the LLM space isn't about building the most sophisticated system. It's about building the right system for your needs." Start from the simplest prompt with solid evaluation; add multi-step systems only when the simple approach stops being enough.
Sources
| Source | URL |
|---|---|
| Anthropic engineering blog · Building effective agents (official page verified via WebFetch on 2026-10-30) | https://www.anthropic.com/engineering/building-effective-agents |
| Reflexion paper (arXiv 2303.11366, abstract page direct-fetched 2026-10-30) | https://arxiv.org/abs/2303.11366 |
| LangGraph official docs · Persistence (direct fetch 200 on 2026-10-30) | https://docs.langchain.com/oss/python/langgraph/persistence |
Source snapshot: 2026-10-30; item-specific rechecks and their scope are recorded in the text or source notes. Features and terms may change; check the original sources before use.