Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 48

Agent Design Patterns: ReAct, Tool Use, and Planning

Recommended resources

Introduction

In our previous lesson, we established an architectural blueprint for an AI agent, deconstructing it into its four essential components: perception, reasoning, action, and memory. This provided the "what"—the static anatomy of an agent. Today, we delve into the "how"—the dynamic, operational logic that brings these components to life.

This lesson focuses on the common design patterns that orchestrate an agent's behavior. Your goal is to be able to describe common agent design patterns such as ReAct, tool use, and planning-based approaches. Understanding these patterns is fundamental from an architect's perspective, as the choice of pattern directly dictates an agent's efficiency, cost, observability, and overall problem-solving capability. We will explore how agents think, act, and plan, moving from simple loops to more sophisticated strategies.


An Overview of Agentic Design Patterns

Before we dive into specifics, let's establish a mental map of the patterns we'll be discussing. Just as in traditional software architecture, agentic design patterns provide reusable solutions to common problems in orchestrating AI behavior.

This infographic provides an excellent high-level overview of the key design patterns we will explore: Reflection, Tool Use, ReAct, and Planning. We will also touch upon the Multi-agent pattern as a preview for our next lesson.

As you can see, these patterns are not mutually exclusive. A planning agent might use a ReAct loop to execute each step, and any agent can benefit from reflection. Let's start with the most foundational pattern: ReAct.


The ReAct Pattern: Interleaving Reasoning and Action

The most fundamental pattern for an autonomous agent is ReAct, which stands for Reason + Act. As the name implies, it structures the agent's control loop into a sequence of generating a thought, taking an action based on that thought, and then observing the result. This cycle repeats until the task is complete. This simple loop is what transforms a static model into a dynamic problem-solver that can interact with an environment.

Lilian Weng's comprehensive blog post on LLM-powered agents provides a clear definition and examples of this crucial pattern.

LLM Powered Autonomous Agents | Lil'Log

This article is a foundational text in the agentic AI space. We will refer to it multiple times.

In the section on Self-Reflection, please read the part introducing ReAct. Focus on how it combines task-specific actions with generating reasoning traces. The Thought: ... Action: ... Observation: ... template is the core of this pattern.

The key insight of ReAct is making the model's reasoning process explicit. For you as an architect and engineer, this "Thought" trace is not just an implementation detail; it is the primary mechanism for observability and debugging. When an agent fails, the chain of thoughts tells you why it failed, allowing you to debug the agent's logic, not just its code.

The article from Let's Data Science reinforces this point and provides a practical example.

Building AI Agents: ReAct, Planning, and Tool Use | Let's Data Science

This article offers a pragmatic, architect-focused view on agent patterns.

Read the section on The ReAct Pattern. Pay close attention to the practical example of the research assistant. Notice how each step explicitly contains a Thought, an Action, and an Observation. Also, take note of the "Pro Tip" that follows, emphasizing the importance of logging the full trace for production systems.

To make this even more concrete, examine the following image, which shows ReAct being applied to two different tasks: a knowledge-intensive question-answering task (HotpotQA) and a decision-making task in a simulated environment (AlfWorld).

This image, from the original ReAct paper, shows the Thought-Action-Observation loop in practice. On the left, the agent reasons about how to find information. On the right, it reasons about how to physically navigate an environment.

In both cases, the agent isn't just generating an answer. It's formulating a plan, executing a step, observing the outcome, and then reformulating its plan based on new information. This iterative process is what gives agents their power and adaptability.


The Tool Use Pattern: Extending Agent Capabilities

In the previous lesson, we identified "Action" as a core agent component, executed via tools. The Tool Use pattern is about how an agent decides when and how to use those tools. Without tools, an LLM is a closed system, limited by the knowledge frozen into its training data. With tools, it can interact with the outside world: search the web, query a database, call a microservice, or even write to a file.

Andrew Ng, a leading voice in AI, considers tool use one of the fundamental agentic design patterns.

Andrew Ng Explores The Rise Of AI Agents And Agentic Reasoning | BUILD 2024 Keynote

This clip from Andrew Ng's keynote at BUILD 2024 provides a high-level framing for the importance of agentic patterns.

Please watch the short segment where he describes the tool use design pattern, from this timestamp. He explains how it allows an LLM to generate API calls to interact with external systems.

From an architectural standpoint, the challenge lies in how the agent selects the correct tool from a potentially large set of options. Giving an agent too many tools can be counterproductive, leading to confusion and incorrect selections. The "Building AI Agents" article outlines several practical strategies for tool selection.

Building AI Agents: ReAct, Planning, and Tool Use | Let's Data Science

Let's revisit the article from Let's Data Science for its architectural take on tool use.

Read the section "Tool Integration and Selection." Focus on the different selection patterns described: Direct selection, Two-stage selection, and Parallel execution. The pitfall of providing too many tools is a critical lesson learned from real-world deployments. Also, note the importance of designing for error recovery, a concept familiar from your experience with distributed systems.

For a deeper technical perspective on how tool use is implemented, the Lil'Log article discusses several foundational frameworks.

LLM Powered Autonomous Agents | Lil'Log

This section of the Lil'Log article provides a survey of frameworks that enable tool use.

Skim the section "Component Three: Tool Use." You don't need to memorize the specifics of MRKL or Toolformer, but understand that the core idea is to teach or prompt an LLM to generate structured API calls. The description of HuggingGPT provides a good example of a multi-stage process for complex tool-based tasks: planning, model selection, execution, and response generation.


Planning-Based Approaches: From Reactive to Proactive

The ReAct pattern is inherently reactive; it decides the next step after each observation. This is great for exploration but can be inefficient for tasks where the overall structure is known. For more complex, multi-step problems, we often turn to planning-based approaches.

Andrew Ng also highlights planning as a core agentic pattern.

Andrew Ng Explores The Rise Of AI Agents And Agentic Reasoning | BUILD 2024 Keynote

Let's watch another clip from Andrew Ng's keynote.

Watch the segment on the planning or reasoning design pattern, from this timestamp. Notice how the LLM breaks down a complex request into a sequence of discrete actions before execution begins.

This introduces a key architectural trade-off:

  1. Step-by-step (ReAct): More adaptive, but higher latency and token cost for long tasks due to repeated reasoning.
  2. Plan-then-execute: More efficient (planning happens once), but more rigid. If an early step fails or reveals new information, the rest of the plan might be invalid.

The "Building AI Agents" article provides an excellent comparison of these strategies, including a third hybrid approach.

Building AI Agents: ReAct, Planning, and Tool Use | Let's Data Science

This article excels at framing these patterns in terms of their architectural trade-offs.

Read the section "Planning Strategies for Complex Tasks." The side-by-side comparison diagram and the table summarizing the trade-offs between ReAct, Plan-then-execute, and LATS (Language Agent Tree Search) are particularly valuable. The insight that most production agents use a hybrid approach—a rough upfront plan followed by ReAct-style execution—is a key takeaway for practical system design.


The Reflection Pattern: Enabling Self-Correction

A powerful enhancement to any agentic loop is Reflection (also known as self-critique or review and critique). In this pattern, the agent generates an output and then uses another LLM call to critique its own work against a set of criteria. This feedback is then used to refine the output in an iterative loop. This is analogous to a developer writing code and then acting as their own code reviewer.

Andrew Ng Explores The Rise Of AI Agents And Agentic Reasoning | BUILD 2024 Keynote

Andrew Ng provides a very clear explanation of this pattern.

Watch the segment on the reflection design pattern from this timestamp. He uses the example of a coding agent that writes code, critiques it, and then improves it based on the critique, which should resonate with your software engineering background.

The Google Cloud Tech video on agent design patterns shows a concrete implementation of this pattern, which they call "review and critique."

3 Advanced AI agent design patterns

This video demonstrates how these patterns are implemented in Google's Agent Development Kit (ADK).

Watch the first section on the loop review and critique pattern from this timestamp. The example of planning a trip with a hard constraint (travel time < 30 minutes) clearly illustrates why this pattern is useful for ensuring outputs meet specific quality standards or business rules. Pay attention to the discussion of the trade-offs: higher quality at the expense of increased latency and cost.


Conclusion

In this lesson, we moved from the static components of an agent to the dynamic patterns that govern their behavior. You learned how different patterns offer distinct trade-offs in adaptability, efficiency, and cost, which are critical considerations for any system architect.

Key Takeaways:

  • ReAct (Reason + Act) is the foundational pattern for agents, creating an observable, step-by-step loop of Thought -> Action -> Observation.
  • Tool Use patterns are what give agents their power to interact with the world beyond the LLM's internal knowledge, using mechanisms like function calling. Effective tool use requires careful strategies for selection and error handling.
  • Planning-based approaches introduce a higher level of strategy. They involve a trade-off between the adaptability of reactive patterns (like ReAct) and the efficiency of proactive patterns (like plan-then-execute).
  • Reflection is an iterative refinement pattern where an agent critiques its own work to improve output quality, which is essential for tasks requiring high accuracy or adherence to constraints.
  • These patterns are composable building blocks. A sophisticated agent might generate a high-level plan, use a ReAct loop with tools to execute each step, and apply reflection to refine the final output.

Preview of the Next Lesson:

We have focused entirely on the architecture of a single agent. However, many complex problems are best solved by a team of specialized agents working together. In our next lesson, we will scale up to multi-agent architectures. We will explore patterns for inter-agent communication, task delegation, and coordination, preparing you to design systems where multiple agents collaborate to achieve a common goal.