Skip to main content
Self-reflection enables agents to evaluate and improve their responses in async execution, bringing full feature parity with sync agents.
The user asks for copy; the agent drafts, self-reflects, and improves the answer before replying.

Quick Start

1

Basic Async Reflection

Enable reflection in async agents with simple boolean flag:
2

Custom Reflection Criteria

Configure reflection with custom criteria for async agents:

How It Works

Self-reflection in async agents follows the same process as sync agents:

Feature Parity

Prior to PR #1704, async agents had limited reflection support:
Before PR #1704: Only legacy custom-LLM async branch supported reflection; the default OpenAI async path skipped it entirely.After PR #1704: Self-reflection works uniformly in both sync and async agents on all execution paths, including the default unified-dispatch path.
Parse-error parity (PR #4253): The async path always bounded parse-error retries at max_reflect. The sync path did not — a reflection response that persistently failed to parse (a structured-output refusal, a content-filter block, or a truncation) looped forever. PR #4253 closes that gap: sync now terminates at max_reflect on parse errors, like async, and returns the un-reflected answer.This is termination parity, not call-count parity — the sync loop still issues one extra primary completion per reflection round, so sync and async do not cost the same under a persistent-refusal scenario.

Configuration Options

All reflection configuration options work identically in async agents:

Best Practices

Set reasonable min_reflect and max_reflect values to balance quality with performance. Async reflection still involves multiple LLM calls.
Provide specific evaluation criteria for better reflection quality. Generic criteria like “Is this good?” are less effective than specific requirements.
Reflection increases response time and token usage. Monitor these metrics in production async applications.
Wrap async reflection calls in try-catch blocks to handle potential timeout or API errors gracefully.

Async Agents

Complete guide to async agent execution

Self-Reflection Concepts

Core concepts and architecture