Agent Architectures: ReAct, Planning, and Reasoning Patterns

Overview

A master architect doesn't just follow blueprints—they understand the structural principles that make buildings stable, functional, and beautiful. Similarly, AI agent architectures are not just code patterns but fundamental approaches to organizing perception, reasoning, and action that determine how intelligently an agent can behave.

In this lesson, we'll explore the key architectural patterns that have emerged in AI agents, from the elegant simplicity of ReAct (Reasoning + Acting) to sophisticated multi-layer systems that can handle complex, multi-step reasoning and planning.

Learning Objectives

After completing this lesson, you will be able to:

  • Understand and implement the ReAct (Reasoning + Acting) pattern
  • Design Plan-and-Execute architectures for complex tasks
  • Compare different reasoning patterns and choose appropriate ones for specific use cases
  • Implement reflection and self-correction mechanisms in agents
  • Build agents that can decompose complex goals into manageable subtasks

The ReAct Architecture: Thinking and Acting in Harmony

The Power of Interleaving Thought and Action

Traditional approaches either think completely before acting (planning) or act without thinking (reactive). ReAct revolutionizes this by interleaving reasoning and acting—thinking a bit, acting a bit, observing the results, then thinking some more.

Analogy: Think of a skilled detective solving a case. They don't plan every step in advance, nor do they act randomly. Instead, they:

  1. Think: "Based on the evidence, the suspect might be at the coffee shop"
  2. Act: Go to the coffee shop and ask questions
  3. Observe: "The barista says they haven't seen the suspect, but mentions they often go to the library"
  4. Think: "Let me check the library next"
  5. Act: Head to the library...

This iterative process allows for adaptive problem-solving that pure planning or pure reaction cannot achieve.

Architecture Pattern Comparison

Reactive Pattern (Stimulus-Response):

Deliberative Pattern (Plan-Execute):

ReAct Pattern (Think-Act-Observe):

Hybrid Pattern (Multi-Layer):

Interactive ReAct Demonstration

Interactive Beam Search Tree

Prompt:
Natural language processing has
Beam Width
3
parallel sequences
Max Depth
4
generation steps
Step 0 of 3

Initial Token Candidates

Active Beams (3)
Beam #1
Score: -1.255
Natural language processing has understand
Beam #2
Score: -1.555
Natural language processing has process
Beam #3
Score: -1.855
Natural language processing has generate
Pruned Candidates (5)
Natural language processing has analyze
-2.155
Natural language processing has learn
-2.455
Natural language processing has predict
-2.755
Natural language processing has classify
-3.055
Natural language processing has transform
-3.355

💡 Understanding This Visualization

Green boxes show the 3 best sequences kept at each step. These are the "beams" that continue to the next generation step.

Red boxes show candidate sequences that were generated but pruned because they had lower cumulative scores than the top 3.

Cumulative Score is the sum of log probabilities for all tokens in the sequence. Higher scores indicate more likely sequences according to the model.

Use the step controls to see how beam search explores multiple paths simultaneously and prunes less promising candidates at each step.

Implementing ReAct: The Basic Pattern

python
# ReAct Agent Implementation class ReActAgent: def __init__(self, llm, tools): self.llm = llm self.tools = tools self.max_iterations = 10 def solve(self, task: str) -> str: """Main ReAct loop""" context = f"Task: {task}\n\n"

ReAct Pattern Variations

VariationKey FeatureBest Use CaseComplexity
Basic ReActSimple reasoning-action cyclesWell-defined tasksLow
Chain-of-Thought ReActExtended reasoning stepsComplex problem solvingMedium
Multi-step ReActLong action sequencesMulti-stage workflowsHigh
Parallel ReActConcurrent reasoning pathsTime-sensitive decisionsVery High

Enhanced ReAct Patterns:

  • ReAct-SC (Self-Correction): Adds self-reflection steps where the agent evaluates its own reasoning and actions
  • ReAct-Memory: Incorporates long-term memory to remember useful patterns from previous tasks
  • Multi-Modal ReAct: Extends ReAct to handle images, audio, and other modalities beyond text

Plan-and-Execute: Deliberative Architecture

When You Need a Master Plan

Some tasks require comprehensive planning before execution—like organizing a conference or debugging a complex software system. Plan-and-Execute architectures first create a detailed plan, then execute it step by step.

Analogy: Building a house requires careful planning—you can't just start hammering and hope for the best. You need architectural drawings, permits, material lists, and a construction schedule before breaking ground.

Planning Process Visualization

Plan-and-Execute Implementation

python
# Plan-and-Execute Agent class PlanAndExecuteAgent: def __init__(self, llm, tools): self.llm = llm self.tools = tools def solve(self, task: str) -> str: # Phase 1: Planning plan = self.create_plan(task)

Hybrid Architectures: Multi-Layer Intelligence

Combining the Best of All Worlds

Hybrid architectures combine multiple approaches in a layered system where different layers handle different types of reasoning and response.

Analogy: Think of a skilled emergency room doctor who operates on multiple levels:

  • Reflexive layer: Immediate life-saving responses (check airways, stop bleeding)
  • Diagnostic layer: Systematic analysis and planning (run tests, analyze symptoms)
  • Strategic layer: Long-term treatment planning (recovery plan, follow-up care)

Multi-Layer Architecture

Interactive Architecture Explorer

Agent Architecture Patterns

Different approaches to organizing agent intelligence

Reactive Agents
  • • Simple condition-action rules
  • • Fast response times
  • • No internal state
  • • Example: Thermostat, Alarm system
Deliberative Agents
  • • Plan before acting
  • • Complex reasoning
  • • Internal world model
  • • Example: Chess AI, Route planner
ReAct Agents
  • • Interleaved reasoning and acting
  • • Adaptive problem solving
  • • Tool integration
  • • Example: LLM-powered assistants
Hybrid Agents
  • • Multiple reasoning layers
  • • Best of all approaches
  • • Complex coordination
  • • Example: Autonomous vehicles

Hybrid Architecture Implementation

python
# Hybrid Agent Architecture class HybridAgent: def __init__(self, llm, tools): self.llm = llm self.tools = tools self.memory = {} # Layer configurations self.reactive_threshold = 0.1 # seconds self.tactical_threshold = 5.0 # seconds

Advanced Reasoning Patterns

Tree of Thoughts

Tree of Thoughts extends chain-of-thought reasoning by exploring multiple reasoning paths simultaneously, like a chess player considering multiple moves ahead.

Self-Correction and Reflection

Choosing the Right Architecture

Architecture Selection Guide

Performance Comparison

ArchitectureSpeedQualityAdaptabilityComplexityBest For
Reactive⭐⭐⭐⭐⭐⭐⭐Simple, fast responses
ReAct⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐General problem solving
Plan-Execute⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐Complex, structured tasks
Hybrid⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐Variable, production systems

Summary and Next Steps

Key Architecture Principles

  1. Match Pattern to Problem: Reactive for speed, Plan-Execute for complexity, ReAct for adaptability
  2. Layer When Needed: Hybrid architectures handle diverse requirements
  3. Enable Self-Correction: All patterns benefit from reflection and revision
  4. Consider Trade-offs: Speed vs. quality vs. adaptability

Architecture Evolution Path

In our next lesson, we'll explore tool integration—the mechanisms that allow agents to extend their capabilities through external APIs, databases, and services. This is where agents truly become powerful by leveraging the vast ecosystem of available tools and services.

Practice Exercises

  1. Pattern Implementation: Implement each architecture pattern with a simple example
  2. Performance Testing: Compare response times and quality across patterns
  3. Hybrid Design: Design a hybrid system for a specific use case
  4. Self-Evaluation: Add reflection capabilities to any architecture

Additional Resources