"It failed" is not a diagnosis
When an AI agent misbehaves in production, the first report is always the same: it failed. It approved the wrong invoice, it emailed the wrong customer, it looped forever. The report names a symptom. The expensive part is that most systems cannot tell you why, because the exact conditions — the model version, the prompt, the tool responses, the intermediate state — are gone the moment the run ends. You are left re-running the agent and hoping it misbehaves the same way, which it usually will not.
Determinism through event sourcing
Deterministic replay borrows a well-understood idea from event sourcing: instead of storing only the final state, you store the ordered sequence of events that produced it. For an AI agent that means capturing every input, every model call and its response, every tool invocation and its result, and every decision, as immutable events. Given the same event log, you can replay the run and arrive at exactly the same place — not a similar place, the same place.
Why non-determinism is a recording problem, not a model problem
People assume you cannot replay an LLM agent because the model is stochastic. But the stochasticity lives in a bounded set of places: the sampling in the model call, the responses from external tools, timestamps, random seeds. If you record those outputs at the moment they happen and replay from the recording rather than re-calling the live services, the run becomes deterministic. You are not asking the model to be repeatable; you are replaying the recording of what it already did.
From "here's roughly what happened" to "here's exactly why"
With a complete event log, debugging changes character. Instead of guessing, you load the failed run and step through it: here is the input, here is the model's response, here is where the tool returned an unexpected value, here is the branch the agent took because of it. The root cause stops being a hypothesis and becomes a line you can point at. That is also what turns an incident into evidence you can show a regulator or a customer.
The engineering cost is mostly discipline
The hard part is not clever infrastructure; it is discipline. Every source of non-determinism must go through a boundary that records its output, and state must never be mutated in place — it is derived by folding the event log. Teams that adopt this early get replay almost for free. Teams that bolt it on after an incident spend months instrumenting a system that was never designed to remember itself.
