Reflexion: Language Agents with Verbal Reinforcement Learning
Language agents can be improved across trials without any weight updates by converting environment feedback into natural-language self-reflections stored in a bounded episodic memory, which acts as a "semantic gradient" conditioning subsequent attempts.

Oct 2023 · Paper
1. Motivation
Reinforcement learning (RL) improves policies through gradient updates on scalar rewards, but applying RL to large language model (LLM) agents is expensive and often impractical: fine-tuning frontier models is costly or impossible via APIs, and rewards in interactive tasks (embodied environments, question answering, programming) are sparse and uninformative.1 Reflexion asks whether the feedback signal of RL can be preserved while replacing the weight update with something an LLM already does well - reading and writing text. The hypothesis is that binary or scalar feedback, once “amplified” into a specific verbal lesson (“you kept searching the countertop, but the mug was in the cabinet”), can steer the next trial the way a policy-gradient step would.2 This reframes agent improvement as a memory-engineering problem, an idea nearly every later agentic discovery system - from ReEvo to the AI Co-Scientist - reuses in some form.3
2. Methodology
2.1 Search Structure
Reflexion is an iterative trial-and-error loop over whole episodes, formalized as its Algorithm 1 “Reinforcement via self-reflection”:2
repeat until Evaluator pass or max trials:
τ_t = Actor(mem) # full trajectory of actions/observations
r_t = Evaluator(τ_t) # scalar / binary / heuristic score
sr_t = SelfReflection(τ_t, r_t) # verbal lesson in first person
mem = mem ∪ {sr_t} # episodic buffer, |mem| ≤ Ω
Search operates at the granularity of episodes, not tokens or steps: each iteration produces one complete trajectory, scores it, and distills one reflection. Three task families instantiate the loop: sequential decision-making (AlfWorld, ReAct Actor), single-step reasoning (HotPotQA, chain-of-thought [CoT] or ReAct Actors), and programming (HumanEval, MBPP, LeetcodeHardGym).2
2.2 State Representation
The policy is parameterized as with : the frozen LLM plus memory. Two memory tiers exist: (i) short-term memory - the current trajectory history of action–observation pairs, analogous to RL state; (ii) long-term memory - stored self-reflection texts from past trials.2 Long-term memory is deliberately bounded: “we bound mem by a maximum number of stored experiences, (usually set to 1–3).”2 The sliding window keeps the most recent 3 reflections for AlfWorld/HotPotQA and only 1 experience for programming tasks.2
2.3 Generation Mechanism
The Actor is a prompted LLM - GPT-3 for AlfWorld, GPT-4 for programming - using CoT or ReAct prompting, conditioned on observations plus the reflection buffer.2 No gradients are computed anywhere; improvement is generated purely by re-prompting with accumulated verbal lessons. In the programming setting the agent additionally generates its own unit-test suite via CoT prompting (at most tests), filtered for syntactic validity by abstract-syntax-tree (AST) construction before execution.2 The Self-Reflection model is itself an LLM prompted to convert the failed trajectory and its reward into a specific, actionable first-person hint.
2.4 Evaluation & Grounding
Three evaluator types are explored: (i) exact-match grading (HotPotQA binary success); (ii) hand-written heuristics for AlfWorld - reflect if the same action–response pair repeats for more than 3 cycles or the episode exceeds 30 actions (“inefficient planning”); (iii) self-generated unit tests executed against real compilers/interpreters (MultiPL-E for Rust).2 The pass@1 claims for programming rest specifically on self-generated tests, not hidden ground-truth suites - a grounding choice with measured consequences (see §2.7).2
2.5 Memory / Information Flow
The information pipeline per trial is:
failed trajectory τ → scalar reward r → Self-Reflection LLM
→ verbal lesson sr ("semantic gradient")
→ append to episodic buffer (sliding window, Ω ≤ 3)
→ inject as context into next trial's Actor prompt
A HotPotQA ablation isolates the value of verbal distillation versus raw persistence: CoT(GT) plus episodic memory (raw last trajectory) versus CoT(GT) plus Reflexion - self-reflection adds an 8% absolute boost over raw episodic memory, showing that the compressed lesson, not mere trajectory replay, drives the gain.2
2.6 Selection & Propagation
There is no population and no selection operator: Reflexion is single-agent hill-climbing across trials. “Propagation” reduces to which experiences survive the sliding window - only the most recent reflections persist - and the loop terminates on Evaluator pass or after 3 consecutive failed attempts per task (HotPotQA).2 This makes Reflexion the minimal, non-evolutionary pole of the selection spectrum later populated by Promptbreeder’s tournaments and MAP-Elites’ archive elitism.
2.7 Anti-Slop / Anti-Hallucination Mechanisms
Controls are structural, not prompt-level. The AlfWorld heuristic explicitly targets hallucination (the agent believes it holds an item it does not) and looping; ReAct-only converges with a 22% hallucination failure rate that Reflexion largely eliminates via distilled self-hints.2 For code, AST syntax filtering rejects malformed self-tests, and the paper honestly reports a false-positive analysis of its test suites: MBPP-Python’s false-positive rate of 16.3% versus HumanEval-Python’s 1.4% explains Reflexion’s underperformance on MBPP (Table 2).2
3. Results
- AlfWorld (134 tasks): ReAct+Reflexion solves 130/134 (97%), an absolute +22% over the ReAct baseline within 12 trials; ReAct-only plateaus at trials 6–7.2
- HotPotQA (100 questions): +20% over CoT/ReAct baselines; baselines show zero probabilistic recovery of failed tasks at temperature 0.7.2
- Programming pass@1 (GPT-4 Actor, Table 1): HumanEval-Python 91.0 vs GPT-4 base 80.1; HumanEval-Rust 68.0 vs 60.0; MBPP-Rust 75.4 vs 70.9; LeetcodeHardGym 15.0 vs 7.5; MBPP-Python 77.1 vs 80.1 - the one loss, attributed to test-suite false positives.2
- Ablation (HumanEval-Rust 50 hardest): full Reflexion 68%; removing self-reflection → 60% (no gain over base); removing test generation → 52% (worse than base - the agent makes harmful edits without grounding).2
Baselines were re-run by the authors under the same Actor models; independent evidence on other tasks (multiple-choice QA across 9 LLMs) found statistically significant gains for self-reflection generally ().4
4. Limitations & Assumptions
The authors concede Reflexion “may still succumb to non-optimal local minima” and depends entirely on the LLM’s self-evaluation ability - a weak reflector yields useless lessons.2 Memory is a short sliding window; the authors suggest vector/SQL stores as future work.2 Test-driven grounding fails for non-deterministic, impure, hardware-dependent, or concurrent code.2 Most importantly, the headline 91% HumanEval figure is conditioned on self-generated tests with nonzero false-positive rates, so it should be read as “pass@1 against a self-authored oracle,” not hidden-test SOTA.2
5. Critical Analysis
- Distinctive strength: Reflexion isolates and quantifies the value of verbal memory - the +8% HotPotQA ablation over raw episodic memory is rare causal evidence that distilled natural-language lessons beat replay, and the omission ablations (reflection → no gain; tests → harmful) cleanly attribute gains to each component.2
- Structural weakness / trade-off: a single-agent, single-trajectory loop with memory cannot accumulate population-level diversity; it trades exploration breadth for cheap, API-compatible improvement and inherits the reflector’s blind spots (MBPP’s false-positive tests silently certified wrong programs).2
- Connections: ReEvo directly extends Reflexion from binary rewards to comparative reflection over parent heuristics inside an evolutionary loop.3 FunSearch and AlphaEvolve replace the verbal buffer with an execution-grounded program database - the same “learn from evaluated history without weight updates” principle, grounded by compilers rather than self-report.56 The MLE agents (AIDE, ML-Master, MARS, FM-Agent) inherit Reflexion’s reflect-on-failure debug loop and its self-test machinery, including the false-positive accounting problem.
6. References
Footnotes
-
Shinn et al., Reflexion (arXiv abstract): https://arxiv.org/abs/2303.11366 ↩
-
Shinn et al., Reflexion, NeurIPS 2023 (PDF v4): https://arxiv.org/pdf/2303.11366.pdf · proceedings: https://papers.nips.cc/paper_files/paper/2023/hash/1b44b878bb782e6954cd888628510e90-Abstract-Conference.html · code: https://github.com/noahshinn/reflexion ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11 ↩12 ↩13 ↩14 ↩15 ↩16 ↩17 ↩18 ↩19 ↩20 ↩21 ↩22 ↩23 ↩24
-
Ye et al., ReEvo, NeurIPS 2024: https://arxiv.org/abs/2402.01145 ↩ ↩2
-
Renze & Guven, Self-Reflection in LLM Agents (2024): https://arxiv.org/abs/2405.06682 ↩
-
Romera-Paredes et al., FunSearch, Nature 625:468–475: https://www.nature.com/articles/s41586-023-06924-6 ↩
-
Novikov et al., AlphaEvolve: https://arxiv.org/abs/2506.13131 ↩