Coding adventuresAgentMem · October 2026
Three AI agents. One project. Zero memory.

Goldfish no more

My coding agents forgot everything the moment a session ended. Teaching them to remember turned out to be easy. Teaching them what to forget took the rest of the month.

The problem in one picture. Every session starts from zero. A decision made with one agent is invisible to the next, so I kept re-explaining my own project to it.

I work with three AI coding agents at once. Claude leads and plans, Codex reviews and takes the hard bugs, and OpenCode does the cheap, mechanical work. It's a great team, apart from one thing. None of them remember anything. Close the terminal, and the decision we spent twenty minutes on is gone. Open a new session tomorrow, and I'm explaining the database choice all over again, to an agent that confidently picks the other one.

So I built AgentMem, a shared memory for all three. The plan sounded simple. Save every session, summarize it, and keep one note per project saying where things stand. When a new session starts, hand it that note before anyone types a word.

The first version worked. At least it looked like it did.

01The memory that leaked

Saving sessions was the easy part. Hooks in each agent fire when a turn ends, and a background worker picks up the transcript, strips out secrets, and asks a small model for a summary. The summaries landed in my Obsidian vault, and the project notes got rewritten from them. It was searchable and tidy, and all the tests were green.

Then I asked a different question. Never mind whether each part works. If I start a brand-new session, does it actually know where the project stands? I scripted real agents through a week in the life of a project: decide something, quit, come back, change my mind, get killed mid-task. Then I read what the next session was handed.

213 sessions saved92 never reached the project note
made it into the noteparked and forgotten
INVENTED
"The temp folder is part of the project."
The summarizer filed its own scratch folder as a project fact, and the next session repeated it.
LOST
git commit -m "switch back to SQLite"
Work done through shell commands looked trivial, so the reversal was never saved. The old decision came back.
Where the memory went. Each dot is one saved session. The red rings are sessions whose updates were too long, got parked, and were never picked up again. On top of that, invented facts got in, and decisions made outside the editing tools got lost.

The worst one was the quietest. One week I decided against something, and a later session cheerfully brought back the old decision, because the reversal had happened in a session the system decided wasn't worth saving. Memory that is confidently wrong is worse than no memory at all.

02The wiki detour

My first instinct was to go bigger. Andrej Karpathy had sketched a pattern he calls the LLM Wiki. Instead of searching raw documents every time you ask something, you let the model build and maintain a living wiki. It ingests new sources, links them together, and periodically lints itself for contradictions. Knowledge gets compiled once and kept current, so it compounds.

I built a version of it: a claim store where every fact points at its evidence and every decision knows what it replaced. Then I benchmarked it against plain search, and on a set of made-up test questions it crushed it.

On questions pulled from my real repositories, though, the improved plain search was level with it or ahead. Worse, the store sometimes served an outdated decision as current, which is the exact bug I was trying to kill. And the benchmark itself was asking the wrong question. It tested whether memory can answer things. What I actually needed was memory that tells a new session where we are, before anyone asks.

I'd built a brilliant librarian. I needed a good briefing.

So I kept the idea and dropped the second system. The rest of this story is the briefing.

03One page per project

Every project now has a single status page. It has seven fixed sections: purpose, what works, latest progress, active work, open questions, key decisions, and next steps. That page is the only place that says what is true now. Everything else, every old session and every retired decision, is history. You can still search history. It just never gets to pretend it's current.

Before · the note that only grew
Current state: storage uses SQLite (local only)
Current state: switched to Postgres for multi-user
Decided: dates stored as 20261016
Decided: ISO dates only
Working on: overdue filter
Working on: overdue filter (done?)
Next: run the tests
Next: wait for review from the reviewer
Note: the temp folder is part of the project
Pending: 140 more lines from old sessions…
Pending: …
Pending: …
Pending: …
After · the status page

Active work

- Overdue filter: list --overdue not wired yet (oct-24 #e4)

Next steps

- Wire list --overdue and test it (oct-24 #e6)

Key decisions

- Postgres, because multi-user needs concurrent writers (oct-23 #e2)
- ISO dates only; week dates were ambiguous (oct-24 #e2)

What works

- Due dates and priorities, sorted listing (oct-22 #e5)
Same project, two memories. The old note kept everything, contradictions included. The status page keeps only what is true now. Every line links to the exact quote in the session that established it. The example is a made-up todo app.

Those little #e4 tags matter. When a session ends, its note gets numbered evidence entries, and each one is a quote from the actual transcript. A claim can only reach the status page if it points at one of those quotes, and if the quote really contains what the claim says. The summarizer's invented facts died right there. You can't cite a quote that doesn't exist.

04Change your mind. Watch it happen.

Here is the move that broke the old system: deciding one thing on Monday and the opposite on Wednesday. Click through the week.

Pick a day:
Status page · key decisions
History
Decisions get replaced. They never disappear. When a newer session decides differently, the old decision moves to history with the reason and a link to the evidence that replaced it. The next session sees only the current call, and can still find out why it changed.

05The model proposes. Code decides.

A small model reads each finished session and proposes an update to the page: what to keep, what to add, what to retire. It's good at that. What it is not good at is following rules every single time. The rules I left to the prompt alone kept getting broken in live runs. So the model only proposes, and a plain piece of code checks every proposal before anything touches the page.

REJECTED
+ "The temp folder is a project file."
No quote in the session says this. No evidence, no entry.
REJECTED
- retire decision "Use Postgres"
  because: next step "run tests"
Only a newer decision can retire a decision. A to-do can't overrule one.
REJECTED
+ "Waiting for the reviewer's verdict."
That's what an agent is doing, not a fact about the project. Chatter stays off the page.
REJECTED
- retire "ISO dates only" (Oct 24)
  using evidence from Oct 22
Older evidence can never overwrite newer evidence, even if its session finished later.
ADDED
+ "Postgres, because multi-user needs concurrent writers" (#e2)
Cited, matches its quote, newer than what it replaces. The old decision moves to history.
ADDED BY CODE
+ decision the model forgot to include
If a session made a cited decision and the model left it out, code puts it in anyway.
The bouncer at the door. Every rejection is logged with its reason, and nothing is dropped silently. Git facts like the current branch are never stored at all. They are read live when a session starts, so they can't go stale.

06Back to the wiki, sort of

Funny thing. Once the status page settled, I looked back at Karpathy's sketch and realised I'd ended up building a version of it after all. It's just smaller, and it has a stricter editor.

LLM Wiki
AgentMem
Raw sourcesImmutable documents the model reads but never edits
→
Session notesOne per session, written once, quoted as evidence
The wikiPages the model maintains and keeps current
→
Status pagesOne per project, rewritten by the model, compiled once and kept current
SchemaA file like AGENTS.md describing how to maintain it
→
Vault rulesThe vault's own AGENTS.md
LintThe model checks for contradictions now and then
→
The bouncerCode checks every single update, before it lands
QueryAnswer questions from the wiki
→
SearchLabelled current or historical, so an old answer never poses as a new one
Same shape, one change. The wiki's ideas survived. What changed is the lint step, which moved from an occasional model pass to a gate on every write. The separate claim store is still in the code, switched off.

07The bug that hid in plain sight

The nastiest bug of the project only showed up once real agents were driving. Hundreds of tests had sailed past it. AgentMem skips trivial sessions, which is good, because nobody needs a note for "what time is it?". But it judged each turn on its own. Picture a session where you talk through a decision first and write the code afterwards:

Turn 1
"Where should the notes live? Let's keep them in docs/."
Trivial · skipped
Turn 2
"OK, write the file."
Trivial · skipped
Both turns together
A decision, a reason and a new file
Worth keeping
Death by small steps. Each turn looked too small on its own, so a real session full of decisions was never saved. Now, a skipped stretch waits and gets judged again together with whatever comes next.

That bug had probably been eating discussion-heavy sessions all along, and those are exactly the ones where decisions get made. No unit test caught it, because each test checked one turn. The only thing that caught it was running two real sessions end to end and noticing that the second one didn't know what the first had decided.

08What a session sees now

Open a new session in any of my projects, in any of the three agents, and before I type anything it already has the briefing:

new session · todo-cli · injected at start
Git (live): branch main, 4f2c9e1, clean
Capture health: all sessions saved
### Active work
- Overdue filter: list --overdue not wired yet (oct-24 #e4)
### Next steps
- Wire list --overdue and test it (oct-24 #e6)
### Key decisions
- Postgres, because multi-user needs concurrent writers (oct-23 #e2)
2 more items in todo-cli.md
The goldfish, briefed. It's short enough to read in ten seconds. Every line can be traced to the moment it was decided, and anything older is one search away, clearly marked as history.

Ask it "what are we doing and what's next?" and it answers from the briefing, correctly, without opening a file. That was the whole point.

09What I'd tell myself a month ago

Test the job, not the partsEvery component can pass while the product fails. The only test that mattered was a new session reading its briefing.
Let the model propose, let code decideModels are great editors and unreliable rule-followers. Every rule that mattered ended up in code.
Make every claim show its receiptForcing each fact to quote its source killed invented facts. The summaries didn't get worse for it.
One place for "now"Two systems that both describe the present will eventually disagree. Keep history huge and searchable, and keep "now" in one spot.