Skip to content

// Foundations · ~2 min read

Plan-and-Execute

Reach for it when: you can sketch the whole plan before touching tools.

After this lesson you can: Write the plan up front, run it step by step, and decide when a replan is worth it.

// 60-second mental model

How to hold it in your head

Write the whole plan first. Then run the steps. Only replan when a step actually fails — not after every tool call.

Plan-and-Execute separates a planner (break the goal into ordered steps) from an executor (run the tools for each step). Common implementations, such as LangChain’s, ask a re-planner after each step or once the plan finishes. This lesson teaches a leaner variant that replans only when a step fails.

How this differs

ReAct decides every step after seeing the last tool result. Plan-and-Execute writes the plan first. Common versions, such as LangChain’s, check with a re-planner after each step; the version taught here replans only when a step fails, which saves planner calls when the steps are predictable.

// Mini architecture

Plan once → execute steps → replan only on failure

The user goal goes to a Planner, which writes a step list. An Executor runs the next step through a tool and gets the step result back. If a step failed, control goes back to the Planner to replan; if not, the Executor moves to the next step or the final answer.

Unlike ReAct, reasoning between every tool call is optional — the plan carries the sequence until reality breaks it.

// Mini-project

Multi-step research brief (stub)

Stub planner and executor

Goal: Produce a short brief from a fixed plan: search → outline → draft — replan only if a stub step returns failure.

  1. Accept a topic (for example, “how to choose a database”).
  2. Planner stub returns three steps: `search`, `outline`, `draft`.
  3. Executor runs each step via stub tools (canned payloads).
  4. If `search` returns `{ ok: false }`, planner inserts a `narrow_query` step and continues.
  5. Stop when all remaining steps succeed; emit the brief.
  6. Log plan vs. executed steps so you can see replans.

Stubs are enough. The lesson is the contract: plan up front, execute in order, replan only on explicit failure.

// Common failure

What goes wrong

Symptom

Replanning after every tool call — Plan-and-Execute collapses into expensive ReAct.

Fix

Replan only on hard failure or a missing prerequisite. Soft uncertainty stays on the current plan.

// Self-reflection

Sit with this

Where do you already know the steps — and still pay for a reason-loop on every call?

Sources

Session only. Nothing is saved.