Skip to main content
Reflection allows the agent to critique and improve its own responses before returning them. This “Self-Correction” pattern improves output quality by checking for errors, clarity, and completeness.

Enabling Reflection

To enable reflection, set reflection=True during agent initialization.

Configuring Reflection

You can customize the reflection process using ReflectionConfig.

When to Use Reflection?

  • Coding Tasks: To catch bugs and improve code quality.
  • Complex Reasoning: To verify logic and assumptions.
  • Creative Writing: To refine style and tone.
Reflection increases the time and token usage for each task as it involves additional model calls for critique and revision.