Reflexive (self-critique) agent: draft, critique, revise
A reflexive agent checks its own draft against a rubric or tests and revises it, within a fixed number of rounds. Use it when first drafts are often close but need polish and a clear pass test exists.
Reflexive agent in 60 seconds
- What: an agent that critiques its own output and revises it, instead of returning the first draft.
- How: draft, critique against a rubric or tests, decide pass or fail, and revise with the feedback up to a fixed number of rounds.
- Best for: writing, code with tests, structured extraction, and any output that can be checked against clear criteria.
- Weak spots: a model can approve its own mistakes, extra rounds add cost, and vague rubrics produce vague feedback.
- Research link: Self-Refine (Madaan et al., 2023) has one model draft, critique, and refine in a loop with no extra training. Reflexion (Shinn et al., 2023) stores written self-reflections in memory to do better on later attempts.
Where this type fits
The types of AI agents hub groups agents by how they decide. The reflexive agent sits in the first family, beside the planning, ReAct, and plan-and-execute agents. Those types focus on choosing actions. This one focuses on the quality of the result. It can be added to any of them as a final stage, and it is the natural step before a learning agent, which keeps lessons across tasks.
The problem it solves
A language model writes its first answer in one pass and does not look back. That draft is often close, but it may contain a wrong figure, a missing section, a broken test, or a tone that ignores the brief. Each flaw is small. Together they decide whether a person trusts the output or has to fix it by hand. Without a review step, the cost of those flaws lands on the reader.
Models are frequently better at judging an answer than at writing a perfect one first time. Spotting that a paragraph lacks a deadline is easier than producing every paragraph correctly in one go. A reflexive agent uses that gap. It spends a second pass on checking, and the check produces specific feedback, such as "the refund window is missing" or "test three fails with a null value".
There is also a practical reason. Many teams already review output by hand with a checklist. A reflexive agent moves part of that checklist into the system, so obvious problems are fixed before a person looks. The person still reviews, but sees a stronger draft, and review time goes to judgement rather than typos and omissions.
How it works
- Take the task. Include the brief and the criteria the output must meet.
- Draft. The model produces a first version of the output.
- Critique. Check the draft against a rubric, a set of tests, or both. Tests and code checks are the most reliable. A model that scores the draft against written criteria is the fallback. The critique returns specific, actionable feedback, not just a score.
- Decide. If every criterion passes, stop. If not, and rounds remain, continue. If rounds are used up, stop and flag the output for a person.
- Revise. Give the model the draft and the feedback, and ask for a new version that fixes the listed issues without breaking what already passes.
- Output. Return the best passing draft, along with a note on how many rounds it took.
The dashed arrow is the whole idea, and also the main danger. It must have a ceiling. Each round costs a model call or two, and later rounds often change less. Two or three rounds usually capture most of the gain. A hard cap protects the budget and prevents an agent that cannot satisfy a contradictory rubric from looping forever.
Self-Refine, by Madaan and colleagues in 2023, describes this pattern directly: one model drafts, critiques its own output, and refines it in a loop, with no extra training. Reflexion, by Shinn and colleagues the same year, extends the idea across attempts. Agents turn task feedback into written self-reflections and keep them in memory so later attempts go better, again without changing model weights. The first is a within-task loop. The second is a memory of lessons, and it connects to episodic memory.
A worked example
Acme's support team asks the agent to draft a reply to a customer who wants a refund for a faulty kettle bought 40 days ago. The policy says refunds are available within 30 days, but faulty goods can be replaced within 12 months. The rubric has four checks: states the policy accurately, offers an option the customer can take, is polite and under 120 words, and includes the next step with a deadline.
Round 1 draft: "Thank you for contacting us. We are sorry to hear about your kettle. Unfortunately refunds are only available within 30 days, so we cannot help with this request." The critic checks it. Policy accuracy fails because the draft ignores the replacement route for faulty goods. Offers an option fails because it offers none. Tone and length pass. Next step fails because there is none. The feedback reads: "Mention the 12-month replacement for faulty goods, offer it, and give a next step with a deadline."
Round 2 draft: "Thank you for contacting us, and sorry your kettle is faulty. A refund is only available within 30 days, but faulty items can be replaced within 12 months. Please reply with a photo of the fault by 5 December and we will send a replacement." The critic finds all four checks pass, and word count is 52. The agent stops after two rounds and returns the draft with the note "passed in 2 of 3 allowed rounds".
{
"round": 1,
"checks": [
{"name": "policy_accurate", "pass": false, "note": "Omits 12-month replacement for faulty goods"},
{"name": "offers_option", "pass": false, "note": "No option the customer can take"},
{"name": "tone_and_length", "pass": true, "note": "54 words, polite"},
{"name": "next_step", "pass": false, "note": "No step or deadline"}
],
"all_pass": false
}Building it
The sketch below uses a rubric of independent checks. Programmatic checks, such as word count, run first because they are exact and free. A model-based critique handles the rest. The loop has a round cap, keeps the best draft seen, and stops early if a revision makes no progress. llm.generate() is a placeholder for your own model client.
import json
# Placeholder: llm.generate(prompt) -> str. Use a separate prompt (and ideally a separate
# model or temperature) for the critic so it does not just agree with the writer.
MAX_ROUNDS = 3 # hard cap: each round costs one or two model calls
MAX_WORDS = 120
RUBRIC = [
'States the refund policy accurately',
'Offers an option the customer can take',
'Gives the next step with a deadline',
]
def code_checks(draft):
# Why: exact checks should never be left to a model.
problems = []
if len(draft.split()) > MAX_WORDS:
problems.append(f'Over {MAX_WORDS} words')
return problems
def model_critique(task, draft):
prompt = ('Judge the draft against each rubric item. Return JSON: '
'{"failed": [{"item": str, "fix": str}]}\n'
f'Rubric: {RUBRIC}\nTask: {task}\nDraft: {draft}')
return json.loads(llm.generate(prompt)).get('failed', [])
def score(problems, failed):
return len(problems) + len(failed) # lower is better
def run(task):
draft = llm.generate(f'Write a reply. Task: {task}')
best, best_score = draft, None
for round_no in range(1, MAX_ROUNDS + 1):
problems = code_checks(draft)
failed = model_critique(task, draft)
current = score(problems, failed)
if best_score is None or current < best_score:
best, best_score = draft, current # keep the best draft, not just the last
if current == 0:
return {'output': draft, 'rounds': round_no, 'status': 'passed'}
feedback = problems + [f"{f['item']}: {f['fix']}" for f in failed]
draft = llm.generate(
f'Revise the draft. Fix only these issues and keep what already passes.\n'
f'Issues: {feedback}\nDraft: {draft}')
# Rounds used up: hand over for a person instead of pretending it passed.
return {'output': best, 'rounds': MAX_ROUNDS, 'status': 'needs_review'}
Two choices matter here. The agent keeps the best draft, because revisions can make things worse. And on failure it returns a clear status of needs_review rather than a draft that looks finished. Those two lines save more trouble than any prompt tuning.
Design decisions
- Critic source: prefer tests, schemas, and code checks over model judgement. Use a model critic only for qualities code cannot measure, such as tone or completeness.
- Round limit: default to three. Measure how much quality each extra round adds and cut the limit where the gain flattens.
- Critic independence: use a separate prompt for the critic, and consider a different model. A critic that shares the writer's blind spots will wave mistakes through.
- Rubric design: write checks as specific yes-or-no questions. "Is the deadline stated?" gives useful feedback. "Is it good?" does not.
- Cost control: run cheap checks first, and only call the model critic if they pass. Stop early when a draft passes.
- Failure handling: when rounds run out, return the best draft flagged for a person. Never present an unchecked draft as approved.
- Lesson storage: if you keep reflections across tasks, store them with a scope, a date, and an expiry, so old lessons do not mislead new work.
Measuring it
- Pass rate by round: the share of tasks that pass after round 1, 2, and 3. It shows how much each round adds.
- Quality lift: score first drafts and final outputs on the same test set with blind human review or a trusted automatic check. The difference is the real benefit.
- Critic agreement: compare critic verdicts with human verdicts on a sample. Compute how often they match, and how often the critic passes a draft a human rejects.
- Regression rate: the share of revisions that break something that passed before. A high rate means feedback is too broad.
- Cost per accepted output: total tokens across all rounds divided by outputs that passed, compared with a single-pass baseline.
When to use it, and when not to
| Situation | Use this type? | Why |
|---|---|---|
| Code generation where unit tests give a clear pass or fail | Yes | Test failures are precise feedback, and revision fixes real errors. |
| Customer replies that must follow a written policy | Yes | A rubric of policy checks catches omissions before a person sees the draft. |
| Structured extraction that must match a schema | Yes | Schema errors give exact feedback for a retry. |
| Quick, low-stakes answers where speed matters | No | Extra rounds add delay and cost for little gain. |
| Tasks with no clear success criteria | No | A vague critic produces vague changes, and quality may not improve. |
| Facts the model cannot verify itself | Maybe | Self-critique cannot add knowledge. Pair it with retrieval or a tool check. |
Trade-offs
| Dimension | Effect | What to do about it |
|---|---|---|
| Quality | Usually higher on checkable work. Little gain when the critic cannot spot the flaw. | Anchor critique in tests and specific rubric items. |
| Latency | Each round adds at least one model call, so the wait grows with rounds. | Cap rounds, stop on first pass, and show the draft early if useful. |
| Cost | Roughly the single-pass cost multiplied by rounds, plus the critic. | Run cheap checks first and measure the lift per round. |
| Complexity | Low to moderate. A loop, a rubric, and a cap. | Keep the rubric in version control and review it with real failures. |
| Failure modes | Self-approval of errors, oscillating revisions, and over-polishing. | Use independent critics, keep the best draft, and escalate on failure. |
Compared with related types
A ReAct agent improves its answer by gathering evidence from tools. A reflexive agent improves it by re-reading its own work. They combine well: gather facts with ReAct, then run a reflexive pass over the final answer. A learning agent goes further by keeping lessons across tasks and changing future behaviour.
When one model critiques itself, the critic may share its blind spots. The critic and reviewer loop uses a separate reviewer agent for a more independent view, at higher cost. Choose the in-agent loop for speed and simplicity, and the separate reviewer when the stakes justify it.
What this means for your role
Common mistakes
Further reading
- Types of AI agents: the hub page that compares every agent type.
- Self-Refine, Madaan et al., 2023: one model drafts, critiques its own output, and refines it in a loop, with no extra training.
- Reflexion, Shinn et al., 2023: agents turn task feedback into written self-reflections and keep them in memory to do better on later attempts, without changing model weights.
- Critic and reviewer loop: using a separate reviewer.
- Evaluation and observability: how to build rubrics and test sets.
A reflexive agent gives a model a second look at its own work. It pays off when the check is clear, the cap is firm, and a person still sees anything that fails.