Years ago I helped run a data wall: records spread across a ring of nodes, placed by consistent hashing so any key landed on a predictable machine. The failure that taught me the most was not a node dying. It was a node coming back and not knowing who it was. Bring it up without its keys and its state, and it was a stranger wearing the right hostname; the ring healed only when a node could be rebuilt as itself, key and data intact, ready to answer for the range it owned. I have been thinking about that failure again, because an AI agent has exactly the same problem. Whatever it appears to remember between runs, it remembers only because something kept the state and reloaded it correctly.
Agent memory is really state management with a persistence tier: the same session-store, cache, and key-continuity discipline you already run, now asking not how do I retrieve this, but what earns the right to survive the run, and who decides.
- Why the context window is not memory, and the exact seam where the previous dive handed this one the baton.
- Memory is not one thing: the layers that outlive a run, each a different store with a different bill, and only one of them ever a vector database.
- Retrieval was never the hard part. The write path is: deciding what earns durability, and who is allowed to sign it.
Stage 04's own overview names memory as layers in a single line, and warns in the same breath that it is not just a vector DB. This dive is that line, expanded. It is deliberately not about the loop: the previous dive owns that, and said the true thing about in-run memory already: the transcript is the memory. So start there, at the fence.
The Part the Window Forgets
Within a single run, an agent's memory is nothing exotic: it is the transcript accumulating in the context window, turn by turn. The payload contract governs all of it, and its closing move was to draw a boundary and hand across it: everything in that dive was the discipline of one call, one session; what an agent remembers across sessions is a different discipline with different failure modes, and it said, in as many words, that it belonged to a dive of its own. This is that dive. It begins exactly where the window ends.
Because the moment a run finishes, the window evaporates. The process exits, the transcript is garbage-collected, and unless something deliberately wrote state to a store that outlives the process, the agent wakes up next time as that stranger wearing the right hostname. Everything this dive owns lives on the far side of that fence: the state that must survive the run and reload correctly. In-run is the loop's ground. Cross-run is here.
Memory Is Not One Thing
The word "memory" hides a stack of different problems, and most confusion clears the instant you split them. There are three durable layers above the fence, and the reason they get lumped together is that engineers reach for one storage reflex, usually a vector database, and try to make it carry all three. It cannot, and it should not.
You Have Managed This State Before
Line the layers up against systems you have run and the correspondence is not a metaphor. It is the same engineering, renamed. Working state is a request-scoped cache: hot, fast, thrown away when the task ends. The episodic summary is a session store or an event log: what happened, compressed enough to reload cheaply. Long-term preference is the record of record: durable, authoritative, the thing that must survive every restart intact, exactly like the keys that had to travel with a node so it could be rebuilt as itself.
That last row is the whole thesis in one line. The encryption on that data wall was the easy promise; the retrieval was easy too. Keeping the key and the data together through every failure, so the node came back as itself, was the hard one. Agent memory is the same bargain, and the same discipline pays it.
Retrieving Memory Is Not Retrieving Knowledge
Here is where the vector-database reflex misfires. RAG retrieves knowledge: a large, mostly static corpus, keyed by meaning, where "find me passages semantically near this question" is exactly the right query and an approximate index is exactly the right machine. Memory retrieval is a different animal. It fetches my state: small, personal, mutable, and keyed by identity and recency, not by meaning. "What did this user tell me their name was" is a key-value GET, not a nearest-neighbour search, and running it through an embedding model is slower, costlier, and less correct than a lookup.
So a vector database earns its place at exactly one layer, long-term semantic memory, and even there only when the recall is genuinely fuzzy. For working state and episodic summaries, the boring stores win, the same way the index dive warned that below a certain scale you should not build an index at all. A vector database is where you keep what the world knows. Most of what an agent needs to remember about you fits in a key and a value.
The Write Path Is the Whole Game
Every discipline above is about reading. The genuinely hard, genuinely under-taught part of agent memory is the write: not how you get state back, but what earns the right to be kept, and who is allowed to sign it. The same trust-boundary question that governs which actions a model may take governs which writes earn durability, and it has the same three answers.
A write can be model-authored (the agent decides something is worth remembering), system-authored (your code commits a fact it can vouch for), or human-confirmed (a person said yes, keep this). The failure mode is specific and nasty: a model that writes its own hallucinations into durable memory has not learned anything, it has corrupted a record that will outlive the session that lied, and every future run will read the corruption as ground truth. Durable memory the model can write to without a gate is not a feature. It is a persistence bug waiting to compound.
When Memory Goes Stale
The other half of the write problem is that everything you keep can go wrong with age. A preference that was true last quarter, a summary that dropped the one fact that mattered, a remembered value that now contradicts the source of record: memory does not just fill up, it drifts. The defenses are the ones you already run against exactly this on every cache you have ever operated. Give durable facts a time-to-live or an explicit invalidation. Let the source of record win over remembered state whenever they disagree. And accept the honest accounting: durable memory you never expire is not an asset, it is a liability accruing interest, and one day it comes due as an agent confidently acting on something that stopped being true a year ago.
Keep the Key With the Data
The node that could rebuild itself was not the one with the cleverest storage. It was the one whose keys and data stayed together through every failure, so that when it came back it was genuinely itself and could answer for its range. An agent's memory is the same promise, made to a user instead of a hash ring: across every restart, the right state survives, reloads, and makes the agent continuous rather than a stranger with your history typed into its prompt. The retrieval was never the hard part. Keeping the right state alive to be reloaded, and letting only trustworthy hands write it, is, and it is the same discipline I have been keeping since the data wall.
Memory is what the loop keeps. The next dive is what the loop does. The Moves the Loop Can Make catalogues the patterns an agent runs on top of its state: reflection, planning, routing, delegation. Or step back onto the Route at Stage 04, where the flag is planted.