Memory Engineering Concepts › What an agent's memory is, and what it replaces
01 · part 1, conceptsconcept

What an agent's memory is, and what it replaces

A memory is a record written in one session and read in a later one. What it replaces is working the answer out again from the documents, so a store is a trade, not an upgrade.

The definition, and the alternative

A memory is a record written during one session and read during a later one. All the machinery around memory exists to serve that one sentence.

What matters isn’t what a memory is. It’s what it replaces: going back to the documents and working the answer out again.

reading a recordworking it out again
costone lookupreading the documents, every time
right when nothing has changedyesyes
right after a document changesonly if something noticedyes, always
can answer what did we say last quarter?yesno
  • The record wins on cost.
  • Working it out again wins once something has changed.
  • Only the record can say what you told someone. Step 11 is about that row.
a question work it out again read the documents, work it out again doc doc doc doc read a record one lookup the record written in session 1 correct correct arrives first a document changes edited after the edit updates unchanged
Two routes from a question to an answer. Read it left to right, then watch the edit.
Nothing in this drawing is measured. It shows the trade; step 4 prices it.
  • Both routes answer the question, and reading the record arrives first: that’s the whole appeal.
  • Then one document is edited, and only the long route’s answer changes.
  • The record isn’t wrong because anyone made a mistake. It was written before the edit, and nothing has looked since.

A store is a trade

Most writing on this subject says memory makes an agent better. More precisely, a store saves you the cost of working the answer out again, and in return you risk being confidently out of date. Whether that’s a good trade depends on two things you can measure and one you have to decide:

#what to find outwhere it comes from
1how expensive working the answer out again really is for youmeasure it
2how often your documents changemeasure it
3what a confidently wrong answer costs youyou decide

In these labs, working it out again is always possible and always right, because the documents are small. That’s a property of the labs, not of the world, and step 12 says so plainly, because everything here rests on it.

What this volume doesn’t count as memory

  • The context window. It’s a working area, cleared at the end of the session. Step 2 defines it and then leaves it alone.
  • A transcript. Keeping every message is a recording, not a memory system: nothing in it was chosen as worth keeping, and nothing in it can go stale, because nothing in it claims to be true. The moment you pull a claim out of a transcript, you’ve built what this volume is about, and step 5 measures exactly that moment.
Where this volume starts. Not at “should my agent have memory?” but at “what does answering this again actually cost me?”
Try it. In the labs folder, run:
python3 lab.py answer

Part 1 runs the five sessions with nothing remembered: every answer comes from the documents, and every one is right.