top of page

Plan and Execute Design Pattern: Agentic AI Systems

  • Writer: Javith Abbas
    Javith Abbas
  • 10 hours ago
  • 4 min read

When I began working with large language models (LLMs), I was amazed by their ability to generate human-like text and tackle complex queries. However, I quickly recognized a crucial limitation: while LLMs excel at producing coherent output, they struggle with intricate, multi-step problems. They resemble brilliant improvisers but lack the structured approach necessary to navigate the hidden complexities of real-world tasks.


This realization led me to Agentic Design Patterns, a framework that fundamentally changes how we utilize LLMs. Among the four core patterns - Reflection, Tool Use, Multi-Agent Collaboration, and Planning. Planning emerged as a transformative concept. It enables LLMs to evolve from reactive text generators to autonomous problem solvers by separating reasoning from action.


Why Planning Matters: Addressing Hidden Complexity

One of my first "aha moments" occurred when I faced a seemingly simple challenge: generating a comprehensive report from raw data. At first glance, it appeared straightforward. However, as I designed the agent, I quickly uncovered the underlying complexity. The agent needed to: 1. Gather and preprocess the data. 2. Analyze it to compute key performance indicators (KPIs). 3. Generate insights based on the analysis. 4. Format everything into a structured, user-friendly report.

Initially, I attempted a classic ReAct approach (Reason and Act), where the agent alternates between reasoning and acting step by step. While this method worked for simpler tasks, it faltered here. The agent became trapped in loops, repeatedly reconsidering the same steps, and lost track of intermediate results. I realized I definitely needed a different strategy, one that allowed the agent to break the problem down into a series of steps upfront and execute them systematically. This is the essence of the Planning pattern.


The Core Concept: Plan to Execute

The Planning pattern operates by separating reasoning (planning) from action (execution). Instead of tackling a problem iteratively, the agent first analyzes the user’s request to create a structured roadmap or "task decomposition." Once the plan is in place, the agent executes the steps in sequence, either independently or with the assistance of sub-agents.


The workflow for Planning typically follows these steps:

1. Input/Perceive: The agent receives a high-level goal or request.

2. Decompose: It analyzes the goal to identify dependencies and break it into subtasks.

3. Sequence: The subtasks are organized into a logical order (e.g., "Step A → Step B → Step C").

4. Execute: The agent (or sub-agents) systematically carries out the steps.


This upfront decomposition is particularly effective for tasks with hidden complexity, where dependencies between steps aren’t immediately apparent. For example, Writing a substantial piece of code often involves multiple systems, edge cases, and intermediate outputs. By surfacing these dependencies early, the agent avoids getting stuck mid-execution.


Key Implementations of the Planning Pattern

As I delved deeper into Planning, I discovered that there isn’t a one-size-fits-all solution. Instead, several implementations cater to different types of problems. Here are the ones I found most effective:

1. ReWOO (Reasoning WithOut Observation)

ReWOO acts as a "compiler" for agent workflows. Instead of iteratively reasoning and acting, the agent generates the full plan upfront, including placeholders (e.g., `#Data`) for future tool outputs. This decouples planning from execution, enabling parallel execution of independent steps.

Here’s a simplified example:

# THE BLUEPRINT (Generated by Planner)
Plan = """
1. Search[2023 revenue NVIDIA] (Output: #RevNV)
2. Search[2023 revenue AMD] (Output: #RevAMD)
# Worker executes 1 and 2 simultaneously to save time.
3. Calculate[#RevNV - #RevAMD] (Output: #Diff)
4. Solver[Synthesize final report using #RevNV, #RevAMD, and #Diff]
"""

In this model, the agent doesn’t wait for each step to complete before planning the next. Instead, it creates a comprehensive roadmap and executes steps in parallel whenever possible. This drastically reduces latency and token costs compared to sequential loops.

2. Hierarchical Task Decomposition

For more ambiguous or open-ended problems, a hierarchical approach is more effective. In this setup, a "root" agent acts as a supervisor, breaking down high-level goals into subtasks and delegating them to specialized "worker" agents. For instance, when generating a report, the root agent might assign subtasks like "data gathering" and "data analysis" to separate worker agents. Each worker focuses on its specific task, allowing the system to manage complexity more effectively.


Techniques for Robust Planning

Implementing the Planning pattern comes with challenges. Here are some techniques that helped me enhance its robustness:

Variable Substitution

This technique, central to ReWOO, assigns placeholders to future outputs during the planning phase. It decouples planning logic from execution, allowing the agent to generate the plan in a single pass. During execution, the agent replaces placeholders like with actual outputs as shown in the ReWOO example.


Dynamic Replanning

Static plans can be brittle. If a step fails or yields unexpected results, the entire workflow may collapse. To address this, I implemented dynamic replanning, allowing the agent to pause and revise the plan when issues arise. This adaptability enhances robustness by enabling the agent to adjust mid-execution.


Hybrid Approaches

Combining Planning with other patterns—like ReAct—can yield optimal results. For example, I’ve used a Planner to create a high-level roadmap and a ReAct agent to execute subtasks that require exploration or trial-and-error.

Lessons Learned and Future Directions


Implementing the Planning pattern revealed that the true power of LLMs lies in their capacity to manage complexity, not merely generate text. By separating reasoning from action, we can develop agents that systematically and efficiently tackle intricate, multi-step problems. Moving forward, I’m eager to explore how Planning can integrate with other agentic design patterns—such as Multi-Agent Collaboration—to create even more robust systems. The key takeaway is clear: when faced with hidden complexity, prioritize planning over reaction.


 
 
 

Comments


©2024 by TechThiran. Proudly created with Wix.com

bottom of page