Agents & Tools Interview Prep

Course Content

Agents & Tools Interview Prep

6 sections · 40 lessons

What is the Plan-and-Execute approach, and when is it useful?


The Singapore trip plan, and the one replanGoal:3-night work trip1 search_flights2 search_hotels3 check_visano hotelunder the limitreplan: within3 km of office
Independent steps run together, and a surprise rewrites one branch of the plan instead of restarting the whole run.

What you need to know

  1. Plan — a strong model turns the goal into numbered steps with dependencies.
  2. Review (optional) — a human or a rule checks the plan.
  3. Execute — each step runs; independent steps run in parallel.
  4. Replan on surprise — if a step fails or returns something unexpected, the planner revises only the remaining steps.
  5. 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:

Python
PLAN_TOOL = {    "name": "submit_plan",    "description": "Submit the ordered steps needed to complete the task.",    "input_schema": {        "type": "object",        "properties": {"steps": {"type": "array", "items": {            "type": "object",            "properties": {                "id": {"type": "integer"},                "tool": {"type": "string", "enum": ["search_flights", "search_hotels", "check_visa"]},                "args": {"type": "object"},                "depends_on": {"type": "array", "items": {"type": "integer"}},            },            "required": ["id", "tool", "args", "depends_on"],        }}},        "required": ["steps"],    },}

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

ReActPlan-and-Execute
Decides next stepAfter every observationOnce, up front (plus replans)
Strong-model callsEvery stepPlanning and replanning only
Parallel stepsOnly within one turnNatural, from the dependency graph
Human reviewHard — no plan existsEasy — review the plan
Handles surprisesVery wellOnly 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).