Reflection Loop
Scores each draft against a fixed rubric, feeds the critique into a revision, and repeats until the draft passes a threshold or the retry budget ends
Add to Pack
Saved locally in this browser for now.
Cite This Pattern
Nikola Balic (@nibzard) (2026). Reflection Loop. In *Awesome Agentic Patterns*. Retrieved October 14, 2026, from https://agentic-patterns.com/patterns/reflection
@misc{agentic_patterns_reflection,
title = {Reflection Loop},
author = {Nikola Balic (@nibzard)},
year = {2026},
howpublished = {\url{https://agentic-patterns.com/patterns/reflection}},
note = {Awesome Agentic Patterns}
} Use when
- Output must meet explicit quality criteria
- Single-pass answers miss edge cases or constraints
- Writing, reasoning, or code tasks with a clear scoring metric
Avoid when
- No well-defined metric to score drafts
- Extra compute per answer is not acceptable
Problem
Single-pass generation frequently misses edge cases, constraints, or quality criteria that become obvious on review. Without a structured revision loop, agents return the first plausible answer even when a better answer is reachable with lightweight critique.
Solution
After generating a draft, run an explicit self-evaluation pass against defined criteria and feed the critique into a revision attempt. Repeat until the output clears a threshold or retry budget is exhausted.
Use stable scoring rubrics (correctness, completeness, safety, style) so the loop improves objective quality rather than free-form restyling. For reduced bias, use a separate model for critique (dual-model architecture) at the cost of additional compute.
for attempt in range(max_iters):
draft = generate(prompt)
score, critique = evaluate(draft, metric)
if score >= threshold:
return draft
prompt = incorporate(critique, prompt)
How to use it
Use this when quality must meet explicit criteria in writing, reasoning, or code generation. Keep loop budgets small; there is no universally established optimum, so log score deltas per iteration and stop when the deltas flatten rather than assuming a fixed iteration count. Note that 2025-2026 reasoning models already internalize a form of self-checking in their thinking, so hand-rolled reflection scaffolds pay off mostly with non-reasoning models or when the rubric is domain-specific.
Trade-offs
- Pros: Improves outputs with little supervision.
- Cons: Extra compute; may stall if the metric is poorly defined.
References
- Self-Refine: Iterative Refinement with Self-Feedback - Madaan et al., 2023
- Reflexion: Language Agents with Verbal Reinforcement Learning - Shinn et al., NeurIPS 2023 - adds episodic memory for persistent learning across trials