Essays / memory / operations
An Agent Forgets. Cron Doesn't.
Memory in a long-running agent is not a feature you install. It is a schedule you keep, and a file you are willing to maintain.
The project that taught me this ran for six weeks: a consumer app, two people, a hard launch date. The agent was involved every day. By week three it had started contradicting decisions we made in week one, and I could not tell whether it was forgetfulness or disagreement, because the context was gone and the reasoning with it.
I tried the obvious fixes. All four failed, for different reasons.
What did not work
A vector store of past decisions. The retrieval was fine. The problem was that retrieval returns similar text, not binding text. Asked to add a settings page, the agent retrieved a paragraph about a settings page we had rejected in week one and used it as precedent for building the wrong thing.
A giant system prompt with every decision appended. It worked for eleven days. Then it was 9,000 tokens of history, half of it obsolete, and the model started treating stale decisions as current.
Asking the agent to summarize the project at the end of each day. Summaries drift. Each one compresses the last summary, and after five rounds the project has a clean narrative with none of the awkward constraints in it.
Relying on the chat history in one very long session. Expensive, slow, and it dies the first time you need to restart.
What actually worked: a state file and a clock
Two artifacts, both boring.
One file, STATE.md, under 60 lines. Not a summary of the conversation. A decision sheet in present tense:
- What is being built, one paragraph.
- Decisions that are binding, with the date and the reason.
- Decisions that were reversed, with what replaced them.
- What is in flight right now.
- What is explicitly out of scope.
A scheduled job that reads it every morning. At 08:00 the agent opens the repository, reads STATE.md, reads the last two commits, and writes a five-line brief: what changed, what is next, what looks inconsistent. That brief is the first message of the day.
The cost of the state file is about 900 tokens. The alternative, re-reading six weeks of context, is roughly 40,000 and does not fit.
Why the schedule matters more than the file
A file nobody reads is a diary. The schedule is what makes it a working document, because the agent has to reconcile the file with reality every morning, and reconciliation is where inconsistencies surface.
Twice it caught something I had missed: a migration written against a schema the file still described the old way, and a feature in flight whose decision had been reversed on a Friday and never reflected anywhere.
Write the file by hand for the first week. If the agent writes it from the start, it will write the story it can defend, not the decisions you made. After the format is stable, let it draft; you approve or correct. The approval step is the whole point.
Three rules that kept it honest
- Binding decisions include the reason. "Use Postgres, because we need row-level security for the pilot." Without the reason, a later session will happily propose SQLite to save an hour.
- Reversals are recorded, not deleted. A deleted decision is rediscovered and rebuilt. A reversal with a date and a reason closes the topic.
- Out of scope is a list, not a vibe. Five bullets, updated weekly. Most agent drift I have seen is the agent doing something reasonable that we had already decided not to do.
What it costs to maintain
Twelve minutes a week, on Friday, plus thirty seconds each morning to read the five-line brief and correct it. Compared with the alternative, which is not "no maintenance" but "rediscovering the same decision three times and shipping the wrong version once", it is the cheapest thing in the project.
The launch went out on the date. Not because the agent remembered everything. Because we stopped pretending it would, and gave it something to read every morning.
What to steal
- A 60-line
STATE.md: build, binding decisions with reasons, reversals, in flight, out of scope. - A cron at a fixed hour that reads it and writes a five-line brief.
- A Friday edit pass, by hand, twelve minutes.
- One rule above all: if it is not in the file, it is not a decision.