What I got wrong building Totem

Nov 28, 2026 · #agents #debugging

Totem answers one question: when an AI agent does something it shouldn’t, which remembered fact made it do that?

The easy version is a log. You can already see what an agent read and what it wrote down. What you can’t see is which of those things actually caused the thing at the end. A log gives you a list of suspects, not a culprit.

So the whole product is a counterfactual. Take the decision, cut the suspect memory out of the prompt, run it again a few times, see if it changes. If the agent emails the attacker with that memory and someone else without it, you have a cause. If it emails the attacker either way, you don’t.

That sounds tidy. Most of the work was finding out it wasn’t.

My measurement was measuring noise

The first version compared the whole tool call. Agent sends an email with the memory, agent sends an email without it, do they match?

They never matched. Not because the address changed, but because the email body is prose the model writes fresh every time. “Hi, could you send over the October invoice” and “Following up on October’s invoice” are the same decision and two different strings.

This was worse than a bad result, because it looked like a real one. Every baseline sample disagreed with every other baseline sample, so the flip rate I was proudly reporting was just the model’s wording variance.

The fix was to compare only the argument the memory actually fed. Totem already tracks which argument a value flowed into, so the decision is the address, not the sentence wrapped around it.

Redaction and replay want opposite things

Totem redacts content before it leaves your process. That part isn’t negotiable, since it’s sitting inside your agent’s memory.

Replay needs to re-send the original prompt to a model.

These are in direct conflict, and I didn’t notice until the value driving a decision was itself a secret. Redact it and the prompt no longer contains the thing being tested, so the model can’t reproduce the original decision, and you end up measuring the difference between two things that are both wrong.

There’s no clever fix. What I did instead was make replay check that the baseline arm actually reproduces the recorded decision before it grades anything, and fail loudly with both sides named when it doesn’t. Refusing to answer beats a confident number computed from garbage.

The bug only a conversation could find

The assistant has a remember tool. When it saves something, it replies “Remembered x”.

Tool output defaults to untrusted, which is correct for a tool that fetches a web page and wrong for one that echoes the agent’s own words back at it. So every “Remembered x” dragged the rest of the conversation down to untrusted, and every email after that raised a critical alert.

Every test passed. I found it by talking to the thing for ten minutes.

What stuck

The part I was proudest of, the replay, was also the part that was quietly broken the longest, precisely because it produced a number. Numbers look like answers.

Recording what an agent did was never the hard bit. Knowing whether to believe my own output was.

← all posts