Overview

7 Reflection and evaluation: How your agent audits and learns from itself

The chapter presents reflection as the disciplined use of feedback that is allowed to change something, whether that means revising a current artifact, repairing a failed run, admitting a reusable capability, or storing a lesson for later use. Its central warning is that local fixes can look successful while quietly accumulating cost, complexity, or conflicting rules across many runs. To avoid that trap, the text emphasizes that reflection must be paired with explicit evidence, clear authority, and a stop policy that prevents endless iteration or overcorrection.

One major theme is separating production from review. For the current task, Generator-Critic improves an artifact by using a review path with independent criteria and evidence, while Self-Heal Loop repairs bounded execution only inside a protected recovery envelope. In both cases, the reviewer or verifier must see something the producer did not, and the system must preserve the best known version, support rollback, and stop when progress stalls. The chapter also shows that better evaluation is not just another pass: it requires grounded checks, calibrated rubrics, protected tests, and measurements like confirmed-issue precision, regression rate, latency, and cost.

The other major theme is cross-task learning. Skill Package turns a successful procedure into a versioned capability that can be routed later only after isolated, coexistence, and trial evidence support it, while Experience Replay stores traces and distills scoped lessons that may be recalled only when task, version, and trigger conditions match. Both patterns insist on provenance, conflict tracking, and reversible retirement so that admitted knowledge remains useful without becoming unsafe or stale. Taken together, the chapter shows how an agent can audit itself, recover from failure, and learn from experience without granting itself unlimited authority over its own evidence or behavior.

The Generator-Critic chain. The Critic receives one artifact version, explicit criteria, and evidence; a bounded return permits another review.
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.
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.
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.
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.
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.
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 AI agent design?Reflection is the engineering of feedback that is allowed to change something. That change may be temporary, like revising the current artifact, or persistent, like admitting a reusable Skill or lesson for later tasks.
Why is a second pass by the model not enough for reliable reflection?A second pass can improve an answer, leave it unchanged, or even make a correct answer worse. Without new evidence, it is still just probabilistic generation, so fluency alone does not prove that a real issue was found.
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 in what can change, what evidence is used, and whether the change affects only the current task or future tasks too.
What does the Generator-Critic pattern do?Generator-Critic separates production from review. One component creates the artifact, another reviews it against criteria and evidence, and then the artifact is revised or accepted based on that review.
What makes a Critic useful in Generator-Critic?A Critic is useful when it can see different evidence, criteria, or context than the Generator. If it uses the same assumptions and evidence, it may repeat the same blind spots instead of catching errors.
What is the Self-Heal Loop pattern?Self-Heal Loop is a bounded recovery cycle for failed execution. It captures the failure, diagnoses it, proposes a repair within allowed authority, verifies the result, and then either recovers, rolls back, or hands off.
Why must the recovery verifier be protected in Self-Heal Loop?The verifier must be outside the repair path so the agent cannot rewrite the evidence used to judge success. If the agent can change both the system and the test, it can manufacture its own success.
What is a Skill Package?A Skill Package is a versioned, reusable capability that can be admitted for later tasks. It is only activated after evidence from isolated, coexistence, and trial evaluation shows that it is safe and useful.
How is Experience Replay different from Skill Package?Experience Replay stores scoped advice learned from past traces, while Skill Package stores executable capability. Experience Replay influences planning or diagnosis, but it does not grant execution authority like a Skill does.
Why is evaluation central to reflection patterns?Because every reflection pattern needs evidence that matches the claim being made. Local success alone is not enough; the system also has to measure regressions, accumulated cost, latency, conflicts, and later outcomes across runs.

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


Close
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 Designing AI Agents ebook for free
Close
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 Designing AI Agents ebook for free