Reflection (Agent Pattern)
ReAct and Plan & Execute produce outputs — but they don't review their own work. Reflection adds self-correction: the agent generates a draft, critiques it, and revises — looping until the output is good enough. It mirrors how people draft, review, and improve, and it's one of the most reliable ways to raise output quality.
💡 In one line: Reflection has the agent critique its own output and revise it, looping generate → critique → revise until it's good enough.
What is the Reflection Pattern?
Reflection is a loop of generate → critique → revise. The agent produces an output, evaluates it against some criteria, then improves it based on that critique — repeating until the result is satisfactory or a limit is reached. It's self-correction built into the agent.
How It Works
Why Reflect?
First-pass outputs have errors. A dedicated critique step catches mistakes and lifts quality — exactly like draft → review → revise for a human. It reduces hallucination and makes results more reliable, often for a modest extra cost.
Variants
- Self-reflection — the same model critiques itself.
- Actor-critic — a separate generator and critic.
- Reflexion — learn from feedback, storing lessons in memory for next time.
- External feedback — use tests, tools, or compiler errors as the critique signal (ideal for code agents).
Where It Fits
Reflection layers on top of ReAct or Plan & Execute — you can reflect on the final output or on individual steps. It complements the other patterns rather than replacing them.
Examples
- Coding agent — write code → run tests → fix failures.
- Writing agent — draft → critique → revise.
- Reasoning — self-check the answer before finalising.
Benefits
- Higher quality and fewer errors.
- Self-improvement without retraining.
- Less hallucination and more reliability.
Trade-offs
- Extra LLM calls — more cost and latency.
- Diminishing returns — and it can over-revise.
- Bad critique → bad revision (garbage in, garbage out).
- Needs stopping criteria (a max-iterations cap).
Best Practices
- Define clear critique criteria.
- Prefer external signals (tests, tools) over self-judgement when available.
- Cap iterations to avoid runaway loops.
- A separate critic is often more objective than self-critique.
Summary
- Reflection loops generate → critique → revise for self-correction.
- It catches first-pass errors and raises quality — like draft-review-revise.
- Variants: self-reflection, actor-critic, Reflexion, and external-feedback.
- It layers on top of ReAct or Plan & Execute.
- Watch cost and diminishing returns; cap iterations and prefer objective critique signals.