Skip to content
The AI Agent Factory

36.9 When Claude Code gets it wrong, and the limits

Approved by
Panaversity ·
7 min read

In everyday life. A school's exam board worries most about two things: students who see the paper early, and teachers who mark their own pupils. Every rule it has comes back to those two.

What you will learn. The mistakes to look for first in a learning loop, the checklist that catches them, and what self-improvement cannot promise.

Why it matters. A broken work loop makes one mistake. A broken learning loop teaches the worker to make it every time.

Dreaming that writes straight to live memory

What it looks like. The dreaming Workflow ends with insert into memories, or calls a saveMemory helper the worker also uses.

How to catch it. Check dreaming's database role. Try to write to memories with it. Search the dreaming code for any write that is not to candidates.

The author reused as the judge

What it looks like. The evaluation runner calls the router with activity "judge", which routes to the same economy model that dreaming used, because it is the cheapest.

How to catch it. The runner must pass the author's model to the router as excluded. Write a test where only the author's model is available for judging: evaluation must stop and ask for a person, not judge itself.

Held-out cases leaking into evidence

What it looks like. The held-out cases are a filter on the same table dreaming reads (where held_out = false). One query without the filter, and dreaming sees the test.

How to catch it. Held-out cases live in a separate table that dreaming's role cannot read. Check the grants, not the queries.

Retrieval with no permission check

What it looks like. order by embedding <=> $1 limit 8, then a filter in TypeScript on the results. The model may already have been sent the unfiltered list, and the filter can drop all eight and return nothing useful.

How to catch it. Every memory query filters by tenant, status, validity, scope and release in SQL, before ranking, as in 36.2.

The review checklist for this chapter

Add these to your REVIEW.md:

  • Every memory has tenant, provenance, approver, validity and status.
  • Memory search filters by tenant, status, validity, scope and release before ranking.
  • Dreaming's role reads evidence and memories, writes only candidates, and has no deployment rights.
  • Held-out cases are in a table dreaming cannot read.
  • The judge is never the candidate's author; code checks run first.
  • Candidate moves follow the state table, by the named actor; approval binds the exact hash.
  • Every learning call reserves from the learning budget; safety fixes bypass the stop rules.
  • The autonomy report keeps failures in the count and mandatory approvals apart.
  • Rollback checks deletion and revocation before restoring a release.

The limits

Compounding is a hypothesis. The paper says so plainly. A worker that learns may keep getting better, or may stop. Persistent memory alone does not prove that a worker compounds.

Improvement can plateau. After the common cases are learned, the remaining errors are rare and varied, and each lesson is worth less. The stop rules in 36.7 exist for this.

Knowledge goes stale. Suppliers change layouts, bank details and terms. A verified fact from March may be wrong in June. Validity dates and expiry are not optional.

Learning can teach mistakes. A wrong lesson that passes a weak evaluation spreads to every assignment. That is why the gate is strict, the canary is small and rollback is fast.

What this chapter leaves out. Learning across many companies, and the governed company-wide form of knowledge, belong to Part VI. Changes to the platform's own code are never made by the learning loop.

Code in this chapter was tested locally. The lab's reference solution passes its tests on Wrangler's local runtime, with recorded model answers. The local database stand-in imitates Postgres roles and ranks memories in code; on Neon, use real roles and pgvector. It has not yet run on a deployed account. Ask Claude Code to check every API against the installed documentation.

The invariant. Learning is a hypothesis you keep testing: a strict gate, a small canary and a fast rollback, because a lesson can be wrong.

Check yourself. Claude Code's evaluation runner is fast and cheap because it judges with the same model that wrote the candidate, and all tests pass. Do you approve? (No. The author must never judge alone. Ask for the router to exclude the author's model, and for a test that proves it.)

  • Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), section 12.3
Owner
Panaversity