chapter seven

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

 

This chapter covers

  • Using feedback to improve an agent's current work and future behavior
  • Refining a current artifact with the Generator-Critic pattern
  • Recovering a failed task within a bounded Self-Heal Loop
  • Admitting reusable capabilities through the Skill Package pattern
  • Recalling validated lessons through the Experience Replay pattern
  • Choosing evidence that can reveal the failure under investigation
"An unexamined life is not worth living."

— Socrates, in Plato’s Apology 38a

An engineer building evaluation environments told me about an agent that added another safeguard whenever a new build failed. The safeguard addressed that failure, so the system kept it. The next failure led to another safeguard and another local check.

After about two months, the agent had accumulated dozens of constraints. The environments were more stable, but a build that had once taken about five minutes now took thirty minutes and sometimes close to an hour. Some safeguards overlapped while others worked against one another, even though each repair had made sense when it was added. Together, they had become a burden.

7.1 What is reflection?

7.1.1 Why another pass is not enough

7.2 Pattern: Generator-Critic

7.2.1 One artifact, a different line of inquiry

7.2.2 Design the Critic before adding iterations

7.2.3 Building Generator-Critic

7.2.4 When Generator-Critic breaks

7.3 Pattern: Self-Heal Loop

7.3.1 Recovery requires permission and responsibility

7.3.2 The fail-diagnose-fix-verify loop

7.3.3 Building Self-Heal Loop

7.3.4 When Self-Heal Loop breaks

7.4 Pattern: Skill Package

7.4.1 A successful run creates a candidate

7.4.2 One active Skill or conditional coexistence

7.4.3 Route in layers

7.4.4 Building Skill Package

7.4.5 Maintain the library from operating evidence

7.4.6 When Skill Package breaks

7.5 Pattern: Experience Replay

7.5.1 From an execution trace to a replayable lesson

7.5.2 Feedback latency changes the admission test

7.5.3 Record, admit, and recall

7.5.4 Building Experience Replay

7.5.5 When Experience Replay breaks

7.6 Composing reflection patterns

7.6.1 A current-task coordinator