AI Wisdom

Reflection Pattern

Have the agent critique its own output and iteratively refine it before returning the final result.

In this article

Problem: First-pass LLM outputs frequently contain errors, gaps, or suboptimal structure. Without review, these defects reach users.

Solution: After generating an initial response, make a second LLM call instructed to critique the first output โ€” identify errors, missing information, and improvements. Then make a third call to revise based on the critique. Optionally loop until a quality threshold is met.

Implementation:

  1. Generate: First LLM call produces initial response
  2. Critique: Second call with prompt: "Review this response for errors, gaps, and improvements: [response]"
  3. Revise: Third call: "Rewrite the response addressing these critiques: [critique]"
  4. Gate: Check revision quality with a short evaluator call; loop if below threshold (max 3 iterations)

Trade-Offs:

  • โœ” Pro: Significant quality improvement on complex tasks (20-40% reduction in errors)
  • โœ” Pro: Self-contained โ€” no external data required
  • โœ– Con: 2-3x cost and latency over single-pass generation
  • โœ– Con: Risk of "sycophantic revision" โ€” model agrees with its own critique without meaningful changes

When To Use: Code generation, long-form content, technical explanations, and any high-stakes output where quality trumps speed. When to avoid: Real-time chat, simple factual lookups, latency-sensitive applications.

Discussion

Sign in to share your feedback and join the discussion.