Reflexion
Reflexion pattern for self-improving AI agents: verbal reinforcement learning where agents turn failures into written lessons and retry — no gradients required.
Last updated
Reflexion: Agents That Learn from Mistakes
Verbal reinforcement learning: the agent fails, writes itself a lesson, and retries with that lesson in context. No gradients, no fine-tuning — learning that happens in plain text, within a session.
Reinforcement learning improves a policy by turning failures into weight updates. Reflexion (Shinn et al., NeurIPS 2023) does the same thing without touching a single weight: when an attempt fails, a reflection step writes a short natural-language lesson — “I assumed the list was sorted; it isn’t; sort before binary search” — stores it in an episodic memory buffer, and injects it into the context of the next attempt. The feedback signal becomes words instead of gradients. With GPT-4 as the actor, this loop hit 91% pass@1 on HumanEval, beating the same model’s 80% baseline — an 11-point gain purchased entirely with retries and text.
Related
More in LLM & Agentic
LLM Lifecycle
PreviewComplete lifecycle of large language models from pre-training through fine-tuning, RLHF, and deployment — with architecture diagrams and production considerations.
How LLMs Call Tools
PreviewHow LLMs use function calling and tool use — the mechanics behind tool-calling agents, from prompt engineering to structured output.
When to Fine-Tune: The Decision Framework
PreviewShould you fine-tune at all? A structured decision framework for prompt engineering vs RAG vs fine-tuning.
LoRA, QLoRA & PEFT Methods
PreviewHow LoRA works inside transformer layers, QLoRA for memory-efficient training, and the full PEFT method comparison with code examples.
Get full access to all 87+ sections with code examples, diagrams, and interactive animations.
Unlock Premium