Course Content
Agents & Tools Interview Prep
6 sections · 40 lessons
What is the Plan-and-Execute approach, and when is it useful?
What you need to know
- Plan — a strong model turns the goal into numbered steps with dependencies.
- Review (optional) — a human or a rule checks the plan.
- Execute — each step runs; independent steps run in parallel.
- Replan on surprise — if a step fails or returns something unexpected, the planner revises only the remaining steps.
- Finish — combine the results into the answer.
Asking for the plan as structured data
Make the plan a tool call so it arrives as validated JSON, not prose:
1PLAN_TOOL = {2 "name": "submit_plan",3 "description": "Submit the ordered steps needed to complete the task.",4 "input_schema": {5 "type": "object",6 "properties": {"steps": {"type": "array", "items": {7 "type": "object",8 "properties": {9 "id": {"type": "integer"},10 "tool": {"type": "string", "enum": ["search_flights", "search_hotels", "check_visa"]},11 "args": {"type": "object"},12 "depends_on": {"type": "array", "items": {"type": "integer"}},13 },14 "required": ["id", "tool", "args", "depends_on"],15 }}},16 "required": ["steps"],17 },18}The enum means the planner can only choose real tools, and depends_on tells the executor which steps can run together.
Plan-and-Execute versus ReAct
| ReAct | Plan-and-Execute | |
|---|---|---|
| Decides next step | After every observation | Once, up front (plus replans) |
| Strong-model calls | Every step | Planning and replanning only |
| Parallel steps | Only within one turn | Natural, from the dependency graph |
| Human review | Hard — no plan exists | Easy — review the plan |
| Handles surprises | Very well | Only through replanning |
A real-life example
A travel agent receives: "Book a work trip — Mumbai to Singapore, 3 nights, hotel near Marina Bay, check visa rules for an Indian passport."
The planner writes 4 steps: (1) search_flights, (2) search_hotels, (3) check_visa — all independent — and (4) build an itinerary from 1–3. The executor runs steps 1–3 in parallel, so the wall-clock time is about 4 seconds instead of 12. The user sees the plan and itinerary before anything is booked.
Then a surprise: step 2 returns no hotels under the company's ₹12,000-per-night limit near Marina Bay. The replanner adds a step: search within 3 km of the office and check travel time. That is one extra planner call, not a restart.
Compare with a vague request like "Help me figure out a trip that makes sense for my team offsite." The right steps depend on answers you do not have yet, so a ReAct-style loop with clarifying questions fits better.
Follow-up questions to expect
- "How do you stop the plan from going stale?" — Replan on failure or surprise, keep plans short, and cap the number of replans (e.g. 2).
- "Can the executor be plain code?" — Yes, if each step maps to a single tool call with known arguments. Then only the planning needs a model.
- "Who approves the plan?" — For side-effecting tasks, a human; for read-only tasks, often a rule check (allowed tools, step count, estimated cost).