Skip to content
The AI Agent Factory

Chapter 36. The Self-Improvement Platform: Memory, Dreaming, Evaluation and Evolution

Approved by
Panaversity ·
13 min read

The point

What a worker learns should belong to the company, not to the model. In Chapter 31 you taught Brightline's AP worker to learn from its own runs. It reflected on its work and proposed lessons, and a person approved the good ones before they went live. You kept its memory as versioned files in the worker's repository, with Claude's memory stores and dreams as the hosted option (31.13). It worked, and it was the fastest way to see the idea.

This chapter rebuilds the same loop on the open stack, and adds four things Chapter 31 could not:

  1. Memory that survives a change of model. The worker's approved knowledge lives in your database. Switch it from Claude to an economy model and it still knows Acme's suppliers.
  2. A learning budget. Learning costs money. It gets its own budget, and it stops when the budget runs out or the value is not there.
  3. Measured value. A single number, the verified autonomy rate, tells you whether the worker needs people less than it did last month.
  4. Learning to need no model. The best lesson a worker can learn is that a repeated job no longer needs reasoning. It becomes a typed tool, a function with fixed inputs and outputs that calls no model, written by Claude Code and approved by you. The worker gets cheaper as it gets better.

You, the expert, decide what is worth keeping. Dreaming proposes. Code and an independent evaluation test. A person approves every one, even the low-risk lessons Chapter 31 let through automatically. Nothing the worker learns reaches production any other way.

The learning loop as five boxes left to right. Work: each assignment writes an experience record. Dreaming: proposes candidates, such as memories, skills and tools, and changes nothing itself. Evaluation: code checks first, then a judge that is not the author, on held-out cases; one regression sends the candidate to rejected. Approval, in gold: a person with the right role approves the exact hash, before it expires. Canary: about 10% of new assignments, picked by a hash of each assignment's ID, compared with the rest. If the canary passes, the release becomes active and all new work uses it; if a stop rule fires, it is rolled back and the previous release is restored. A dashed arrow from active back to work says the new release reaches new assignments, and running work keeps its release unless it is revoked. A box below lists what the loop never does: dreaming reads through its own database role and cannot write a memory or see the held-out cases; the loop never changes the harness or the Workflow code, which engineers change by review; a rollback restores the previous release but does not undo a payment already posted; and learning has its own budget, so when the stop rules say wait, dreaming waits.

Figure 36.1. Who may do what in the learning loop. Later sections build each box.

A map of the Part IV platform in four rows, foundation at the bottom, then work, platform and learning, with economics as a column on the right. Highlighted as this chapter, Chapter 36: Memory (facts, source, expiry); Dreaming (proposes candidates); Evaluation (held-out cases, new judge); Releases (approve, canary, roll back). Already built in earlier chapters: Control plane (workers, versions, tenants); Model router (filter, then rank); Role contracts (one authorize check); Tenant walls (and proven deletion); The AP worker (one object per conversation); Waits, approvals (asleep, not paying); Workflows (month-end reconciliation); Events, schedules (per-worker coordinator); Harness (Pi Durable); Runtime (Durable Objects); Process engine (Cloudflare Workflows); Model access (any model, AI Gateway). Dashed, later in this part: economics (Chapter 37). A note at the foot says approved knowledge, case files and the governed door are stand-ins here, and Part VI replaces them with the systems of record.

Where this chapter sits in Part IV. The same map opens every chapter, with that chapter's parts highlighted.

Why it matters

This story is invented.

Over six months, a firm's AP worker learned three things. One supplier always puts the PO number in the invoice's footer. Another sends credit notes as negative invoices. A third must never be paid before the 15th. The lessons lived in the model provider's memory feature. Then the firm moved the worker to a cheaper model, from a different provider, to save $7 a month. The lessons did not come with it. For three weeks, the review queue filled with mistakes the worker had stopped making in March.

The firm had paid for the learning. It did not own it.

Words this chapter uses

The words of Chapter 31 keep their meaning: reflection, dreaming, candidate, promotion, golden set. The words of Chapters 33 to 35 do too: release, role contract, coordinator, tenant, correlation ID.

WordMeaning
Experience recordA structured record of one finished assignment: evidence, versions, outcome, cost, corrections
ProvenanceWhere a memory came from, who approved it, and when
CandidateA proposed change to memory, a skill or a procedure, which cannot be edited once made
Held-out casesTest cases dreaming never sees, used only to evaluate its proposals
CanaryA release given to a small share of work first, to catch problems early
ManifestThe list of exact versions that make up one release
Learning budgetThe money a worker may spend on learning in a month
Verified autonomy rateThe share of attempted assignments accepted with no discretionary correction

What you will build

Where you are. Brightline's platform runs AP workers for two companies, with a control plane, routing by activity and data class, and role contracts in code.

What you build, with Claude Code, from your own spec and failure tests:

  1. A memory store in Neon with pgvector, outside any model provider, with provenance and permission checks.
  2. Dreaming as a Workflow, on the cheapest model that qualifies, that reads past evidence and writes only candidates.
  3. An evaluation gate on held-out cases, where code checks first and no model judges its own work.
  4. Evolution: candidate states, immutable releases, a canary and a rollback.
  5. One repeated activity turned into a typed tool, proposed by dreaming, built by Claude Code, approved by you.
  6. The verified autonomy rate, and the cost per assignment, before and after.

By the end of this chapter, you can run a worker that learns on any model, and keep what it learns. You can show what the learning cost and what it saved, and refuse a lesson that would make it worse.

In this chapter

  • 36.1 Recall, and what changes on the open stack
  • 36.2 Memory that survives a change of model
  • 36.3 Dreaming as a Workflow
  • 36.4 Evaluation the author cannot game
  • 36.5 Evolution: from candidate to release
  • 36.6 From reasoning to code
  • 36.7 Learning on a budget, and who learns from whom
  • 36.8 Measuring improvement
  • 36.9 When Claude Code gets it wrong, and the limits
  • Lab 36 A worker that learns, on any model

What this chapter is built on

The chapter follows sections 7.8, 10, 11.2, 11.5, 12 and 13 of Panaversity's paper Building Affordable, Self-Improving AI Workers (29 November 2026). Learning costs come from the paper's cost model, model.ts. The numbers for validated improvements and autonomy are the paper's fictional illustrations; your own come from the lab. The memory, dreaming, evaluation, release and autonomy code in this chapter was tested on 30 November 2026. It ran on Wrangler's local runtime with recorded model answers, but not yet on a deployed account. Check each API against the installed documentation, as CLAUDE.md tells Claude Code to.

  • Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), sections 7.8, 10, 11.2, 11.5, 12 and 13
Owner
Panaversity