reflection=True on an agent and it critiques its own answer before returning — improving quality within the same task.
Quick Start
How It Works
After each response, the agent runs one or more reflection passes (betweenmin_iterations and max_iterations). Each pass asks whether the answer meets quality criteria; if not, the agent revises before returning.
Configuration Options
ReflectionConfig SDK Reference
Full parameter reference for ReflectionConfig
| Option | Type | Default | Description |
|---|---|---|---|
min_iterations | int | 1 | Minimum reflection passes |
max_iterations | int | 3 | Maximum reflection passes |
llm | str | None | None | Model for reflection (defaults to agent model) |
prompt | str | None | None | Custom evaluation prompt |
Choosing Reflection Strength
Best Practices
Disable for tool-heavy agents
Disable for tool-heavy agents
Reflection adds an extra LLM pass per turn. Set
reflection=False on agents that call tools frequently to keep latency down.Pair with a dedicated reflection model
Pair with a dedicated reflection model
Use
ReflectionConfig(llm="gpt-4o") when the main model is fast but you want a stronger critic.Do not confuse with self_improve
Do not confuse with self_improve
reflection improves this answer within the task. self_improve captures reusable skills for next time — they compose independently.Set max_iterations for cost control
Set max_iterations for cost control
Cap
max_iterations in production to avoid runaway loops on open-ended prompts.Related
Self Improve
Capture reusable skills after each task
Guardrails
Validate agent outputs with policies
Planning Mode
Let agents plan before acting
Execution Systems
Configure agent execution limits

