DevInterviewMasterStart free →
Agentic AI PatternsFree to read

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

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

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?

ScenarioRecommendationWhy
Quality really matters (code, important writing, math)✅ Use ReflectionA self-review round catches obvious errors before delivery.
There are clear correctness criteria to check against✅ Use ReflectionThe critic has something concrete to test the draft against.
Simple, low-stakes one-liners❌ Skip itThe extra LLM calls cost time/money for little gain.
You need the cheapest, fastest possible response❌ Skip itReflection at least doubles the number of calls.

Beginner Reflection mistakes

MistakeConsequenceFix
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

Key takeaways

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.

Browse all Agentic AI Patterns topics →

Practice this on DevInterviewMaster

Read the full Reflection Pattern (Self-Critique) breakdown with interactive demos, quizzes, and Hinglish notes.

Open the interactive topic →

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.