Reflect-Revise Pattern
The reflect-revise pattern has agents evaluate their own outputs against criteria, then iteratively improve based on self-identified issues.
What Problem It Solves
First-draft outputs from language models are often imperfect: - Missing information or coverage gaps - Logical inconsistencies or errors - Style or tone mismatches - Structural problems
External evaluation catches some issues, but models can often identify problems in their own outputs when explicitly prompted to evaluate them. Reflect-revise systematizes this self-improvement capability.
How It Works
Generate Phase Agent produces initial output for the given task.
Reflect Phase Agent (often with different prompting or even a different model) evaluates the output against explicit criteria: - Does it fully address the task? - Is the reasoning sound? - Are there factual errors? - Does it meet quality standards?
Revise Phase If reflection identifies issues, agent produces an improved version, specifically addressing the identified problems.
Iterate Reflect-revise cycles continue until output meets criteria or iteration limit is reached.
When to Use / When to Avoid
Use when: - Quality matters more than speed - You have clear evaluation criteria - First-draft quality is insufficient - Self-evaluation meaningfully catches errors
Avoid when: - Latency is critical - First drafts are typically sufficient - Evaluation criteria are unclear (reflection has nothing to check against) - The task is simple (overhead exceeds benefit)
Failure Modes
Infinite loops: Agent never satisfies criteria, revising forever. Mitigation: hard iteration limits and diminishing return detection.
Degradation: Revisions make output worse. Mitigation: compare revision quality to original; revert if degraded.
Surface-level fixes: Reflection identifies real issues but revision only addresses superficially. Mitigation: specific revision prompts targeting identified issues.
Evaluation blindness: Reflection consistently misses certain error types. Mitigation: diverse evaluation criteria and occasional external checks.
Esy Implementation Example
Esy's essay quality assurance uses reflect-revise:
Draft Phase: Initial essay content is generated with sources integrated.
Reflect Phase: A QA agent evaluates the draft against criteria: - Are all claims supported by cited sources? - Is the argument logically structured? - Does the tone match the specified audience? - Are transitions between sections smooth?
Revise Phase: If issues are found, specific revisions target each identified problem. The revision prompt includes both the original draft and the specific critique.
Quality Gate: After maximum iterations (typically 2-3), output is either accepted or flagged for human review if criteria still aren't met.
This systematically improves essay quality while maintaining reasonable generation times.