Paper Breakdowns  /  Reflexion
Paper 38~7 min readNortheastern / MIT · 2023
Paper Breakdown

Reflexion,
explained.

Reinforcement learning improves an agent by nudging millions of weights — slow, expensive, and impossible if the model is behind an API. Reflexion found a shortcut hiding in plain sight: when the agent fails, have it write down why, keep the note, and let it read its own advice before trying again. No gradients. No fine-tuning. The agent gets better the way people do — by remembering what went wrong.

Written breakdown
This one is a written deep-dive.
Paper, mechanism, worked math and a runnable version — all below ↓
01

Agents that make the same mistake twice

A ReAct-style agent can act, observe, and adapt within one attempt. But let it fail the whole task and try again, and something embarrassing happens: it repeats the same mistake. Nothing carried over. The standard fixes were both bad — fine-tune on failures (expensive, impossible via API, and one task's lessons overwrite another's) or hope a bigger context magically helps (it doesn't; raw failed trajectories are noise, not lessons).

What's missing is what humans do between attempts: compress the failure into a lesson. Not "here are the 4,000 tokens of my failed attempt" but "I forgot to handle the empty-list case."

02

Actor, Evaluator, Reflector

Reflexion splits the retry loop into three roles. The Actor attempts the task — writing code, navigating a household simulator, searching for answers. The Evaluator grades the attempt: unit tests for code, task success for environments, an LLM judge where nothing crisper exists. And the Self-Reflection model turns the graded failure into a short, specific verbal lesson.

The Reflexion loop — reinforcement through words
Actor attempts
Evaluator grades
tests · env · judge
Reflector writes
why it failed
Episodic memory
lessons persist
Retry with lessons
in context

The lessons accumulate in an episodic memory buffer that's prepended to every new attempt. Attempt three doesn't just know the task — it knows exactly how attempts one and two died.

03

Why words beat scalars

Classic RL compresses feedback into a single number — reward 0. Everything about why is discarded, and the algorithm spends thousands of episodes rediscovering it through trial and error. A verbal reflection keeps the why: which assumption was wrong, which edge case was missed, what to try instead. It's credit assignment in prose — precise, immediate, and executable by the very next attempt.

Test failed: merge_intervals([[1,4],[4,5]]) → expected [[1,5]]
Reflection: "I treated touching intervals as disjoint. Boundary equality must merge — use start <= prev_end, not <."
Attempt 2: passes.
The key idea

The model already contains the machinery to diagnose failures and follow advice — it's a language model. Reflexion routes the learning signal through that machinery instead of through the weights. Policy improvement becomes a context update.

The whole loop is one line of state that survives between attempts — the memory of what went wrong:

Delete that memory arrow and every retry is attempt one again. The runnable version below shows it fix the boundary bug on attempt two — and a memoryless retry failing forever.

04

The numbers

TaskResult
HumanEval (code, GPT-4)80% → 91% pass@1 — SOTA at publication
ALFWorld (household decision-making)+22 points absolute over ReAct baseline
HotPotQA (multi-hop reasoning)+20 points over strong baselines

The coding result carried the headline: with nothing but self-generated unit-test feedback and verbal retries, GPT-4 jumped eleven points on the benchmark everyone watched. The breadth mattered more — the same three-role loop worked on navigation, search and code, unchanged.

05

The limits

Reflexion learns nothing durable — lessons live in a context buffer, bounded by the window, gone when the episode ends (unless you persist them into real memory). It leans on the Evaluator: crisp signals like unit tests make it soar; fuzzy self-evaluation can reinforce confident nonsense. And reflection quality is capped by the model's own diagnostic ability — an agent that misunderstands why it failed writes itself bad advice and then dutifully follows it.

It's also, quietly, a test-time method: multiple attempts cost multiple rollouts. Like self-consistency and ToT, it buys capability with inference compute.

06

Why it still matters

Reflexion named and validated the pattern that now lives inside nearly every serious agent: try → check → diagnose in words → retry with the diagnosis. Every coding agent that reads its own test failures and patches, every harness with a critique-then-revise step, every eval loop that feeds errors back as guidance — that's the Reflexion loop, productionized.

Its deeper claim aged even better: a model's language channel is a legitimate substrate for learning. That idea threads through self-critique training, agent post-mortems written to memory, and the whole self-improvement research line. Weights are one place to store lessons; words, it turns out, are another.

Read next

The within-attempt loop it extends: ReAct. Where the lessons should live: MemGPT. The evaluator side: Agent Evals.

RUN IT YOURSELF

Watch an agent learn from its own failure

Reflexion's loop is small enough to run — using the paper's own merge_intervals boundary bug. The Actor writes code, the Evaluator runs unit tests, and the Reflector turns the failing case into a specific lesson ("touching intervals must merge — use <=") that persists in memory. Watch it fail attempt one, reflect, and pass attempt two. Then watch a memoryless retry repeat the same mistake five times. The only difference is whether the lesson is remembered.

CPython · WebAssembly
07

Using it in practice

Reflexion splits the agent into three roles, and getting each right is what makes it work. The actor attempts the task; the evaluator judges the attempt (a test suite, a reward signal, an exact-match check); and the self-reflection step turns a failure into a short natural-language lesson stored in memory. The next attempt reads those reflections back into context. The whole method lives or dies on the evaluator: if it can't tell success from failure, the reflections are noise and the loop just churns.

That is why the method shines where feedback is concrete and cheap. Coding tasks with unit tests, decision-making tasks with a clear win/lose signal, and puzzles with a checkable answer all give the evaluator something real to grade, so the verbal lesson ("I forgot to handle the empty-list case") is grounded and actionable. Tasks with vague or delayed feedback give it little to reflect on, and the gains shrink.

The verbal signal is the clever part. Classic reinforcement learning nudges weights with a scalar reward; Reflexion instead writes an explicit sentence about what went wrong and what to try next, and feeds it back through the context window. It needs no gradient updates or fine-tuning — the "learning" is entirely in memory and prompt — which is what let it work on a frozen model. But that also bounds it: the lesson only helps while it stays in context, and a reflection that doesn't generalize can misfire on the next attempt.

Modern agent loops inherited the core idea directly. The pattern of act → evaluate → reflect → retry, with lessons carried in external memory, is now standard in agent harnesses that iterate on tests, retry failed tool calls with the error fed back, and keep a running scratchpad of what has and hasn't worked. Reflexion was an early, clean statement of the loop that most self-improving agents now run.

Frequently asked

Quick answers

What is Reflexion?

A framework where agents improve across attempts via verbal self-reflections stored in episodic memory — reinforcement through words, no weight updates.

How does the loop work?

Actor attempts, Evaluator grades (tests/environment/judge), Reflector writes why it failed, memory keeps the lesson, the retry reads it.

Headline result?

HumanEval with GPT-4: 80% → 91% pass@1, plus ~20-point gains on ALFWorld and HotPotQA.

Main limitation?

Nothing is learned durably — lessons are context, bounded by the window, and only as good as the model's own diagnosis.

Finished this one? 0 / 111 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns