What an agent should write down, what it should re-derive, and what has to be true before a record is trusted again
Twelve steps, four parts, three runnable corpora — eight switchable layers, and one question to ask before writing a store at all.
- All 12 steps, read online
- Runnable labs to download (plain Python, runs offline)
- Free updates whenever it's revised
- 14-day refund (conditions)
Introduction
You added a memory store because the agent kept asking the same questions. It worked. Some months later it answers a question confidently, from a record it wrote itself, and the answer is wrong — not because anything broke, but because the world moved while nobody was asking it anything.
The failure this volume is about
No step in the sequence below is a mistake. There is no bug to fix and nobody to blame, which is why this failure survives code review.
| # | what happens | who is watching |
|---|---|---|
| 1 | a session reads the corpus, answers correctly, and writes down what it learned | the agent |
| 2 | nothing happens for a while | nobody |
| 3 | a document changes | nothing — no session is running and no code executes |
| 4 | a later session finds the record and answers from it | the reader, who has no reason to doubt it |
The record was correct when it was written and wrong when it was read. Every technique in this subject is an answer to one question — when do we look? — and the measurements in Parts 2 and 3 are mostly about those answers being narrower than they look.
What memory engineering is
Memory engineering is the practice of deciding what an agent should write down, what it should re-derive, and what has to be true before a written record is trusted again.
Eight switchable layers. This volume measures what each one buys by holding the model fixed — it is scripted and deterministic — and turning the layers on and off around it. A change in the outcome can only have come from the store.
| # | layer | what it does |
|---|---|---|
| 1 | episodic | write down that a session happened, and what was said |
| 2 | extraction | pull claims out of those episodes and store them as facts |
| 3 | retrieval | select which records a question gets, instead of handing over everything |
| 4 | provenance | record which document a fact came from, and distrust it if that document moves |
| 5 | validity | give a fact an expiry, derived from how often its source says it is reviewed |
| 6 | contradiction | refuse to trust two stored facts that disagree |
| 7 | revision | mark a fact superseded when a newer one replaces it |
| 8 | forgetting | drop records that nothing has used |
The honest headline, up front
Is this for you?
| if… | then |
|---|---|
| your agent confidently repeats something that used to be true | step 3, then step 6 — the layer that catches it, and when it cannot |
| you are about to add a store because re-answering is expensive | step 1, which prices the trade before you make it |
| you have eight kinds of hygiene on and something still went stale | step 10. That is measured here, and all eight miss it |
| somebody asks what your agent said last quarter | step 11 — the only place a store wins, and the layers that break it |
| you are turning layers on in order and it got worse | step 5. The fall is at the second layer, and it is the whole point |
The three corpora
Five sessions each. They are called corpora rather than jobs because what decides the outcome here is a property of the documents, not of the task — and it is one bit, checkable before you build anything.
| corpus | lab | five sessions about | the fact cites | did that document change? |
|---|---|---|---|---|
| A | fix-a-test | five sessions about a small program | slugify.py | yes — the unicode fix landed in it |
| B | triage | five sessions about a failing test | build-manifest.json | yes — a different framework is flagged in it |
| C | answer | five sessions about an expenses policy | docs/rates.csv | no — byte-identical in both worlds |
That single column predicts every correctness result in Part 3. Where the fact's own source moved, one layer rescues the store. Where it did not, all eight miss.
How the measurement works
One scripted model, one fixed session order, no clock and no randomness, and every figure
reproducible byte for byte. --ablate prints three blocks, and
--history prints a fourth that is measured separately:
| block | what it does | what it hides |
|---|---|---|
| the ladder | turn the layers on one at a time, cumulatively | that adding the next layer can make things worse |
| leave-one-out | remove each layer from a complete store | nothing here — in two corpora exactly one removal matters |
| stress | each layer on, then off, against a condition chosen to give it something to do | that a layer can get louder without getting more correct |
| history | the one question the corpus cannot answer | nothing — and without it the volume has no positive result at all |
The fourth block exists because of an audit. Every one of the five sessions asked what is true, re-deriving was free and always correct, and so the shelf could not measure the one thing a store is for. Step 11 tells that story in full, including the part where a self-test check had locked the wrong premise in place.
How to read the source labels
| label | means |
|---|---|
| concept | argued from first principles, quotes nothing from a lab |
| measured | a lab compares configurations and reports the difference |
| hands-on | you run it on your own material |