Lesson 1 of 6 · 3 min read
Memory, Context and Retrieval
In this lesson
TL;DR: The model remembers nothing between requests; everything it "knows" about the past is something the harness chose to put in the context. Three sources feed that context: run state and notes for the task in hand, retrieval from a corpus other people curate, and memory the agent system wrote itself and reads back later. They differ in who writes them, how long they live, who may read them and how they fail, so a fact has to be placed deliberately in one of them.
After this lesson, you should be able to say where a given fact belongs (context, run state, memory or a retrieval corpus), explain why the model itself has no memory, and name the failure that each place is prone to.
Before you read
Commit to an answer now. The lesson that follows explains it, and having guessed first, even wrongly, makes the explanation easier to remember.
1A user tells a support agent 'I'm vegetarian' while booking a work dinner. Six weeks later, the same agent suggests a steakhouse. Which of the three (context, retrieval, memory) failed, and what does fixing it involve?
The model remembers nothing
A model call is a function: the request goes in, a response comes out, and nothing about the request remains inside the model. "The agent remembered my name" always means some code put your name into a later request. That makes memory a design problem for the harness, not a property of the model: something must decide what to write, where, and what to put back into which request.
Four places a fact can live
Context window
this request
- Written by the harness each turn
- Gone when the request ends
- Read by the model only
Fails by: noise and length (context rot)
Run state and notes
this task
- Goal, constraints, progress, case facts
- Lives for the run, survives compaction
- Scoped to one run
Fails by: drift if the model can rewrite it
Memory
this user or agent, across runs
- Written by the agent system itself
- Lives for weeks or months
- Scoped to a user, team or agent
Fails by: wrong, stale or leaked records
Retrieval corpus
the organisation
- Curated by people and other systems
- Lives as long as the source
- Shared by many users
Fails by: missing or outdated sources
The distinction that matters most is who writes. A retrieval corpus is written by people and other systems: the handbook, the ticket history, the codebase. Memory is written by the agent system from what happened in its own runs: a preference the user stated, a fix that worked, a summary of last month's project. That difference decides how much to trust each, and how they go wrong.
Placing facts
| Fact | Where | Why |
|---|---|---|
| "Ship only to EU addresses" (stated this session) | Run state | Must hold for this task, enforced by the harness |
| "Prefers SMS to email" (stated six weeks ago) | Memory, scoped to the user | Written by the system from a conversation, read in later runs |
| The refund policy | Retrieval corpus | Owned by the policy team, shared, changes on their schedule |
| The order the agent fetched three turns ago | Context (and notes if still needed) | Current only for this task |
| "Running the migration with --dry-run first avoids lock errors" | Memory, scoped to the agent | A lesson from earlier runs, useful to every later run of this agent |
A useful test: if two users asked the same question, should they get the same fact? If yes, it belongs in a corpus someone curates. If it depends on who is asking, and the agent system learned it rather than being told it by the organisation, it is memory.
Why the distinction prevents bugs
- Memory used as a corpus. If everything the agent concludes goes into one shared store, one user's mistaken belief becomes every user's answer. Memory needs scope.
- A corpus used as memory. If the agent writes its conclusions into the documentation index, nobody curated them and they are indistinguishable from policy.
- Context used as memory. Keeping a user's whole history in the window "so it remembers" is expensive, degrades quality and still ends when the history no longer fits.
- Memory used as run state. A constraint for this task written into long-term memory will be applied to the next task, where it does not hold.
Say it in 30 seconds
"The model has no memory; the harness decides what each request contains. It draws on run state and notes for the current task, a retrieval corpus that people curate and many users share, and memory that the agent system writes from its own runs and reads back later, scoped to a user, team or agent. They differ in writer, lifetime, audience and failure: context rots, run state drifts if the model can rewrite it, memory goes wrong, stale or leaks across scopes, and a corpus goes out of date. Every fact gets placed in one of them on purpose."
Check yourself
Answer aloud or on paper before revealing. Producing the explanation unaided is exactly what a panel listens for.
1Why is 'who writes it' the most important difference between memory and a retrieval corpus?
2A coding agent learns that one repository's tests need a database container running first. Where should that fact go?
3Why is keeping a user's whole history in the context window a poor substitute for memory?