← All AI Agents & Tool Use modules

Module 5 — Planning Before Acting

Reasoning across steps · hands-on · about 30 minutes.

So far the agent decided its next move one step at a time. That works for short tasks, but for a goal with several parts — "brief me for my trip: the weather there, the population, and what country it's in" — charging ahead step by step risks losing the thread, repeating work, or stopping early. A more reliable approach borrows a habit from good problem-solving: plan first, then execute. Write the whole list of subtasks up front, then carry them out in order.

Decompose the goal, then work the list

Planning has two phases:

  1. Decompose — break the big goal into a numbered list of small, concrete subtasks, each one a single tool call the agent knows how to do.
  2. Execute — work down the list in order, doing one subtask at a time and checking it off, until the plan is complete.

Writing the plan first gives the agent a map. It can see how many steps remain, it will not forget a part of the request, and — in more advanced agents — it can notice when a step fails and revise the plan. "Plan-then-execute" is the difference between an agent that wanders and one that reliably finishes a structured job.

Watch the agent plan, then execute

Pick a goal. The agent first writes a plan — a numbered list of subtasks. Then press Execute next to run the subtasks one at a time and watch each get checked off as its tool returns a result, or Run plan to complete the whole list.

This activity needs JavaScript. The lesson below still covers everything.

Plan-then-execute in code — read only, nothing to install
# phase 1: the model writes a plan — a list of subtasks
plan = decompose(goal)
# e.g. ["weather(Tokyo)", "population(Tokyo)", "lookup(Tokyo country)"]

# phase 2: execute each subtask in order, collecting results
results = []
for step in plan:
    results.append(run_tool(step))     # do one subtask, check it off

answer = summarize(goal, results)      # combine into the final reply

Some agents re-plan after every step (more flexible, more model calls); others write one plan and follow it (cheaper, more predictable). Both start by turning a vague goal into an explicit list of doable steps.

AI anchor — why "think step by step" became "make a plan" The leap from a chatbot to an agent that can handle a real, multi-part job is largely about planning. Research assistants that write an outline before gathering sources, coding agents that list the files to change before editing, "deep research" modes that lay out a question plan first — all are decompose-then-execute. A good plan keeps a long task coherent and lets the agent recover when one step goes wrong, instead of blundering forward.

Check your understanding

A few questions about planning. You will get a score.

This activity needs JavaScript.

Why this matters next Every plan step above was a tool call — but how does the agent pick which tool fits each subtask? Module 6 builds the router: the decision that sends each request to the calculator, the lookup, the calendar, or search.
One-sentence summary: for a multi-part goal, a reliable agent plans first — it decomposes the goal into a numbered list of single-tool subtasks, then executes them in order, checking each off — so it stays coherent, covers the whole request, and can recover when a step fails.

Next: Routing to the Right Tool →