Reflexion prompting

An agent prompting pattern that adds verbal self-reflection on failures into memory, used to improve performance on retries.

What is Reflexion prompting?

Reflexion prompting is an agent prompting pattern that adds verbal self-reflection on failures into memory, so the model can improve performance on retries. It is a simple but effective way to help an agent learn from its own mistakes without changing the model weights. (arxiv.org)

Understanding Reflexion prompting

In practice, Reflexion prompting asks an agent to inspect a failed attempt, write down what went wrong, and store that critique in an episodic memory buffer. On the next attempt, the agent can condition its answer or plan on that reflective text, which nudges it toward a better strategy. The original paper frames this as a form of verbal reinforcement learning, where language-based feedback stands in for weight updates. (arxiv.org)

This pattern is especially useful in multi-step tasks where errors are informative, such as coding, tool use, reasoning, and environment interaction. Rather than treating each retry as independent, Reflexion lets the agent carry forward lessons like missing constraints, wrong assumptions, or poor action order. In an LLM stack, it often sits alongside the main planner or executor, with reflection generated after an evaluation signal, then retrieved before the next trial.

Key aspects of Reflexion prompting include:

  1. Failure feedback: the agent needs a signal that a trial went wrong, such as an error, judge score, or task outcome.
  2. Self-critique: the model writes a short reflection about why the attempt failed and what to change next time.
  3. Episodic memory: reflections are saved and reused, rather than discarded after one turn.
  4. Retry conditioning: the next attempt includes the memory, which can steer planning and action selection.
  5. No weight updates: the improvement happens at prompt time, not through fine-tuning.

Advantages of Reflexion prompting

  1. Faster iteration: teams can improve behavior without running training jobs.
  2. Better retry quality: the model can explicitly correct prior mistakes on the next pass.
  3. Low infrastructure overhead: it works with existing prompts, judges, and agent loops.
  4. Interpretable behavior: reflections make it easier to see why the agent changed course.
  5. Broad fit: it can be applied across reasoning, coding, and tool-using workflows.

Challenges in Reflexion prompting

  1. Reflection quality: weak or vague critiques can lead to little improvement.
  2. Memory hygiene: storing too much reflection can add noise and context bloat.
  3. Reward ambiguity: if failure signals are unclear, the agent may learn the wrong lesson.
  4. Repeat errors: some tasks need more than text reflection to actually change outcomes.
  5. Evaluation dependence: it works best when retries can be scored cleanly and consistently.

Example of Reflexion prompting in action

Scenario: a coding agent tries to fix a failing test, but its first patch still misses an edge case.

After the test fails, the agent writes a short reflection like, “I fixed the main path but ignored empty input handling.” That reflection is saved to memory. On the next retry, the agent sees the note before generating a new patch, so it checks the edge case first and produces a more complete fix.

This is the core value of Reflexion prompting. The agent is not just repeating a prompt, it is carrying forward a usable lesson from the last failure. Over several retries, that can turn a brittle workflow into one that improves with each pass.

How PromptLayer helps with Reflexion prompting

PromptLayer helps teams manage the prompts, traces, and evaluations around Reflexion-style agent loops. That makes it easier to compare reflections, inspect retry behavior, and track whether a new memory strategy actually improves outcomes across runs.

Ready to try it yourself? Sign up for PromptLayer and start managing your prompts in minutes.

Related Terms

Socials
PromptLayer
Company
All services online
Location IconPromptLayer is located in the heart of New York City
PromptLayer © 2026