What is reflection in AI agents?
Reflection in AI agents is the process of reviewing an action, result, or completed attempt to identify what worked, what failed, and what should change next. Rather than repeating the same approach automatically, the agent uses feedback to improve its next decision.
A practical example
An agent generates an API test suite, runs it, and gets this result:
3 tests failed because the endpoint expects a required account_id field.
A reflection step can examine the failed tests and the API specification, then record:
- The generated requests omitted a required field.
- The next version should include a valid account_id.
- The revised tests must be rerun and checked against actual test results.
The agent then revises the test suite. Reflection is useful because it turns observable feedback into a specific improvement.
How does reflection work?
- Attempt: The agent takes an action or produces an output.
- Observe: It collects evidence, such as test results, errors, tool outputs, or user feedback.
- Evaluate: It compares the evidence with the task's acceptance criteria.
- Identify an improvement: It determines what should change and why.
- Apply and verify: It updates the next attempt and checks whether the change helped.
Reflection can happen after one important step or after a whole task attempt.
Where does feedback come from?
- External feedback: Unit-test results, API errors, validators, user corrections, or task-success signals.
- Self-critique: A model reviews its own answer or plan against stated requirements.
External checks are often stronger evidence. A model's self-critique can miss mistakes or confidently suggest an incorrect fix, so reflection should not be treated as proof of correctness.
Reflection vs. replanning
Reflection evaluates evidence and derives lessons or corrections.
Replanning changes the remaining actions.
An agent can reflect without changing its plan, or use a reflection result to decide that replanning is necessary.
Does reflection train the model?
Not necessarily. In systems such as *Reflexion*, agents can store textual lessons from feedback and use them in later attempts without changing model weights. Whether lessons persist across tasks depends on the system's memory design.
When is reflection useful?
Reflection is especially useful when outcomes can be checked: coding, test generation, document review, multi-step problem solving, or tool-driven tasks with clear success criteria.
However, repeated self-review adds latency and cost. Use bounded reflection at meaningful checkpoints, and stop when checks pass or additional attempts are no longer useful.
In short
Reflection lets an AI agent learn from feedback within its execution process: observe an outcome, assess it against a goal, and use the findings to improve the next attempt. Its value comes from evidence-based corrections, not simply asking the model to think again.
Sources & Research References
Learning Sequence
AI Agents Curriculum
Explore Related Questions
Deepen your understanding across related AI Agents topics.