Inferensys

Glossary

Reflexion

An agentic framework that uses verbal reinforcement learning, where an agent reflects on task failure signals stored in episodic memory to improve its reasoning and decision-making on subsequent attempts.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
VERBAL REINFORCEMENT LEARNING

What is Reflexion?

An agentic framework that uses verbal reinforcement learning, where an agent reflects on task failure signals stored in episodic memory to improve its reasoning and decision-making on subsequent attempts.

Reflexion is an agentic cognitive architecture that implements verbal reinforcement learning by converting scalar failure signals into linguistic self-feedback. Unlike traditional reinforcement learning that updates model weights, Reflexion stores reflective critiques in an episodic memory buffer, allowing the agent to condition future reasoning on past mistakes without gradient-based optimization.

The framework operates through a three-component loop: an Actor generates text and actions, an Evaluator produces a heuristic reward signal, and a Self-Reflection module synthesizes the failure trajectory into a natural language summary. This verbal feedback is appended to the agent's context window on subsequent trials, enabling iterative improvement on complex tasks like code generation, sequential decision-making, and multi-hop question answering.

VERBAL REINFORCEMENT LEARNING

Key Features of Reflexion

Reflexion is an agentic framework that uses verbal reinforcement learning, where an agent reflects on task failure signals stored in episodic memory to improve its reasoning and decision-making on subsequent attempts.

01

Actor-Evaluator Loop

The core architecture separates the Actor (which generates actions and reasoning) from the Evaluator (which provides feedback). The Actor produces a trajectory using an LLM, and the Evaluator scores the outcome. On failure, the Evaluator's scalar reward or textual critique is stored in episodic memory, enabling the Actor to self-correct on the next trial without gradient updates.

02

Episodic Memory Buffer

Reflexion maintains a persistent episodic memory that stores reflective summaries of past failures. Unlike short-term context windows, this buffer retains lessons across multiple independent trials. Each entry captures:

  • The original reasoning trajectory
  • The failure signal from the environment
  • A verbal self-reflection diagnosing the error This allows the agent to accumulate experiential knowledge over long horizons.
03

Verbal Reinforcement Signal

Instead of updating model weights through traditional RL, Reflexion uses natural language as the reinforcement signal. The Evaluator generates a textual critique explaining why a trajectory failed. This verbal feedback is more sample-efficient than scalar rewards alone, as it provides dense, semantic guidance that the Actor can parse and act upon in subsequent prompts.

04

Heuristic-Based Self-Reflection

The reflection generation process follows a structured heuristic. When a task fails, the agent is prompted to analyze:

  • What went wrong in the reasoning chain
  • Which specific action caused the failure
  • What alternative strategy would avoid the error This structured introspection produces actionable insights that are appended to the agent's working memory for the next attempt.
05

Trial-and-Error Without Fine-Tuning

A defining characteristic of Reflexion is that it improves performance without any gradient-based optimization. The underlying LLM weights remain frozen. All learning occurs through in-context retrieval of past reflections. This makes the framework lightweight, model-agnostic, and immediately deployable with any sufficiently capable language model, avoiding the compute cost of RLHF or fine-tuning.

06

Application to Decision-Making Tasks

Reflexion was originally demonstrated on sequential decision-making benchmarks including:

  • AlfWorld: Embodied household tasks requiring multi-step planning
  • HotPotQA: Multi-hop question answering over Wikipedia
  • HumanEval: Code generation with unit test feedback In each domain, the agent iteratively refines its policy by reflecting on execution failures, achieving significant gains over baseline ReAct agents.
VERBAL REINFORCEMENT LEARNING COMPARISON

Reflexion vs. Related Techniques

A feature-level comparison of Reflexion against other iterative self-improvement and reasoning frameworks for large language models.

FeatureReflexionSelf-RefineReAct

Core Mechanism

Verbal RL with episodic memory

Iterative self-critique and revision

Interleaved reasoning and action

External Memory

Learning Signal

Binary task success/failure

Self-generated textual critique

Environmental observation

Persistent Improvement Across Episodes

Trial-and-Error Exploration

Heuristic for Self-Evaluation

Rule-based failure detection

LLM-as-judge prompting

Task-specific reward parsing

Primary Optimization Target

Decision-making and reasoning policy

Single output quality

Task completion trajectory

Risk of Hallucination Snowballing

Moderate

High

Low

REFLEXION FRAMEWORK

Frequently Asked Questions

Explore the core mechanisms of the Reflexion agentic architecture, a verbal reinforcement learning paradigm that enables large language models to autonomously improve their reasoning by reflecting on past failures.

Reflexion is an agentic framework that implements verbal reinforcement learning, enabling a large language model (LLM) agent to autonomously improve its decision-making by reflecting on prior task failures. Unlike traditional gradient-based fine-tuning, Reflexion operates entirely in the semantic space of natural language. The process involves a cyclical loop: an Actor agent generates a reasoning trace and action, an Evaluator tests the output and produces a scalar reward or failure signal, and a Self-Reflection module analyzes the sparse feedback to generate a detailed, linguistic critique stored in episodic memory. On subsequent attempts, this textual reflection is injected into the prompt as additional context, guiding the Actor to avoid repeating the same logical errors. This allows the model to learn from trial and error without updating its underlying weights.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.