Planning & Control Flow

Plan-and-Execute

Plan all the steps once with a strong model, then execute each step with a cheaper model under the plan.

Problem

A ReAct loop (reason-act-observe) runs the strong model on every single step, including trivial ones where the next action is obvious, so it pays full price for routine execution. Hand-coding the workflow gives up the agent's ability to handle small surprises. Without an inspectable plan emitted before any tool fires, reviewers cannot see what the agent intends to do until it has already partially done it, and a wrong assumption near the start cannot be caught until the run produces a bad result.

Solution

Two-stage loop. Planner: produce an ordered list of steps with explicit dependencies. Executor: run each step (often with tools) and accumulate results. On failure or surprise, replan with the new evidence in context.

When to use

  • The task decomposes cleanly into mostly-independent steps.
  • The world is stable enough that a plan made once is still good to execute.
  • Cost of replanning per step would dominate the run.

Open the full interactive page

Diagram, neighbourhood map, code examples, related patterns and full provenance.

Related