FDEInterviews logo
NeurIPS 2023

Reflexion: Language Agents with Verbal Reinforcement Learning

The 2023 paper that taught agents to learn from failure without training: after each failed attempt, the model writes itself a lesson and reads it on the next try.

Breakdown by FDE Interviews · 12 min read · Updated

About the original · 2023
AUTHORS
Shinn, Cassano, Berman, Gopinath, Narasimhan, Yao
FROM
Northeastern University, MIT, Princeton University
PUBLISHED
Mar 2023 · NeurIPS 2023
CITED BY
6,118Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 22% of this breakdown.

01

The paper in one minute

Language agents built on ReAct and similar methods act, observe and act again, but they do not learn from one attempt to the next. If an agent picks up the wrong pan on its first try, it is just as likely to do it on the second. The standard machine-learning answer, reinforcement learning, would update the model's weights from rewards, which takes many samples and a fine-tuning budget that was out of reach for GPT-3.5- and GPT-4-sized models.

Reflexion, from Noah Shinn and colleagues at Northeastern, MIT and Princeton (including ReAct's Shunyu Yao), does the learning in text instead. Three model roles work in a loop. An Actor attempts the task. An Evaluator scores the attempt: exact match against the answer, a hand-written heuristic, an LLM judgment, or unit tests the agent wrote itself. A Self-reflection model reads the failed attempt and its score and writes a short lesson in plain language, such as which action went wrong and what to do instead. The lesson goes into a memory of the last one to three lessons, which is added to the Actor's prompt on the next try. The loop repeats until the evaluator says pass or the trial budget runs out.

The results were strong for 2023. On HumanEval, GPT-4 with Reflexion reached 91% pass@1, against 80.1% for GPT-4 alone. On ALFWorld, text-based household tasks, the agent solved 130 of 134 within 12 trials. On 100 HotPotQA questions, success rose by about 20 points over the trials.

The paper also showed where it fails. On MBPP Python, the agent's self-written tests let wrong code through 16.3% of the time, and Reflexion scored 77.1%, below GPT-4's 80.1% without it.

THE IDEA, VISUALLY
LEARNING BY WRITING NOTES, NOT BY TRAINING Actor LLM attempts the task Evaluator tests, heuristic or LLM Self-reflection LLM explains the failure Memory last 1 to 3 lessons attempt pass / fail lesson next try No weights change. The 'reinforcement' is text in the prompt: a short lesson naming the step that went wrong and what to do instead on the next attempt. The loop stops when the evaluator says pass, so the evaluator's mistakes decide the result. ONLY AS GOOD AS ITS OWN TESTS GPT-4 pass@1, base vs Reflexion, Tables 1 and 2 HumanEval, Python base 80.1 Reflexion 91.0 self-written tests passed wrong code 1.4% of the time MBPP, Python base 80.1 Reflexion 77.1 self-written tests passed wrong code 16.3% of the time Same model, same loop. The difference is how often the agent's own tests said 'pass' on a wrong answer.
Reflexion's loop on the left. On the right, the same model and loop gained 11 points on one coding benchmark and lost 3 on another, depending on how often its own tests passed wrong code.
Research notes: the problem, approach and results
91%

HumanEval pass@1 with GPT-4 and Reflexion, against 80.1% for GPT-4 alone

130 / 134

ALFWorld household tasks solved over 12 trials with a simple failure heuristic

16.3%

of passing self-written MBPP tests let wrong code through, which made Reflexion worse there

THE PROBLEM

Agents repeat the same mistakes across attempts, and the usual fix, reinforcement learning on the model's weights, needs many samples and expensive fine-tuning.

THE IDEA

Turn each failure signal into a short written lesson, keep the last few lessons in memory, and put them in the prompt for the next attempt. The model's weights never change.

THE RESULT

GPT-4 with Reflexion reached 91% pass@1 on HumanEval against 80% without it, solved 130 of 134 ALFWorld tasks, and gained 20 points on 100 HotPotQA questions given feedback between trials.

02

Why it matters to an FDE

The pattern in this paper, try, check, write down what went wrong, try again, is now everywhere: coding agents that run tests and fix failures, extraction pipelines that validate output and re-prompt, support agents that retry a failed API call with a corrected argument. Reflexion is the clearest early statement of it, and of its one hard dependency.

The check decides everything. The loop stops when the evaluator says pass. If the evaluator passes wrong answers, the agent ships them confidently; if it fails right answers, the agent may edit working code into broken code. In the paper, the same model and loop gained 11 points on one benchmark and lost 3 on another because of test quality. Before you add a reflection loop, measure how often your check is wrong.

Some reported gains used the answer key. On HotPotQA, the evaluator between trials was exact match against the gold answer, so the agent was told when it was wrong. In ALFWorld, the environment reported success. In production you rarely have either. The programming results are the ones that hold without an answer key, because there the agent used only tests it wrote itself.

It costs attempts. Every reflection is another model call and another attempt. The 2024 paper AI Agents That Matter found that Reflexion cost over 50% more than a simple retry baseline with rising temperature on HumanEval, at similar accuracy. Price the loop before you promise it.

The lessons are readable. Unlike weight updates, a reflection is text a person can audit, which helps debugging and review.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 49 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦3 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The three roles, what the results show, the ablation and the misreadings to avoid

    Free account
  2. 04How it works

    The algorithm, each benchmark's setup, and the programming test pipeline

    Premium
  3. 05The numbers that matter

    Every result in one place, including the one where Reflexion lost

    Premium
  4. 06Try it yourself

    Simulate a test-and-retry loop and watch the quality of its own check cap the result

    Premium
  5. 07Where it breaks

    The limits the paper names, and the ones later work found

    Premium
  6. 08Using it on a deployment

    Where a reflection loop earns its cost, and how to build one safely

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →