Lesson 2: Planner-Executor Pattern
·Agent Design Patterns

Lesson 2: Planner-Executor Pattern

Master the decomposition of complex goals. Learn how to separate high-level strategy from low-level execution to build agents that can solve non-linear problems with high reliability.


Module 3: Agentic Architecture and Orchestration

Lesson 2: Planner–Executor Pattern

The Planner-Executor is the workhorse of agentic architecture. It is based on a simple psychological observation: Planning a task and doing a task are different cognitive skills.

In this lesson, we deconstruct why decoupling "Thinking" from "Doing" reduces hallucinations and allows for complex, multi-step problem solving.


1. The Anatomy of the Pattern

This pattern involves two distinct roles:

Role 1: The Planner (The General)

  • Input: The high-level goal (e.g., "Analyze the competitors for our new AI product").
  • Output: A list of discrete steps (e.g., "1. Search for Top 5 competitors. 2. Fetch their pricing. 3. Compare with our schema").
  • Constraint: The Planner does not have tools. It only has its brain and the ability to write a list.

Role 2: The Executor (The Soldier)

  • Input: A single step from the list.
  • Tools: Access to the search tools, API, and DB.
  • Output: The result of that specific step.

2. Visualizing the Pattern

graph TD
    User([User Goal]) --> P[Planner]
    P --> |Step 1| E[Executor]
    E --> |Tool Result 1| P
    P --> |Revised/Step 2| E
    E --> |Tool Result 2| P
    P --> |Final Report| User

3. Why this Pattern Works

Resilience to "Mid-Task Failure"

In a standard loop (Module 2), if an agent fails at Step 3, it often loses track of what it was supposed to do at Step 4. In a Planner-Executor model, the Planner holds the state of the goal. It can look at the Executor's failure and say: "Okay, Step 3 failed. I will modify the plan to skip Step 3 and try Step 3B."

Context Optimization

The Executor only needs to see the current step. It doesn't need to be polluted by the 50 previous turns of planning conversation. This keeps its focus sharp and its token cost low.


4. Re-Planning (The Feedback Loop)

The most robust versions of this pattern do not just "Plan once." They Re-Plan after every execution result.

  • State 1: Planner makes a 3-step plan.
  • State 2: Executor finishes Step 1.
  • State 3: Planner looks at result of Step 1 and Updates Steps 2 and 3.

5. Architectural Trap: "The Disconnect"

If the Planner is too "Vague," the Executor won't know what to do.

  • Bad Plan: "Research companies."
  • Good Plan: "Use the Search_Tool to find the top 5 revenue-generating companies in the AI space and return their names as a JSON list."
  • Architect's Fix: Force the Planner to output steps in a Structured Template.

6. Summary

  • The Planner maintains the big picture and handles strategy.
  • The Executor handles the "Dirty work" of tool calls and error handling.
  • Decoupling these roles increases reliability for tasks longer than 3-5 steps.

In the next lesson, we will look at an alternative "Managerial" pattern: The Supervisor-Worker Pattern.


Interactive Quiz

  1. What is the main difference between a Planner and an Executor?
  2. Why does re-planning after every step increase robustness?
  3. How does this pattern help manage context window limits?
  4. Scenario: An agent needs to scrape 100 websites. Does a Planner-Executor model make sense here? Why or why not?

Reference Video:

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn