TL;DR
Agents that critique their own output, learn from mistakes, and get better over time - the three patterns that actually ship, from simple reflection loops to tree search and meta agents.
| Topic | Official Source |
|---|---|
| Reflexion (Shinn et al., 2023) | arxiv.org/abs/2303.11366 |
| LATS (Zhou et al., 2024) | arxiv.org/abs/2310.04406 |
| ADAS / Meta Agent Search (Hu et al., 2024) | arxiv.org/abs/2408.08435 |
| LangGraph Reflection Agents | blog.langchain.dev/reflection-agents |
| LangGraph Reflexion + LATS examples | github.com/langchain-ai/langgraph |
| Anthropic building effective agents | anthropic.com/engineering/building-effective-agents |
| Developers Digest video | youtube.com/watch?v=RoaPvj9Ovug |
Most AI agents run in a single pass: prompt in, response out. If the output is wrong, you fix it yourself and move on. The agent never learns what went wrong, and your next session starts from zero.
Self-improving agents flip that. Instead of a fire-and-forget pipeline, the agent reflects on its own output, evaluates what worked and what didn't, and iterates until it converges on a better result. The pattern shows up across three tiers - from a simple 2-node loop you can build in an afternoon to meta-agents that write new agents in code. Here is the map, with real implementations you can use today.
The video above walks through each pattern visually - the post gives you the concepts, the video shows the live demo flow that a static page cannot: seeing an agent correct its own output in real time, backtracking from bad decisions, and converging on a solution it could not reach in one shot.
Every self-improving agent follows the same skeleton:
The magic is in step 2. If the reflection is just "try harder," you get a more confident wrong answer. If the reflection is grounded in external data - test pass/fail, search results, compiler output - the loop converges toward correctness. The difference between a toy demo and a production agent lives in how you ground the reflection step.
For background on the agent infrastructure this runs on, our agent architecture guide walks through state management, error recovery, and the production gotchas that turn a five-step demo into a reliable system.
The entry point. Two LLM calls wired in a loop: a generator and a reflector. The generator produces output. The reflector is prompted to role-play as a critic - "act as a code reviewer," "act as a teacher grading the response" - and returns constructive feedback. The generator gets another shot with the feedback in context. Loop N times, then return the last output.
from langgraph.graph import MessageGraph
builder = MessageGraph()
builder.add_node("generate", generation_node)
builder.add_node("reflect", reflection_node)
builder.set_entry_point("generate")
def should_continue(state):
if len(state) > 6:
return END
return "reflect"
builder.add_conditional_edges("generate", should_continue)
builder.add_edge("reflect", "generate")
graph = builder.compile()
This works for: polishing writing, improving code comments, catching obvious logic gaps. It costs 2x-3x the tokens of a single pass.
It fails when: the reflection has no external grounding. A generic "be more thorough" critique produces a longer response, not a better one. If your generator already missed something, a same-model reflector in the same session often misses it too.
The LangGraph reflection example ships a full implementation. Start here before reaching for heavier approaches.
Newsletter
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools, delivered free every week.
From the archive
Jul 26, 2026 • 5 min read
Jul 25, 2026 • 7 min read
Jul 25, 2026 • 12 min read
Jul 25, 2026 • 22 min read
Reflexion, from Shinn et al. (2023), adds the missing piece: episodic memory. The agent stores its reflections in a persistent buffer and references them on future attempts. It also grounds criticism in external data - search citations, test results, compiler errors - rather than free-form commentary.
The three-part architecture:
On the HumanEval coding benchmark, Reflexion hit 91% pass@1 on GPT-4, up from the baseline 80%. That 11-point gain comes entirely from the reflection loop - no model fine-tuning, no weight updates.
The LangGraph Reflexion example implements this with a draft -> execute_tools -> revise loop. The key difference from simple reflection: the revise node is grounded in external tool output, and reflections persist across iterations.
When to use Reflexion over simple reflection:
For a real-world example of agent loops scaling in production, see how AI agent evaluation tools compare across 2026 - the reflection pattern is the backbone of most eval harnesses shipping today.
Language Agent Tree Search (LATS, Zhou et al. 2024) replaces the single-path loop with tree search. Instead of one refine pass, the agent generates multiple candidate next actions, evaluates each in parallel, and picks the best path using Monte Carlo tree search. If one branch dead-ends, it backpropagates the failure signal and explores alternatives.
This unifies reasoning, planning, and reflection into a single algorithm. The LangGraph LATS example shows it in ~300 lines of Python.
At the top of the complexity curve: Automated Design of Agentic Systems (ADAS, Hu et al. 2024) uses a meta-agent that writes new agents in code. The meta-agent generates agent programs, tests them against benchmark tasks, keeps the winners, and iterates. The agents it discovers often outperform hand-designed agents and transfer across domains - an agent invented for coding tasks beat hand-designed agents at math.
This is still research, but the direction is clear: the hardest agent design problems will eventually be solved by agents themselves.
The simplest shipped version of this pattern is Claude Code's self-improving skills system. After a session where you correct the assistant - fixing a wrong selector, tightening a validation, adjusting a naming convention - a reflection hook analyzes the corrections and updates the relevant skill file:
# .claude/hooks/stop.sh
reflect --auto
The skill file is plain markdown, stored in Git. Each update is a commit. Bad learnings roll back with git revert. This is the transparent, auditable version of agent memory - no embeddings, no retrieval chains, just versioned text that improves session over session. Our self-improving skills guide covers the full setup, from manual reflect commands to automated stop hooks.
The same pattern surfaces in agent fleet economics: as models get cheaper, running reflection loops becomes a cost tradeoff rather than a capability brick wall. Our agent fleet economics analysis shows the math on multi-pass workflows at current pricing.
| Scenario | Use Self-Improving Agents | Skip |
|---|---|---|
| Coding with real test suites | Reflexion with test pass/fail as ground truth | - |
| Factual QA / research | Reflexion grounded in search citations | - |
| Low-latency chatbots (<2s) | - | Fire-and-forget single pass |
| Cost-sensitive batch processing | Simple reflection (2-3 iterations max) | Deep search patterns |
| Writing / content generation | Simple reflection (polish pass) | Anything beyond 2 iterations |
| Agent design / architecture | LATS or ADAS if you have a benchmark | Simpler patterns if you don't have eval infrastructure |
The rule of thumb: if you can measure correctness, investing in a reflection loop pays for itself. If you can't, you are just spending tokens on random walks.
Self Improving Agents in 5 Minutes - watch for the live agent loop in action: the video shows an agent generating a response, reflecting on it, refining it, and converging on a correct solution in real time. Seeing the back-and-forth between actor and reflector is the part a static post cannot replicate.
Chain-of-thought is a single-pass reasoning strategy - the model thinks step by step but never revisits its choices. Reflection is a multi-pass loop: the model produces output, evaluates it, and gets another attempt. Chain-of-thought answers "how do I solve this?" Reflection answers "is this solution actually correct?"
No. The patterns described here work entirely through prompting and tool use. Reflexion stores reflections in an episodic memory buffer, not model weights. The agent gets better within a session or across sessions through text memory, not gradient updates. Fine-tuning from reflection data is a separate (and powerful) optimization, but it is not required to ship a self-improving agent today.
A simple 3-iteration reflection loop costs roughly 3x the tokens of a single pass. With prompt caching, that drops toward 1.5x-2x for subsequent iterations since the system prompt and reflection history are cacheable. At current frontier pricing ($1-2/M input tokens), a reflection loop adds cents per task for most workflows.
Yes, and mixing models often helps. A cheaper model (Claude Haiku, GPT-5 Mini, Gemini Flash) works well as a reflector since the critique task is simpler than the generation task. Using the same model for both actor and reflector risks the blind-spot problem - the same failure modes appear in both roles.
Three approaches: (1) store reflections as text in a persistent skill file (the Claude Code pattern), (2) maintain an episodic memory buffer keyed by task type, (3) fine-tune on collected reflection data. Option 1 ships today with zero infra. Option 2 requires a vector store or message history. Option 3 is the long game and needs good data hygiene first.
Read next
AI agents that reflect on failures, accumulate skills, and get better with every session. Reflection patterns, memory architectures, skill extraction, and working code examples for building agents that actually learn.
13 min readLilian Weng argues self-improving AI won't start with models rewriting their weights - it starts with the harness. Here's what that means for developers building agents.
7 min readFrom single-agent baselines to multi-level hierarchies, these are the seven patterns for wiring AI agents together in production. Each with a decision rule, an implementation sketch, and the tradeoffs that actually matter.
10 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
A hosted infinite canvas your headless AI agents drive over MCP. Any MCP-speaking agent - Claude Code, Codex, Cursor, or...
View ToolAnthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolMost popular LLM framework. 100K+ GitHub stars. Chains, RAG, vector stores, tool use. LangGraph adds stateful multi-agen...
View ToolGives AI agents access to 250+ external tools (GitHub, Slack, Gmail, databases) with managed OAuth. Handles the auth and...
View ToolSpec out AI agents, run them overnight, wake up to a verified GitHub repo.
View AppDesign subagents visually instead of editing YAML by hand.
View AppQueue and organize repeatable agent workflows before they become production automations.
View AppDeep comparison of the top AI agent frameworks - LangGraph, CrewAI, Mastra, CopilotKit, AutoGen, and Claude Code.
AI AgentsConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI AgentsDefine custom subagent types within your project's memory layer.
Claude Code
Build Anything with Vercel, the Agentic Infrastructure Stack Check out Vercel: https://vercel.plug.dev/cwBLgfW The video shows a behind-the-scenes walkthrough of how the creator rapidly builds and d...

Setting Up Self-Improving Skills in Claude Code: Manual & Automatic Methods In this video, you'll learn how to set up self-improving skills within Claude Code. The tutorial addresses the key problem

Leveraging Anthropic's Subagent for Claude Code: A Step-by-Step Guide In this video, we explore Anthropic's newly released subagent feature for Cloud Code, which allows developers to create...

Anthropic cut 80% of Claude Code's system prompt for Opus 5 and Fable 5 with zero regression on coding evals. The post l...

Anthropic removed over 80% of Claude Code's system prompt for Claude 5 models. Here is how the rules changed and what it...

Prompt injection, sandbox escapes, and hallucinated dependencies are now documented, patched, CVE-numbered realities. He...

A step-by-step guide to configuring an isolated Mac that Claude Code can fully control remotely - from SSH and Dispatch...

A new Vera paper tests Codex, Claude Code, OpenClaw, and Hermes with executable safety cases. The useful lesson is not p...

Lilian Weng argues self-improving AI won't start with models rewriting their weights - it starts with the harness. Her...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.