Reflexion

An agent framework that adds verbal self-reflection on past failures into memory to improve performance on retries.

What is Reflexion?

Reflexion is an agent framework that adds verbal self-reflection on past failures into memory so the agent can improve on retries. In practice, it turns mistakes into text-based feedback that the next attempt can use. (arxiv.org)

Understanding Reflexion

Reflexion comes from the idea of verbal reinforcement learning, where an agent does not update model weights after every miss. Instead, it writes a reflection about what went wrong, stores that reflection, and feeds it back into the next run as context. The original paper reports gains across tasks like sequential decision-making, coding, and language reasoning. (arxiv.org)

In an LLM stack, Reflexion usually sits around the agent loop, between evaluation and the next retry. That makes it useful when a team wants the system to learn from failed trajectories without retraining the base model. Over time, the reflection memory becomes a lightweight source of experience that can guide better plans, tool use, and final answers.

Key aspects of Reflexion include:

  1. Self-critique: the agent describes why a prior attempt failed.
  2. Persistent memory: the reflection is stored and reused on later attempts.
  3. Retry-driven improvement: each new attempt can incorporate prior lessons.
  4. Lightweight learning: the pattern improves behavior without changing model weights.
  5. Task-agnostic design: it can be applied to reasoning, code, and tool-using agents.

Advantages of Reflexion

  1. Better retry quality: the agent starts the next attempt with more context.
  2. No retraining loop: teams can improve behavior without fine-tuning after every failure.
  3. Easy to inspect: reflections are readable, which helps debugging.
  4. Fits agent workflows: it works naturally with planning, acting, and evaluation loops.
  5. Reusable lessons: past mistakes can inform future tasks with similar failure modes.

Challenges in Reflexion

  1. Reflection quality: weak critiques can reinforce the wrong lesson.
  2. Memory management: too much stored context can add noise.
  3. Evaluation dependence: the loop works best when failures are detectable.
  4. Prompt sensitivity: small wording changes can shift the reflection quality.
  5. No weight-level learning: it improves behavior at runtime, not the base model itself.

Example of Reflexion in Action

Scenario: a coding agent writes a function, tests it, and the test fails because it missed an edge case.

The agent then produces a short reflection, such as noting that it assumed only positive inputs, and stores that note in memory. On the next retry, it reuses that reflection and adjusts the implementation before running tests again.

This is the core Reflexion pattern: failure, self-review, memory, and a smarter retry. For teams building agentic products, that can turn repeated dead ends into faster convergence. (arxiv.org)

How PromptLayer helps with Reflexion

PromptLayer helps teams track the prompts, outputs, and evals that drive Reflexion-style loops, so reflections and retries are easier to compare over time. That makes it simpler to see which prompt changes improve recovery after failure and which ones add noise.

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