By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Asking a model for a plan is easy. Getting one that is executable is the work. Treat the generated plan like any other model output: a draft to be checked.
errors = validate_plan(plan, tools)
if errors:
plan = model.plan(
goal,
tools,
feedback="Your previous plan was invalid:\n- " + "\n- ".join(errors),
)'Make the plan better' produces another plausible plan with the same defect. - s4 needs s3, which does not exist produces a fix.
When a step fails, you have three options and should choose deliberately:
| Option | When | Cost |
|---|---|---|
| Retry the step | Transient tool error | Low |
| Replan the remainder | A step returned something unexpected that invalidates later steps | One call, plus lost work |
| Stop and report | A required source is unavailable or a policy gate failed | Cheapest, most honest |
Key takeaways
Generate, validate, then repair with the specific errors.
One repair round is usually enough; two is the practical limit.
Replan only when a result invalidates later steps.
Allow the executor to stop with an honest partial answer.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.