Overview

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.

FAQ

What is reflection in designing AI agents?Reflection is the engineering of feedback that is allowed to change something. That change can be immediate, like revising the current artifact, or persistent, like admitting a reusable Skill or lesson for later tasks.
Why is reflection more than just “trying again”?A second pass without new evidence can improve an answer, keep it the same, or even make a correct result worse. Reflection becomes reliable when it uses evidence that is easier to ground than generation, such as tests, tools, source documents, or observed outcomes.
What are the four reflection patterns in this chapter?The four patterns are Generator-Critic, Self-Heal Loop, Skill Package, and Experience Replay. They differ by what they change, how long the change lasts, and what evidence is required before a change is trusted.
How does Generator-Critic work?Generator-Critic separates production from review: a Generator creates an artifact, a Critic evaluates it against criteria and evidence, and the Generator revises the same artifact or delivers it. It is best used when a current artifact needs a separate review path.
What makes a Critic effective in Generator-Critic?A useful Critic sees something different from the Generator: different criteria, context, evidence, or perspective. If the Critic has the same assumptions and evidence, it may repeat the same blind spot instead of finding new issues.
Why does Self-Heal Loop need protected verification?Self-Heal Loop is for recovering a failed task through diagnosis, repair, verification, rollback, and handoff. The verifier must stay outside the repair path so the agent cannot rewrite the evidence used to judge whether the repair actually worked.
What is a Skill Package?A Skill Package turns a successful, repeatable procedure into a versioned capability that can be reused in later tasks. It becomes eligible for routing only after isolated, coexistence, and trial evidence supports activation.
Why is Experience Replay separate from Skill Package?Experience Replay carries scoped advice from past traces into later work, but it does not grant execution authority. Skill Package admits a tested capability that can actually be routed and used; Experience Replay only influences planning, diagnosis, or checks.
How should evaluation evidence be chosen?Use the cheapest signal that can answer the current question, then add broader signals when failures can escape that scope. Examples include structural checks, deterministic verifiers, traces, invariants, rubric-based review, human judgment, and real-world outcomes.
Why does the chapter emphasize cost, regression, and accumulation across runs?A local fix can make one task pass while creating long-term burden, conflict, or latency across many runs. The chapter stresses measuring accumulated cost and regressions so the system improves as a whole, not just in isolated cases.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Designing AI Agents ebook for free