AI & Agents

The Planner-Executor Pattern: How Smart AI Teams Split the Work

A simple way to make AI agents more reliable by giving them two separate jobs — one to plan, one to do.

Scroll to start

Two Roles, One Goal

Imagine a chef in a busy kitchen. The head chef plans the entire meal — what to cook, in what order, with which ingredients. The line cooks just follow the tickets, making each dish one at a time. The head chef never picks up a knife. The line cooks never decide the menu. Each one is good at one job.

The Planner-Executor Pattern works the same way for AI. You split one AI agent into two: a Planner that decides what steps are needed, and an Executor that actually does each step. The Planner thinks. The Executor acts. They talk back and forth until the whole job is done.

This is a popular design pattern for AI agents because it makes them more reliable, easier to debug, and better at handling big, complicated jobs.

Why Split the Job in Two?

When you ask one AI to do a big, multi-step task all by itself, things can go wrong fast. It might skip a step, get confused halfway through, or just make stuff up to fill in gaps it doesn't understand. This is the classic "one brain doing too many things" problem.

Splitting planning from execution solves this. The Planner only has to think — it never has to actually do the work. The Executor only has to do — it never has to make big decisions. Each side gets really good at its own job.

This pattern is the secret behind many of the AI agents you hear about, from research assistants that browse the web, to coding tools that fix bugs across many files, to chatbots that can book your flights.

💡 Key Insight

When one AI does everything, it often loses track of the original goal after a few steps. By separating planning from execution, the Planner stays "in charge" of the goal the whole time — like a project manager checking in on each worker. This makes the whole agent much more reliable on long, complex tasks.

The Back-and-Forth Loop

The pattern runs as a small conversation between two AIs. The user gives a goal. The Planner looks at the goal and the current state, then decides the very next step. The Executor does that step and reports what happened. The Planner looks at the new state, decides the next step, and the cycle continues until the goal is met.

Here's what the loop looks like:

The Planner-Executor Loop
🎯
Goal Given
User states the goal
🧠
Planner Thinks
Decides the next step
⚙️
Executor Acts
Does that one step
🔍
Check Result
Planner reviews & re-plans
repeat until goal is met

The trick is that the Planner only plans one step at a time — never the whole task at once. This way, it can react to surprises (like the executor failing or finding new info) and adjust the plan on the fly.

A Tiny Planner-Executor in Python

Here's a simplified version of the pattern. The Planner looks at the goal and the history of what already happened, then returns the next step as a small JSON object. The Executor takes that step and runs it. The loop checks if we're done and goes again.

planner_executor.py
# A toy Planner-Executor: solve "12 * 4 + 5" step by step
def planner(goal, history):
    # In real life, this is a call to an LLM.
    # Here we fake it with simple rules for clarity.
    if "multiply" not in history:
        return {"action": "multiply", "a": 12, "b": 4}
    if "add" not in history:
        return {"action": "add", "a": 48, "b": 5}
    return {"action": "done", "answer": 53}

def executor(step):
    if step["action"] == "multiply":
        return step["a"] * step["b"]
    if step["action"] == "add":
        return step["a"] + step["b"]
    return step["answer"]

# The main loop: plan one step, do it, repeat
goal = "What is 12 * 4 + 5?"
history = []

for turn in range(10):  # safety cap
    step = planner(goal, history)
    result = executor(step)
    history.append(step["action"])

    if step["action"] == "done":
        print("Final answer:", result)
        break
    print("Step", turn + 1, ":", step["action"], "=", result)

The output looks like this:

output
Step 1: multiply = 48
Step 2: add = 53
Final answer: 53

Notice how the Planner never does any math itself — it just decides the next action. The Executor never decides what to do — it just runs whatever it was told. That separation is the whole pattern.

Knowledge Check

Test what you learned with this quick quiz.

Quick Quiz — 3 Questions

Question 1
What are the two roles in the Planner-Executor pattern?
Question 2
Why is splitting planning from execution useful?
Question 3
In a Planner-Executor loop, what usually happens AFTER the Executor finishes a step?
🏆

You crushed it!

Perfect score on this module.