Module 5 — Planning Before Acting
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:
- 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.
- 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.
# 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.
Check your understanding
A few questions about planning. You will get a score.
This activity needs JavaScript.