Reflection Pattern (Self-Critique)
Always check your own work before handing it in
When you write an essay, your first draft is rarely your best. So you read it back, spot the weak parts, and rewrite them. Reflection gives an agent the same habit: after it produces an answer, it (or a second pass) critiques its own work and then revises it. The result is usually noticeably better than the first try.
Key points
- Reflection = the agent reviews and improves its own output.
- It works as a Generator → Critic → revise loop.
- Each round catches mistakes the first draft missed.
- Stop when the critic is happy or after a few rounds.
The one-line definition
Reflection is a pattern where the agent evaluates its own answer against the goal, lists what's wrong or missing, and then rewrites a better version — repeating this critique-and-revise loop a few times.
Note: Draft → critique the draft → revise → repeat.
The Generator-Critic loop
┌──────────────────────────────────────┐ │ │ ▼ │ ┌───────────┐ draft ┌─────────┴─────────┐ GOAL ───► │ GENERATOR │ ──────────────────► │ CRITIC │ │ writes a │ │ "What is wrong │ │ draft │ ◄────────────────── │ or missing?" │ └───────────┘ feedback └─────────┬─────────┘ │ looks good? │ ┌──────────────┘ │ yes ▼ ✅ FINAL ANSWER
What one round of reflection actually changes
ROUND 1 ROUND 2 (after critique) ─────── ────────────────────────
Draft: Critic said: "Python is a language." • too short │ • no example ▼ • missing 'why use it' ┌────────────┐ │ │ CRITIC │ finds gaps ──────────────┘ └────────────┘ ▼ Revised draft: "Python is a beginner- friendly language used for web, data & AI, e.g. print('hi'). People pick it because..." ✅ better
The 2 roles in Reflection
- Generator — Produces the first draft and every revised draft after feedback. Example: "Here is my answer to the user's question."
- Critic — Reviews the draft against the goal and lists concrete problems to fix. Example: "The answer is missing an example and ignores edge cases."
- Revise loop — Feed the critique back to the generator to rewrite; stop when good or after N rounds. Example: Usually 1–3 rounds is plenty before returns shrink.
A tiny code example (read it like English)
The same model can play both roles. First it generates, then we ask it to critique its own draft, then it rewrites using that critique. Notice the loop stops early when the critic says OK.
draft = llm(f"Answer this: {goal}") # GENERATOR
for round in range(3): # a few revise rounds
critique = llm(
f"Goal: {goal}\nDraft: {draft}\n"
"List concrete problems, or say 'GOOD'.") # CRITIC
if "GOOD" in critique:
break # critic is happy
draft = llm( # REVISE
f"Improve this draft.\n"
f"Draft: {draft}\nFeedback: {critique}")
print(draft) # final, polished answer
▶ Try it: a Generator → Critic → Revise loop
The agent reviews its own work and fixes it. Add another check to the critic!
draft = "i think recursion is when a fucntion calls itself"
def critic(text):
issues = []
if "fucntion" in text:
issues.append("typo: 'fucntion' should be 'function'")
if not text[:1].isupper():
issues.append("should start with a capital letter")
return issues
found = critic(draft)
print("Draft :", draft)
print("Critic :", found)
revised = draft.replace("fucntion", "function")
revised = revised[0].upper() + revised[1:]
print("Revised:", revised)
When is Reflection worth the extra cost?
| Scenario | Recommendation | Why |
|---|---|---|
| Quality really matters (code, important writing, math) | ✅ Use Reflection | A self-review round catches obvious errors before delivery. |
| There are clear correctness criteria to check against | ✅ Use Reflection | The critic has something concrete to test the draft against. |
| Simple, low-stakes one-liners | ❌ Skip it | The extra LLM calls cost time/money for little gain. |
| You need the cheapest, fastest possible response | ❌ Skip it | Reflection at least doubles the number of calls. |
Beginner Reflection mistakes
| Mistake | Consequence | Fix |
|---|---|---|
| Vague critique like "make it better". | The revision barely changes; you waste a round. | Ask the critic for SPECIFIC, listed problems and a clear bar for 'good'. |
| Infinite reflection rounds. | Cost explodes and quality plateaus. | Cap rounds (1–3) and stop early when the critic says it's good enough. |
| Critic and generator never disagree. | Self-critique becomes a rubber stamp that finds nothing. | Prompt the critic to be harsh, or use a separate model/persona as the critic. |
Remember these 3 lines
- Reflection = Generator drafts, Critic finds flaws, Generator revises.
- Make the critique specific and give a clear 'GOOD' stop signal.
- 1–3 rounds is usually the sweet spot — more rarely helps.
Key takeaways
- Reflection makes an agent critique and revise its own output in a Generator → Critic loop.
- Each round catches mistakes the first draft missed, improving quality.
- Keep critiques specific and cap the number of revision rounds (usually 1–3).
- Use it when quality matters; skip it for cheap, low-stakes tasks.
Frequently Asked Questions
What is Reflection Pattern?
When you write an essay, your first draft is rarely your best. So you read it back, spot the weak parts, and rewrite them.
How does Reflection Pattern work?
Reflection is a pattern where the agent evaluates its own answer against the goal, lists what's wrong or missing, and then rewrites a better version — repeating this critique-and-revise loop a few times.
What are the key takeaways about Reflection Pattern?
Reflection makes an agent critique and revise its own output in a Generator → Critic loop. Each round catches mistakes the first draft missed, improving quality. Keep critiques specific and cap the number of revision rounds (usually 1–3). Use it when quality matters; skip it for cheap, low-stakes tasks.
Related topics
Practice this on DevInterviewMaster
Read the full Reflection Pattern (Self-Critique) breakdown with interactive demos, quizzes, and Hinglish notes.
800+ system-design, LLD, coding, and design-pattern topics. Unlock everything with Pro (₹499, one-time) or Ultimate (₹999, one-time) — lifetime access, no subscription.