Follow AiTechWorlds on LinkedIn for professional AI content!Follow Now →
20 minLesson 2 of 23
Agent Fundamentals

Agent Architectures: ReAct, CoT & Planning

AI Agent Architectures: How Agents Are Built

An AI agent is a system where an LLM doesn't just respond to a single prompt — it takes a sequence of actions to accomplish a goal, using tools, making decisions, and adapting based on results. Understanding the main architectural patterns is the foundation for building agents that work reliably.

What Makes Something an "Agent"

A basic LLM call is: input → LLM → output. Done.

An agent is: goal → LLM decides action → executes action → observes result → LLM decides next action → ... → goal achieved.

The key additions:

  1. Tools — functions the LLM can invoke (search the web, run code, query a database)
  2. Memory — context from earlier steps, conversation history, stored knowledge
  3. Planning — the LLM sequences multiple steps rather than answering once
  4. Observation — the LLM sees the results of its actions and adapts

When these combine, you get emergent capability: the agent can accomplish tasks that couldn't be done with a single prompt.

The Four Core Architectures

1. ReAct (Reasoning + Acting)

ReAct is the most common single-agent pattern. The LLM alternates between reasoning (thinking out loud) and acting (using a tool):

Thought: I need to find the current stock price of Apple.
Action: search("Apple AAPL stock price today")
Observation: AAPL is trading at $192.35 as of 2:15 PM EST.
Thought: Now I have the price. The user asked how it compares to last year.
Action: search("Apple AAPL stock price one year ago")
Observation: A year ago, AAPL was trading around $178.
Thought: I have both values. I can calculate the change.
Final answer: Apple (AAPL) is currently trading at $192.35, up approximately 8% from $178 a year ago.

The "Thought" steps are the LLM's internal reasoning — they make the decision-making transparent and improve accuracy. The LLM sees its own reasoning, which helps it stay on track.

Best for: Research tasks, information retrieval, tasks requiring a sequence of lookups

2. Plan-and-Execute

The agent creates a plan upfront, then executes each step:

User: Research the top 3 competitors to our product and write a comparison report.

Planning phase:
1. Search for our product category and main competitors
2. Gather pricing information for each competitor
3. Find customer reviews for each competitor
4. Analyze the data and identify key differentiators
5. Write the comparison report

Execution phase:
[Execute each step sequentially, with each step's output feeding into the next]

Plan-and-execute is better for complex, multi-part tasks where you want a defined structure before execution begins.

Best for: Long research tasks, multi-step document creation, complex workflows

3. Multi-Agent (Orchestrator + Specialists)

Multiple agents with specialized roles, coordinated by an orchestrator:

Orchestrator Agent
├── Research Agent (browses the web, finds information)
├── Coding Agent (writes and executes code)
├── Writing Agent (generates polished prose)
└── Review Agent (checks for errors and quality)

The orchestrator breaks the task, delegates to specialists, and synthesizes results. Each specialist is independently prompted and can use different models/tools.

Best for: Complex tasks that benefit from specialization, tasks where parallel execution helps, production systems where each role has distinct tool requirements

4. Reflection and Self-Improvement

The agent critiques and improves its own output:

Generate → Critique → Revise → [optional: Critique again] → Final output

Step 1: Generate initial response Step 2: "Review your previous response. What's missing? What could be wrong? What could be improved?" Step 3: Revise based on the critique

This pattern is particularly effective for writing quality, code correctness, and analysis depth. The LLM catching its own mistakes is surprisingly powerful.

Best for: High-quality writing, code generation, analysis where you want to check reasoning

The Agentic Loop

All agent architectures share a common execution loop:

while not task_complete:
    # 1. Observe: what is the current state?
    observation = get_current_state()
    
    # 2. Think: what should I do next?
    action = llm.decide(goal, observation, history)
    
    # 3. Act: execute the chosen action
    result = execute_action(action)
    
    # 4. Update: record what happened
    history.append((action, result))
    
    # 5. Check: is the task complete?
    task_complete = check_completion(result, goal)

Understanding this loop helps you debug agents — when something goes wrong, it's usually in one of these five steps.

The Key Design Decisions

Single agent vs. multi-agent

Single agents are simpler to build and debug. Multi-agent systems can parallelize work and specialize, but coordination overhead adds complexity.

Start single-agent. Add agents only when the single agent clearly can't handle the task effectively.

How much autonomy

More autonomy = more potential value, more potential for unintended actions. The right level depends on:

  • Stakes of individual actions (reversible vs. irreversible)
  • Confidence in the LLM's judgment for this domain
  • Whether a human is available to review

Tool selection

What tools you give an agent defines what it can do. Common tools:

  • Web search (current information)
  • Code execution (Python interpreter)
  • File system (read/write files)
  • Database queries
  • API calls (CRM, email, Slack, etc.)
  • Memory retrieval (vector search over stored knowledge)

Start with the minimum tools needed for the task.

Memory architecture

How the agent remembers:

  • Conversation history: Previous messages in the current session
  • External memory: Knowledge stored in a vector database, retrievable via search
  • Entity memory: Facts about specific entities (people, companies) updated over time
  • Episodic memory: Summaries of past sessions, enabling continuity across conversations

When to Use Agents vs. Simple LLM Calls

Agents add complexity and cost. Don't use them when a simple prompt works:

Use Simple LLMUse Agent
Single-step response (write an email)Multi-step workflow (research → analyze → write)
Static information neededReal-time or external information needed
Deterministic pathAdaptive decision-making needed
Low stakes, high volumeHigher stakes, variable tasks

Next lesson: The agent core loop — implementing the reasoning-acting-observing cycle.

📱

Get this course's notes on Telegram!

Free cheat sheets, summaries & practice exercises

Get Notes Free →
!