Planning & Decomposition
Break down complex tasks
The Problem: Without planning, AI jumps straight into tasks and often gets stuck. It's like trying to assemble IKEA furniture without looking at the instructions first — you might get it done, but you'll waste time and make mistakes.
The Solution: Think Before Acting
Planning is the ability of an agent to think about a goal before it starts acting — first sketching a roadmap of steps, then executing them one by one and updating the roadmap as it learns. Instead of reacting to each prompt in isolation, a planning agent holds an explicit, multi-step intention. This is closely related to chain-of-thought reasoning: the model writes out its thinking, but planning goes further by turning that thinking into an ordered list of concrete subtasks that drive real tool calls.
How it works
Under the hood, the agent runs an agent loop: it decomposes the goal into subtasks, picks the next action, executes it (search the web, run code, call an API), reads the result, and decides whether to continue, retry, or revise the plan. A common implementation is the ReAct pattern, where the model interleaves Thought → Action → Observation on every step. Some agents go a step further with "plan-and-execute": one model call drafts the whole plan, then a cheaper loop carries out each step — which saves tokens and keeps the agent on track over long tasks. In larger systems, an orchestrator can split the plan across multiple agents.
When to use it — and the tradeoffs
Reach for planning when a task needs several dependent steps, touches multiple tools, or runs long enough that drift becomes a problem. For a single question ("what's the capital of France?") planning is pure overhead. The main pitfalls: a flawed initial plan can cascade into wasted steps, every planning step costs extra tokens and latency, and agents that never re-evaluate will stubbornly follow a plan that reality has already broken — so good agents check after each step. Worked example: "Find three competitors to product X and email me a comparison." A planning agent decomposes this into (1) identify the product, (2) search for competitors, (3) gather pricing and features for each, (4) build a comparison table, (5) draft and send the email. If step 2 returns only two solid competitors, the agent updates the plan — widening the search instead of inventing a fake third one — and continues. That adaptive re-planning is exactly what stops it from hallucinating its way to a wrong answer.
Think of it like a chess player:
- 1. Analyze: "What's the current state of the board?"
- 2. Plan: "I need to control the center, then develop pieces..."
- 3. Break down: "First move pawn, then knight, then bishop..."
- 4. Execute: Make the first move
- 5. Re-evaluate: "Opponent moved. Do I need to adjust my plan?"
Planning Strategies
- Task decomposition: Break big goals into smaller subtasks
- Goal prioritization: Decide what's most important to do first
- Dependency tracking: Know which tasks depend on others
- Plan refinement: Update the plan based on new information
Fun Fact: The best planning agents use a technique called "Tree of Thoughts" — they explore multiple possible plans like branches on a tree, evaluate each one, and pick the best path. It's like mentally simulating different futures before deciding!
Try It Yourself!
Use the interactive planner below to see how an agent breaks down a complex task into steps. Watch how it creates and adjusts its plan as it works!
Frequently asked questions
What is planning in AI agents?
Planning is an agent's ability to map out a sequence of steps toward a goal before acting, then execute them one by one while updating the roadmap as it learns. Instead of reacting to each prompt in isolation, the agent holds an explicit multi-step intention and breaks a complex task into concrete subtasks.
How is planning different from chain-of-thought reasoning?
Chain-of-thought is the model writing out its reasoning before answering. Planning goes further: it turns that reasoning into an ordered list of subtasks that trigger real actions and tool calls, and it lets the agent revise the plan as steps complete and new information arrives.
When should an agent use planning, and when is it overkill?
Use planning when a task needs several dependent steps, touches multiple tools, or runs long enough that the agent could drift from the goal. For a single simple question like 'what is the capital of France?', planning is pure overhead in tokens and latency.
What are the main downsides and pitfalls of planning agents?
A flawed initial plan can cascade into many wasted steps; each planning step costs extra tokens and latency; and agents that never re-evaluate will stubbornly follow a plan that reality has already broken. Good agents check the result after each step and re-plan when needed.
Try it yourself
Interactive demo of this technique
Plan a three-day trip to London.
Day 1: British Museum. Day 2: Tower of London. Day 3: Walk along the Thames. Enjoy your trip!
Task decomposition:
- Logistics (transport, accommodation) — first priority
- Attractions — depends on (1)
- Daily routes — depends on (2) and geography
- Budget — depends on (1)+(2)
Dependencies: accommodation → area → daily routes
Structured plan:
Prep:
- Stay: near Central London (Zone 1)
- Transport: 3-day Oyster card
Day 1 (central):
- 10:00 British Museum (3 hrs) → lunch → 15:00 National Gallery (2 hrs) → West End show evening
Day 2 (riverside):
- 09:00 Tower of London (3 hrs) → Tower Bridge → Borough Market lunch → 15:00 Tate Modern → Thames walk
Day 3 (royal):
- 10:00 Buckingham Palace → Hyde Park lunch → Westminster Abbey → London Eye at sunset
Budget: ~350 GBP (accommodation 150 + tickets 80 + food 90 + transport 30)
A planning agent first analyzes dependencies between tasks, then builds the plan. This yields a structured result instead of a random list.
Create a free account to solve challenges
3 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path