Skip to main content
Reflection makes agents review and refine their own answers, catching mistakes and improving quality automatically.
The user asks a question; the agent drafts, self-reviews, and refines before returning the final answer.

Quick Start

1

Level 1 — Bool (simplest)

Turn on self-review with a single flag.
2

Level 2 — Config class (tune iterations and LLM)

Use ReflectionConfig to control how many review passes run and which LLM critiques.
3

Level 3 — Config with a custom review prompt

Pass a domain-specific prompt to steer what the self-review checks for.

How It Works


Configuration Options

Full list of options, types, and defaults — ReflectionConfig

Common Patterns

Pattern 1 — Quality-focused writing

Pattern 2 — Factual accuracy check


Best Practices

Enable reflection for writing tasks, technical explanations, and any output where quality matters more than speed. Skip it for simple lookups, calculations, or real-time applications.
Each reflection pass costs an additional LLM call. Set max_iterations=1 for light review, 2 for thorough review, and only go to 3 for high-stakes content. The default is 3.
Default reflection uses general quality criteria. Pass a prompt tailored to your domain — e.g., “Check for HIPAA compliance language” for medical agents or “Verify all code is PEP 8 compliant” for coding agents.

Planning — plan before acting on complex requests

Self-Reflection Deep Dive — advanced reflection patterns