Skip to content
mentoor

Topic 1 of 5 · 4 min read

Plan-then-execute versus interleaved planning

Goal: Judge whether an agent's plan covers the goal, orders dependencies correctly and has steps that can be checked.

An agent can write the whole plan first and then follow it, or decide each step after seeing the last result; the choice depends on how much the task will surprise you. Either way, a plan is only worth executing if you can check it.

Check yourself · 1 of 3

Which task benefits most from a written plan that a person approves before the agent edits anything?

Choose one answer

Two styles

In plan-then-execute, the agent writes a numbered plan, you or a script approve it, and then the steps run. Claude Code's plan mode and the "planner and executor" setups in agent frameworks work like this. In interleaved planning, the style of ReAct, the agent thinks, calls one tool, reads the result and only then picks the next move.

Upfront plans win when the work is wide, risky or expensive to undo: a migration across 40 files, a change that touches a payment path. A person can read a plan in a minute and catch a wrong direction before any file changes. Interleaved wins when the next step depends on what the last one finds: debugging a flaky test, exploring an unfamiliar repo. A plan written before the agent has read the code is a guess.

Most real agents mix both. They sketch a short plan, execute, and revise (see re-planning).

How to judge a plan

Check four things before you say go:

  1. Coverage. Does every part of the goal map to a step? If the goal says "and update the docs", is there a docs step?
  2. Order. Does each step only need things earlier steps produce? A plan that runs the migration before the schema change is wrong even if it reads well.
  3. Checks. Does each step say how to know it worked (a test, a command, an expected output)? "Improve error handling" cannot be checked. "Return 404 for unknown ids; the new test passes" can.
  4. Size and scope. Steps that are too big hide risk. Steps that touch things outside the goal are scope creep.

Before and after

Weak plan for "add rate limiting to the login endpoint":

1. Add rate limiting
2. Test it
3. Update docs

Better:

1. Read how middleware is registered in src/server.ts. Check: name the file and line.
2. Add a limiter keyed by IP, 5 attempts per minute, on POST /login only. Check: unit test for the sixth request returns 429.
3. Add the config value to .env.example. Check: app boots with it unset.
4. Document the limit in docs/api.md. Check: grep finds the new section.

What goes wrong

  • Plan theatre. The agent writes a confident plan, then ignores it. Compare the run to the plan.
  • Stale plans. The plan was written before the agent read the code and no longer fits.
  • Over-planning small tasks. A one-line fix does not need a five-step plan; the plan costs tokens and your attention.
  • Approving a plan by skimming. A fluent list of steps looks complete even when a dependency is missing.

Examples

The step in the wrong order

An agent plans a column rename: "1. Update the ORM model. 2. Write the migration. 3. Run the migration." Running the app between 1 and 3 fails, because the model points at a column that does not exist yet. Reorder: migration first (adding the new column), deploy code that reads both, then drop the old one. Order is the first thing to read in a plan.

Same task, two styles

Task A: "Rename userId to accountId across the repo." The agent plans first: search, list the files, change each, run the tests. Task B: "The nightly export sometimes times out." The agent cannot plan the fix; it reads logs, forms a guess, tests it, and plans only the next move. Task A is plan-then-execute; task B is interleaved.

Key points

  • Plan-then-execute suits wide, risky or hard-to-undo work; interleaved planning suits tasks where each result decides the next step.
  • Judge a plan on coverage of the goal, dependency order, a check per step and sensible step size.
  • A plan written before the agent has read the code is a guess, so let exploration come first.
  • Do not spend a long plan on a small task; the review of the plan has a cost too.
  • Compare what the agent did with what it planned, because a plan that is ignored protects nothing.

Common mistakes

  • Approving a plan because it is fluent, without checking that every part of the goal has a step.
  • Asking for a full plan before the agent has explored the code it will change.
  • Planning every small task, which adds cost and review time with no safety gain.
  • Never comparing the finished run to the plan, so a plan the agent dropped goes unnoticed.

Check yourself · 2 of 3

An agent plans a feature as: "1. Write the API handler. 2. Write the database migration. 3. Run the tests." The handler reads a column that the migration adds. What is wrong with the plan?

Choose one answer

Check yourself · 3 of 3

A plan contains the step "Improve error handling in the upload service." Which rewrite makes the step checkable?

Choose one answer

Practice items, not counted towards your mastery.

Start here