Skip to main content
← Back to techniques

Reflexion

Reasoning

Level 3 · Agentic & composite

Attempt the task, check it against success criteria, reflect on failures, and retry — repeating until it succeeds.

Reflexion asks the model to attempt a task, evaluate its own attempt against explicit success criteria, and — if it fails — write a brief reflection on specifically why it failed before retrying the full task with that reflection in mind. Unlike a single self-critique pass, Reflexion repeats this cycle across multiple attempts, carrying forward what was learned from each failure.

When to use it

Use it for tasks with a clear, checkable success criterion where a single attempt often falls short but iterative refinement is likely to converge — puzzles, code that must pass specific tests, constrained writing tasks.

When to avoid it

Avoid it for tasks without a clear way to check success, or where a single well-structured attempt is already reliable.

Advantages

  • Learns across attempts, not just within a single pass, unlike a single self-critique
  • Particularly effective for tasks with an objective, checkable success criterion
  • The reflection step makes it possible to see why earlier attempts failed, not just that they did

Disadvantages

  • Can loop multiple times, multiplying token cost significantly
  • Only as good as the stated success criteria — a vague criterion produces vague reflections

Examples

Write a function that returns true only for prime numbers, and passes this test suite: [test cases for 2, 4, 17, 1, 0, negative numbers]

Attempt the task. Check it against the success criteria. If it fails, write a brief reflection on specifically why, then retry the full task incorporating that reflection. Repeat until it succeeds or you've tried 3 times.

Try it

Fill in the placeholders below and see the compiled prompt update live.

What you want to achieve.

The checkable criteria the result must pass.

40
Words
268
Characters
0/2
Placeholders filled
1 min
Reading time
Quality score11
  • Completeness0
  • Clarity0
  • Context0
  • Specificity0
  • Constraints0
  • Format0
  • Output0
  • Constraints note0
  • Success criteria100
  • Scope focus100
  • Verification step0
  • Negative example0
  • Confidence0
  • Placeholder syntax100
  • Markdown structure0
Suggestions
  • Fill in the remaining placeholders.
  • Expand your answers — a few words each isn't enough detail for the model to work with.
  • Add background context so the model understands the situation.
{{OBJECTIVE}} Success criteria: {{TEST_SUITE_/_SUCCESS_CRITERIA}} Attempt the task. Check it against the success criteria. If it fails, write a brief reflection on specifically why, then retry the full task incorporating that reflection. Repeat until it succeeds or you've tried 3 times.
AI Assistant

Jump to a page…

Navigation