Reflection
After generating output, the agent explicitly evaluates its own work — identifying errors, weaknesses, and missing elements — then uses that self-critique to produce an improved version. The agent acts as its own reviewer. This can be single-pass (one reflection) or iterative (reflect-revise loop).
Structure
The agent generates, critiques, and revises in a self-contained loop. Unlike Evaluator-Optimizer (an orchestration pattern with two separate roles), reflection happens within a single agent.
How It Works
- Generate — produce an initial output
- Critique — evaluate the output against quality criteria (prompted self-review)
- Identify issues — list specific problems, gaps, or improvements
- Revise — incorporate the critique and produce an improved version
- Repeat or finish — loop until satisfactory or max iterations reached
The critique prompt matters. Effective patterns:
- "What's wrong with this output? List specific issues."
- "Score this output 1-10 on accuracy, completeness, and clarity. Explain each score."
- "If you were reviewing this, what feedback would you give?"
Key Characteristics
- Self-improving — output quality increases with each iteration
- Single agent — no separate evaluator needed (unlike Evaluator-Optimizer)
- Diminishing returns — most improvement happens in the first 1-2 reflections
- Self-blindness risk — the agent may not catch its own systematic errors
- Higher cost — each reflection cycle is an additional LLM call
When to Use
- Writing and editing tasks where revision improves quality
- Code generation — generate, then review for bugs and edge cases
- The agent makes systematic errors that it can catch with a targeted critique prompt
- You want quality improvement without the complexity of a separate evaluator agent
- Tasks where a human would naturally review their own work before submitting