Shinn et al. ask what happens when a language agent is allowed to try, fail, and then speak back to itself before the next try. Standard agents repeat the same trajectory on a second attempt because the weights never move and the prompt only carries the question. Reflexion adds a self-reflection step: after each failed trial the model writes a short paragraph naming what went wrong, that paragraph enters a sliding episodic memory buffer, and the next trial sees it. No gradient, no fine-tuning, no RL — only free-form language feedback to the next prompt.
The numbers are not uniform. On HumanEval (Python) Reflexion jumps to 91.0 Pass@1 from a GPT-4 baseline of 80.1; on HumanEval (Rust) it lifts 60.0 to 68.0; on Leetcode Hard it doubles 7.5 to 15.0. But on MBPP (Python) it actually loses — 77.1 vs the GPT-4 baseline 80.1 — because false-positive test suites stop the agent early, and on WebShop the authors terminate after four trials because the agent does not generate useful reflections. The session below is a teaching schematic, not a paper figure. The argument and the tables are in the paper; this site does not host the PDF.
teaching explainer · Shinn et al. · NeurIPS 2023 · GPT-3/3.5/4 · arXiv:2303.11366 | traces are schematic session logs; numbers marked paper-report come from the tables
0overview
core: Reflexion reinforces language agents with verbal self-reflection and an episodic memory buffer; no weight updates, faster learning from trial-and-error.
speak after failure
After each failed trial the agent writes a short paragraph in plain language naming what went wrong. No gradient, no fine-tuning — free-form text feedback to itself.
episodic buffer
The reflection is appended to a sliding memory: last 3 in ALFWorld, last 3 in HotPotQA, last 1 in programming. Older entries drop off.
next trial sees memory
The next attempt is conditioned on the reflection. The same trajectory is not repeated — the plan is rewritten before the first new action.
paper §4.2 implements HotPotQA two ways: Reflexion + CoT (no env) and Reflexion + ReAct (with Wikipedia API). Figure 7 demos the ReAct path, which this page reuses for §1 and §4.
1problem: agents repeat the same mistake
point: Standard, CoT-only, and ReAct-only all finish with Rene Artois. Reflexion alone sees Trial 2 — its memory carries the lesson that the show title was the wrong search target. Below: one HotPotQA question from paper Figure 7, four prompting styles. The question, the INCORRECT / CORRECT verdicts, and Reflexion's self-reflection are paper Figure 7 verbatim; the intermediate Search / Obs lines are schematic ("first 5 sentences") to fit the tty pane.
question · INCORRECT / CORRECT verdict · Self-Reflection text are paper Figure 7 verbatim. Intermediate Search / Obs are schematic ("first 5 sentences (schematic): ...") so they fit the tty pane; the paper figure has the full Wikipedia paragraphs.
Question (paper Figure 7 verbatim) · Grown-Ups starred the actor who was best known for which role on "Allo 'Allo!"?
Trial 1 Trial 2 Self-Reflection Memory FAIL SUCCESS
2mechanism: trial → reflect → retry
point: at trial the agent sees the prompt and emits actions . On failure it generates a self-reflection ; that text is appended to memory . Trial then sees alongside the original prompt.
action obs / fail self-reflection memory slot
3case: ALFWorld, paper Figure 5 verbatim
point: the task is to examine the mug with the desklamp (paper Figure 5 verbatim). Trial 1 walks drawers 1-6 (closed), then desk 1, picks up the mug, walks back to desk 1 and again to desk 2, and tries to use desklamp 1 twice — nothing happens, the desklamp and the mug were never co-located. The self-reflection (paper Figure 7 verbatim) names the mistake: look for the desklamp first, both objects are on desk 1. Trial 2 does exactly that and turns on the desklamp with the mug in hand.
task description, the desk-1 obs ("creditcard 3, a desklamp 1, ... a mug 1 ..."), the desk-2 obs ("alarmclock 1, a bowl 1, a mug 3 ..."), the Status lines, and the self-reflection text are all verbatim paper Figure 5. Use desklamp 1 / take mug 1 from desk 1 are ALFWorld verbs.
agent action env obs self-reflection (paper Figure 5) Memory FAIL SUCCESS
4case: HumanEval, paper Appendix C.1 task + C.2 prompt
point: The agent writes an implementation, the unit tests fail on an edge case (empty array). The Self-Reflection prompt (paper Appendix C.2 verbatim) drives a self-reflection that names the missing guard; trial 2 adds it. Memory here is a sliding window of last 1 (paper §2) — the only domain where the window is smaller than 3.
task signature (minSubArraySum docstring + two examples) and the Self-Reflection prompt are paper Appendix C.1 / C.2 verbatim. Trial 1 / Trial 2 code bodies and the test feedback are schematic; the paper reports Pass@1 (Table 1) and the Table 3 ablation, not a per-trial trace for this problem.
code test feedback self-reflection (paper Appendix C.2 prompt) Memory (last 1, paper §2) FAIL PASS
5results and limits
point: HumanEval Pass@1 climbs from GPT-4 80.1 to 91.0 (PY) and 60.0 to 68.0 (RS); Leetcode Hard doubles 7.5 to 15.0. But MBPP Python actually drops 80.1 to 77.1 because false-positive test suites let the agent stop early. WebShop terminates after four trials without improvement.
Reflexion GPT-4 baseline Prev SOTA / ablation paper-report numbers
91.0%
HumanEval PY Pass@1 (Reflexion, GPT-4)
80.1%
HumanEval PY GPT-4 baseline (no reflection)
77.1%
MBPP PY Reflexion — loses to GPT-4 80.1 (false-positive tests)
0.60
ablation: omit self-reflection → matches base (reflection alone is not enough)
The four cards are paper-report results, not computed from the printout above. WebShop is terminated by the authors after four trials; the agent does not generate useful reflections there.
Schematic traces are not paper figures. Paper-report numbers: Shinn, Cassano, Berman, Gopinath, Narasimhan, Yao, Reflexion: Language Agents with Verbal Reinforcement Learning, NeurIPS 2023, arXiv:2303.11366. This site does not host the PDF.