Skip to content

Latest commit

 

History

History
92 lines (80 loc) · 3.63 KB

File metadata and controls

92 lines (80 loc) · 3.63 KB
title Reflexion - Generator / Critic loop
tagline A generator writes; a critic reviews; loop until the critic approves or the budget runs out.
attribution Shinn et al.
tier snippet
canonical_url https://blog.langchain.com/reflection-agents/
upstream
repo ref paths
noahshinn/reflexion
main
when_to_use Quality matters more than latency, content, specs, security-sensitive code.
when_not_to_use Real-time UX where wall-clock time per request is the constraint.
tags
reflection
self-critique
two-agent
loop
inputs
A task whose failure mode can be critiqued
A critic prompt
An actor/agent prompt
review_gate
trust standards merge description
tool-assisted
tool-assisted
human-gate
Critic flags issues each iteration; human reviews the final PR.
checkpoints
phase description
per-iteration
Critic reviews actor output and produces a reflection before next attempt
use_cases
building-features
bug-fixing
sources
title author url year
Reflection Agents (LangChain blog)
LangChain
2024
title author url year
Reflection (AutoGen design pattern)
Microsoft
2025
title author url year
Anthropic Cookbook, evaluator_optimizer.ipynb
Anthropic
2024
related
patterns antiPatterns practices glossary workflows
reflexion-self-critique-loop
evaluator-optimizer
writer-reviewer-two-session
reflexion-blind-spot-loop
correction-spiral
graders-resistant-to-hacking
small-sample-evals-first
reflexion
agentic-loop
evaluator-optimizer-loop
tdd-red-green-refactor-skills
loop
trigger steps gate exit back
Task
Generator writes
Critic reviews
Approved / budget left?
Accept
revise

Two agents in a tight loop. A generator drafts the work; a critic reviews against a rubric and either approves or returns specific revisions. Productized in 2025 by AutoGen, LangGraph, and the Anthropic Cookbook after Shinn et al.'s 2023 paper.

The pseudocode is short:

draft = generator(task)
for _ in range(MAX_ITERATIONS):
    critique = critic(draft, rubric)
    if critique.approved:
        break
    draft = generator.revise(draft, critique)
return draft

The technique works because the critic's role is narrow, it evaluates against a written rubric, not against vague preferences. That structure prevents the loop from sliding into infinite "looks good now / wait actually" oscillations.

Use for quality-critical work: spec drafts, security-sensitive code, content destined for users. The original Reflexion paper reported a lift of GPT-4 HumanEval pass-rate from 80% to 91%.

Avoid for latency-critical paths. Each iteration is a model call; budgets compound fast.

Critic prompt template

You are a critic. Read this draft:
---
{draft}
---

Score it against these criteria:
1. {Criterion 1, specific, falsifiable}
2. {Criterion 2}
3. {Criterion 3}

For any criterion the draft fails, return: { "criterion": "...", "fix": "..." }
If all pass, return "APPROVED".
Do not score for vibes; only against the listed criteria.

Rubric checklist, 3 properties of a good critic rubric

  1. Specific. "Names match repo conventions" beats "code is well-named."
  2. Falsifiable. A second reader applying the rubric should agree on pass/fail.
  3. Tied to deliverable purpose. Rubric items that don't change the deliverable's success are noise.