Agentic Engineering from First Principles All chaptersLecturesLabDownload the book
Part III · Making Agents Think and Work

Chapter 12: Planning

Central questionWhen does deciding a sequence before acting improve an agent, and when does following that sequence become a liability?

Lecture

Chapter principle

A plan is a hypothesis about the future. So planning should be judged by the improvement it creates in task performance, coordination or resource use. Not by how sophisticated the generated plan looks.

Key takeaways

Experiments

Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.

Experiment 23: Check a plan before running it

Can checking a plan before it runs catch its mistakes?

A real model acts as a planner. The goal: find the price of 3 units of product A and 2 units of product B, then compute the total. Two tools exist: a price lookup, which gives prices in euros, and a calculator. The model replies with a whole plan, a list of steps, before anything runs. Software then checks that every step uses a tool that exists, and only then runs the plan. The model plans three times for the total, then three times for the total in US dollars. No tool can turn euros into dollars. This is a recorded run of a real model. A new run may produce different plans.

Experiment 24: Plan, execute, replan

What should an agent do when its plan stops matching the world?

A car must get from the start to D. Route A is shorter than route B, but route A is blocked, and nobody knows that at the start. Three controllers are compared, each allowed four moves. Reactive: a real model chooses one move at a time and sees what each move did. Plan-first: a real model plans the whole route, and the program follows the plan no matter what. Plan and replan: the same, but a failed move sends the planner back to work with what was learned. This is a recorded run of a real model. A new run may differ.

All the code for this chapter: github.com/agentic-engineering-book/code

This is Chapter 12 of Agentic Engineering from First Principles: thirty chapters, a case study and fifty-nine executable experiments, from a single model call to controlled, self-improving agents.
Download the bookBrowse all chapters
← Chapter 11: ReActChapter 13: Reflection →