Topic 3
Plan, validate, then execute
An agent can plan and act in one breath: think step by step, then do each step as it goes. AI Engineering (Ch. 6, "Planning overview") points out the risk. What if the model comes up with a 1,000-step plan that doesn't even reach the goal? Without oversight, it can run for hours, spending money on API calls, before anyone notices.
The book's remedy is to decouple planning from execution: generate a plan first, validate it, and only then run it.
Predict first
Scroll sideways to see the whole diagram
AI Engineering: to avoid fruitless execution, decouple planning from execution. First ask for a plan.
Text version
- AI Engineering: to avoid fruitless execution, decouple planning from execution. First ask for a plan.
- Validate it before anything runs. Simple heuristics: reject plans with invalid actions, or with more than some number of steps. A model can also judge whether the plan seems reasonable.
- A rejected plan costs one model call. A bad plan that ran could cost hours of tool calls, or a write you can't undo.
- Only a validated plan executes, and its outcome is evaluated in turn. The plan can cover the whole task or just the next subtask.
If the plan is rejected, ask for another. If it passes, execute it, calling tools as needed, and evaluate the outcome. The plan doesn't have to cover the whole task: it can be a small plan for the next subtask.
The book notes two costs and options:
- Generating several plans in parallel and picking the best is faster than generating them one at a time, but costs more: another latency/cost trade-off.
- Intent classification helps planning by working out what the user is actually trying to do, which tells the agent which tools it needs. The book adds that an intent classifier should be able to label requests as irrelevant, so the agent declines them instead of spending compute on impossible plans.
Quick check