The bug you can’t reproduce

When an agent acts on a wrong memory and that memory has since been overwritten, you cannot prove why it acted. Here is a scenario most agent builders will recognise (illustrative, not a specific incident).

On Tuesday your agent drafts a follow-up email to Alice, addressed to her old employer, Acme. You open the memory store to find out why. The record reads alice worksAt globex. It is correct, it is current, and it is useless: it describes Thursday, and the bug lives on Tuesday.

The value Acme was overwritten on Wednesday, and with it went everything you needed: where the agent learned it, how sure it was, and what else it concluded from it. You are left reading logs and guessing.

Most agent memory is built like a cache: the latest write wins. That is fine for “the user prefers metric units”. It becomes a liability the moment the agent acts on what it remembers, and the moment you have to debug it. This post is about the alternative: memory you can audit, one you can ask what the agent knew at any moment, where each fact came from, and what the agent concluded from it.

What overwriting memory can’t tell you

An overwriting store fails the four questions every serious agent bug ends up asking.

  1. 1.

    What did the agent know at the time? Not what is true now, but what was in memory when it made the decision.

  2. 2.

    Where did that come from? A user message, a tool result, another agent, or the agent’s own inference.

  3. 3.

    How sure was it? And who or what decided it was safe to act on.

  4. 4.

    Was the later change a correction or an update? Did the world change, or was the agent simply wrong?

There is a second, quieter failure. Agents write their own conclusions back into memory. If the store does not record which entries are observations and which are inferences, an inference gets read back next week as a fact, and the agent builds on it. The error compounds, and nothing in the store shows that it began as a guess.

[embed: node/77ea97b4-cd74]

The top lane keeps only the latest value, so Thursday’s debugging starts with nothing about Tuesday. The bottom lane retracts the old entry without deleting it and can replay what memory held on Tuesday.

What an auditable memory keeps

An auditable memory keeps three layers of information about every fact, on two clocks, and it never deletes: it only retracts.

The layers separate things that overwriting stores blur together. The fact is a statement with its own id, such as e1: alice worksAt acme. Statements about that fact record where it came from and how sure the system was. The belief is what the agent concluded, and it points back at the fact it rests on.

The two clocks answer different questions. One records when the system learned something; the other records when it was true in the world. A change adds a new entry and marks the old one as retracted, so both stay readable.

[embed: node/4f859c1a-d0e7]

Read it bottom-up: the fact is what was recorded, the layer around it holds the evidence, and the belief records what the agent did with it. Each layer answers a different debugging question.

Whatever you build it on, these are the five properties to demand from a memory layer:

  • Identity. Every fact has an id, so other entries can point at it.

  • Append and retract. Nothing is overwritten or deleted by an agent write.

  • Two clocks. Recorded-at and true-at are stored separately.

  • Provenance and confidence as data. Source and writer (user, tool, agent) are statements about the fact, not log lines elsewhere.

  • Beliefs kept apart from facts. Each belief links to the facts that support it.

Together they give you the one query that makes debugging possible: memory as it stood at time T.

Debugging with a trace instead of a guess

With an auditable memory, a wrong answer becomes a trace from the decision back to a source, not a hunt through logs.

The method has three moves: pin the time of the decision, ask memory what it held then, and follow the belief to its facts and the facts to their sources. Where the trace ends tells you which kind of bug you have.

[embed: node/ad615d49-96e4]

Follow the trace down the left column; the four boxes on the right are where it can end. Each ending points to a different fix, and all of them finish with a retraction and a note.

Replay the Alice bug. Pin the decision to Tuesday and run the as-of query. It returns the belief “Alice is an Acme employee”, resting on fact e1, which carries a confidence of 0.8 and a source: a chat message. Now you have something to reason about.

The two clocks then separate two bugs that look identical from outside. Suppose Alice left Acme the week before Tuesday and the system only recorded the change on Wednesday. The agent was right about everything it knew; the failure is information lag, and the fix belongs in how quickly job changes reach memory. Suppose instead the correction was already recorded on Tuesday and the agent emailed Acme anyway. Then the right fact existed and was not used, which is a retrieval or reasoning bug, and the fix belongs in the agent. An overwriting store cannot tell these apart, and they need different fixes.

The fix itself is also auditable. You retract the bad entry at its source and annotate why, so the next replay shows the correction and the reason for it.

What it costs, and who needs it

Auditable memory costs storage, query complexity and a harder privacy conversation, and not every agent needs it.

  • Storage grows. Nothing is deleted by an agent write, so you need retention and compaction policies that you set, not the agent.

  • Queries get harder. As-of queries over two clocks are painful to bolt onto a plain key-value store, so choose a store that supports them natively.

  • Privacy gets harder. “Never forget” collides with the right to erasure. Retraction hides a fact from the agent; it does not remove personal data. You need a deliberate erase path that deletes the content but keeps the structural record that an entry existed and was retracted, plus a rule for who may trigger it. Design this first, not after the first request, and check the details with your counsel.

Who needs it? Agents that take consequential actions (money, access, customer communication, compliance) or that run long enough for their state to drift. A chat assistant that remembers your preferred tone does not. A useful test: if you might ever have to explain a decision to someone outside your team, you need an audit trail.

Your turn

If you build agents, I would like to hear about your worst memory bug: the one you could not reproduce because the evidence was gone. Reply to this post or write to me, and I will use the best ones in the next pieces.

I am building these ideas into Tiramemsu, an embedded graph database on SQLite where every fact has an id and every change is kept with when it was made and when it was true. A hands-on quickstart follows next week. If you want it in your inbox, subscribe.

Originally published on Sovereign Agentic AI on Substack.