7 Reflection and evaluation: How your agent audits and learns from itself
Reflection in agent systems is presented as feedback that is allowed to change behavior, but only when the feedback can see the right evidence, when the effect of a change can be verified, and when the agent is explicitly authorized to change something. The chapter opens by showing how local fixes can accumulate into a burden: an agent may keep adding safeguards that each solve one failure, yet the overall system becomes slower, more complex, and harder to maintain. The core message is that reflection must be engineered around scope, authority, timing, and evidence, not treated as a vague “try again” pass.
The chapter then organizes four reflection patterns by what they improve and how long the change lasts. Generator-Critic improves a current artifact through a bounded review loop, using criteria and independent evidence to decide whether to revise, accept, or stop. Self-Heal Loop repairs a failed task through diagnosis, bounded mutation, verification, rollback, and handoff, while keeping protected tests and policies outside the repair path. Skill Package turns a repeatable successful procedure into a versioned capability that can be admitted only after isolated, coexistence, and trial evidence, and Experience Replay stores traces and lessons so that only validated, scoped advice can be recalled for later tasks.
A major theme throughout is that evaluation must sit beside the change it judges. The chapter emphasizes protected evidence, hard gates, versioning, rollback, and calibrated metrics so the system cannot simply rewrite its own proof of success. It also shows how the four patterns compose: current-task review and recovery produce traces, and those traces may later become candidate skills or replayable lessons, but each follows its own admission path before affecting future work. The result is a practical framework for letting agents learn from themselves without collapsing into unbounded self-modification or mistaking local improvement for real system-wide progress.
The Generator-Critic chain. The Critic receives one artifact version, explicit criteria, and evidence; a bounded return permits another review.
The Self-Heal Loop. The agent captures a baseline, diagnoses a failure, checks repair authority, applies a change atomically, verifies it, and either recovers, retries, rolls back, or hands off.
Skill admission and maintenance. A trace proposes a candidate; isolated, coexistence, and trial gates control activation; operating evidence supports refinement, merging, demotion, deprecation, retirement, and rollback.
The Experience Replay hierarchy and recall path. Raw traces support candidate lessons; evidence admits scoped heuristics; task and trigger filters decide whether a replayable lesson enters live context.
Reflection patterns compose through traces and separate gates. Current-task review and recovery produce evidence; capability admission and replay admission control what later tasks may use.
The evaluation evidence stack. Structural checks, deterministic verifiers, traces, invariants, semantic review, human evidence, and real outcomes cover progressively different questions and feedback latencies.
Summary
- Reflection connects feedback to a permitted change. The design specifies what the feedback can see, when the result arrives, what the loop may change, and what evidence is required to retain that change.
- Generator-Critic improves a current artifact. Independence comes from a different review frame, criteria, context, or evidence, rather than agent count alone.
- Self-Heal Loop has greater recovery authority. It verifies each repair, preserves a rollback path, stops at a bounded limit, and hands control to a person when the recovery boundary is reached.
- Skill Package admits executable capability. Promotion requires isolated, coexistence, and trial evidence; routing first filters by permission, risk, dependency, and applicability.
- Low use sends a Skill to review. Retirement requires stronger evidence and a reversible path, and consequential scope changes require human approval.
- Experience Replay separates raw traces, candidate lessons, and replayable heuristics. Recording, replay admission, and runtime recall are separate decisions.
- Experience remains advisory. Recall occurs before planning for selected high-risk or repeated tasks and during recovery after a relevant trigger.
- Evaluation is part of each pattern's change path. Deterministic checks, traces, semantic review, invariants, human evidence, and real outcomes cover different scopes and feedback latencies.
- A hard regression cannot be hidden by an aggregate score. Cost, latency, state change, and human effort belong alongside task success.
- Each safeguard in the opening case passed its local check while the complete system became slower and more conflicted. Cross-run review and explicit retirement authority turn local reflection into system learning.
Designing AI Agents ebook for free