Agents & RAG · Module 12·12 min read

Agentic Patterns

An “agent” is what you get when you put an LLM in a loop with tools. The patterns below — ReAct, Reflection, Planning — are the recurring shapes that production agentic systems take. They’re less exotic than the word suggests.

The five-bullet version

  • An agent is an LLM placed in a loop with tools. Each iteration: the model picks a tool, runs it, looks at the result, decides what to do next.
  • ReAct — interleave reasoning and tool use. The model writes a “thought” before each action and an “observation” after.
  • Reflection — let the model critique its own output and iterate. Improves quality on writing, code, and reasoning.
  • Planning — decompose the goal into a plan first, then execute step by step. Better for long horizons; fragile if the world doesn’t match the plan.
  • Most production agents are simpler than the literature suggests — usually one of these patterns with strict guardrails, not all three at once.

§ 00 · FROM ONE-SHOT TO A LOOPWhat “agentic” actually means

In a normal LLM call, you send a prompt, get a response, and you’re done. One round-trip. The model only ever sees what was in the prompt. It can’t reach the database, check the weather, or send an email.

An agentagent. An LLM placed in a loop with tools. Each iteration, the model decides whether to call a tool, observes the result, and continues until it has enough information to answer. The 'agency' comes from the model — not from any other mechanism — deciding which tool to use and when. flips this. You give the model a set of tools — really just functions it can call — and put the whole thing in a loop. At every iteration, the model can:

  1. Decide it has enough information and emit a final answer (loop ends).
  2. Pick a tool, supply arguments, get back a result, and continue the loop.

That’s the whole framework. The patterns in this lesson are different ways of structuring what the model does inside the loop — when it reasons, when it acts, when it stops, when it second-guesses itself.

§ 01 · REACT — THINK, ACT, OBSERVEThe default pattern

ReActReAct. A 2022 prompting pattern that asks the model to alternate 'Thought' and 'Action' steps. Thoughts are free-text reasoning; Actions are tool calls. After each tool call, the result is fed back as 'Observation' and the model writes its next thought. Standard in modern agent stacks. (Reasoning + Acting) is the simplest and most common pattern. The model is prompted to alternate two kinds of output:

After each action, the runtime executes the tool and feeds the result back as an observation. The model reads the observation and writes its next thought. Loop until the model decides it has enough to answer.

Lab · a ReAct traceUser: “Which enterprise customers signed last quarter, and what’s the combined ARR?”
1 / 7 steps
Thought
The user asked which of our enterprise customers signed in the last quarter and what their combined ARR is. I'll need to query the CRM for recent contracts, filter to 'enterprise' tier, then sum ARR.

Three things ReAct gets right:

The pattern is so natural that modern API tool-calling support (OpenAI function calling, Anthropic tool use, Gemini function calling) is essentially ReAct with the “Thought” field made implicit — the model still reasons, but it does so silently between tool calls.

§ 02 · REFLECTION — LET THE MODEL CRITIQUE ITSELFTwo-pass quality

Reflectionreflection. A pattern where the model produces an output, then is asked to critique that output, then to revise based on the critique. The 'reflection' step is a separate LLM call that examines the first one's work. is the simplest quality booster in the toolkit. After the model produces a first draft (writing, code, an answer, a plan), you ask the same model — usually with a different prompt — to critique that draft. Then ask it to revise based on the critique.

Three steps:

  1. Draft.Normal generation. “Write a function that does X.”
  2. Critique.“Here’s the function. List problems with it: edge cases, performance, style, bugs.”
  3. Revise.“Rewrite the function to address the critique.”

For some tasks, you can run the critique-revise loop multiple times. The diminishing returns kick in fast (usually one round helps a lot, two help a little, three are noise) but the first reflection is often worth it.

Where reflection helps most:

Where reflection doesn’t help: factual recall (the model can’t critique what it doesn’t know), and tasks the model is already saturated on (correct first time, reflection adds noise).

§ 03 · PLANNING — DECOMPOSE FIRST, ACT AFTERGoals into steps

For long-horizon tasks — multi-day research, building a feature, doing a quarterly review — a single tool-calling loop is too myopic. The model picks one action, gets one result, picks the next action; it doesn’t see the bigger structure.

Planningplanning. A pattern where the model first generates a multi-step plan (sequence of subtasks or actions), then executes the plan step by step. The plan can be revised between steps based on observations. adds an explicit step: before any actions, decompose the goal into a sequence of subtasks. Then execute the plan, step by step.

A planning agent typically has three phases:

  1. Plan.One LLM call that produces a numbered list of steps to accomplish the goal. The plan can include conditionals (“if X then do Y else Z”) and parallelizable branches.
  2. Execute. Run each step, often as a ReAct sub-loop. Track which steps are done, which failed, which need to be re-attempted.
  3. Replan. When a step fails or returns surprising results, revise the plan from where it broke.

Planning shines when:

ReAct (flat loop)Planning (decomposed)ThoughtActionThoughtActionThoughtActionAnswerAdaptive depth; figures it out as it goes.Plan (1: A → 2: B → 3: C)Step 1Step 2Step 3Replan if step failsAnswerCommits to structure up front; replans on failure.
Fig 1Planning vs ReAct. The planning agent commits to a structure up front; the ReAct agent figures it out as it goes. Both work; they fail in different ways.

Planning fails when the plan turns out to be wrong but the agent stays committed to it. The model can spend ten steps faithfully executing a plan that doesn’t match reality. The replanning step helps but introduces its own complexity — and risks plan thrashing (replan, fail, replan, fail, replan…).

§ 04 · WHERE THIS GETS YOU, AND WHERE IT BITESProduction realities

Three honest observations from running agent systems at scale:

Six guardrails worth building in from day one:

CHECKYou're building an agent that answers customer questions over your docs. Most queries are answerable from 1–2 doc lookups. Some require 4–5. Which pattern should you start with?

§ 05 · TAKING THIS FORWARDWhere the field is going

Three threads worth following beyond the basic patterns:

For a practical first agent, the formula is unromantic: ReAct loop, 3–5 tools you trust, a tight system prompt, strict guardrails, and evals from day one. Most of the magic comes from the model. Your job is to surround it with the right surface.

§ · GOING DEEPERReAct, Reflexion, and how to build an agent that doesn't loop forever

ReAct (Yao et al. 2022) defined the dominant agentic pattern: Thought (free-text reasoning) → Action (tool call) → Observation (result) → loop. Reflexion (Shinn et al. 2023) adds an explicit critique step — after a failed attempt, the model writes down what went wrong and uses that in the next iteration. For tasks with verifiable success criteria (passing a test, hitting an endpoint), Reflexion meaningfully improves multi-shot success rate.

The hard part of production agents isn’t the prompting, it’s the control surface: timeouts, retry policy, max loop iterations, tool-call validation, partial-failure recovery. Anthropic’s “Building Effective Agents” (2024) lays out the patterns that actually ship: prompt-chaining for sequential tasks, routing for classification, parallelization for fan-out, orchestrator-workers for hierarchical task decomposition. Reach for the simplest pattern that fits the task.

§ · FURTHER READINGReferences & deeper sources

  1. Yao et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models · ICLR
  2. Shinn et al. (2023). Reflexion: Language Agents with Verbal Reinforcement Learning · NeurIPS
  3. Park et al. (2023). Generative Agents: Interactive Simulacra of Human Behavior · UIST
  4. Wang et al. (2023). Voyager: An Open-Ended Embodied Agent with LLMs · arXiv
  5. Anthropic (2024). Building Effective Agents · Anthropic Engineering

Original figures live in the linked sources — open the papers for the canonical visuals in their full context.