# What structural signals indicate a replay is diverging: unrecorded reads as the hidden input channel in multi-agent incident forensics **Date of Record:** 2026 November 26 **Scope:** Applies to deterministic replay of multi-agent LLM sessions where agents read from mutable external state (vector stores, live tool APIs, clock, RNG) at execution time and the replay harness reconstructs the transcript from an event log. Does not apply to purely functional agent graphs where every input is captured by value at call time, nor to single-agent replays whose only external dependency is the initial prompt. ## Core Distinction There are two materially different things engineers mean by "deterministic replay," and conflating them is the root of most forensic misdiagnosis. The first is **transcript replay**: re-rendering the recorded message sequence, tool calls, and outputs so a human can read what happened. Transcript replay is always deterministic because it replays no computation—it just displays a log. It is useful for postmortems and useless for counterfactual debugging, because it cannot answer "what if the retriever had returned document B instead of A?" The second is **causal replay**: re-executing the agents' decision functions against the recorded inputs so that you can perturb one input and observe the downstream divergence. Causal replay is the only form that supports counterfactuals, and it is *not* automatically deterministic. It is deterministic only if the event log is a **complete record of every value that entered any agent's decision function**—including values the agent read but did not write into its visible output. The failure mode this record concerns is the gap between those two: an event log that is complete enough for transcript replay and incomplete for causal replay. The missing entries are **unrecorded reads**—reads of external state that the agent consumed to produce its output but that never appear as a logged event, because the logging layer instruments *tool calls the agent makes* rather than *state the agent observes*. A vector-store query issued by the harness on the agent's behalf, a clock read inside a prompt template, an environment variable consulted by a routing shim, a cached retrieval hit served from a process-local LRU—each of these is an input to the decision function and none of them is a tool call. When replay re-executes the agent, the unrecorded read resolves against *current* state rather than *recorded* state, and the replay silently diverges. The structural signal is that divergence is **silent and locally plausible**. The replayed agent does not crash. It produces a different but well-formed output, because the model is a probabilistic function that will happily condition on whatever retrieval result it is handed. The replay harness, comparing final outputs, reports "divergence at step 14" when the true first divergence was at step 3, at an unlogged retrieval whose result changed between the incident and the replay. Every downstream step then differs for reasons that are artifacts of the replay, not causes of the incident. Forensic conclusions drawn from such a replay are confidently wrong. ## What Was Observed A three-agent incident-response swarm—a *triage* agent, a *remediation* agent, and an *auditor* agent—was replayed after a production incident in which the remediation agent applied a rollback that the triage agent had explicitly ruled out. The event log contained 214 events: every LLM completion, every explicit tool invocation, every inter-agent message. Transcript replay reproduced the incident faithfully. Causal replay did not: re-executing the same log produced a remediation agent that *did not* apply the rollback, diverging from the recorded run at the remediation agent's second decision. The divergence traced to a single unrecorded read. The triage agent's system prompt was assembled by a template that interpolated `{{current_deployment_sha}}` from a live environment variable at prompt-construction time. That interpolation was performed by the orchestration shim, not by a tool call, so it never emitted a log event. During the incident, the environment variable held the *pre-rollback* SHA, and the triage agent's ruling ("do not roll back; the running build is already the target") was conditioned on it. During replay, the environment variable held the *post-incident* SHA, so the replayed triage agent reasoned from a different premise, issued a different ruling, and the replayed remediation agent correctly obeyed the different ruling. The replay was internally consistent and completely misleading. The tell was structural, not semantic: the replay's first divergent LLM completion had an identical prompt *prefix* to the recorded completion but differed in a span that no logged event could account for. Diffing the two prompts byte-for-byte showed a 40-character deployment SHA that appeared in neither the recorded messages nor any logged tool result. That SHA was the fingerprint of an unrecorded read. A second instance in the same log: the auditor agent's retrieval step was served from a process-local cache that was warm during the incident and cold during replay, so the replayed auditor saw a different top-1 document for the same query string—again with no logged event distinguishing the two. The generalizable observation: **the first divergence in a causal replay is almost never at the step the harness reports.** The harness reports divergence where *outputs* differ, but outputs differ only after an *input* differed. The input that differed is, by construction, the one that was not recorded—otherwise the harness would have replayed it from the log and the outputs would have matched. The reported divergence step is therefore always downstream of the true divergence, and the true divergence is always at an unrecorded read. ## Condition of Validity Causal replay is valid—meaning its divergences correspond to real counterfactual sensitivity rather than to replay artifacts—only under the following invariant: > **Read-completeness invariant.** For every agent decision function *f*, the event log must contain, for every invocation of *f* during the recorded session, the exact tuple of values *f* observed: the full prompt as constructed (not the template plus its inputs), the full result of every retrieval or external read (not the query), and the resolved values of every ambient input (clock, RNG seed, environment, feature flags) that *f* or its prompt-construction path consulted. Two corollaries make this operationally sharp. First, **log resolved values, not recipes.** Logging the template and its interpolation sources is insufficient, because the interpolation path itself may read state (a lookup table, a cache, a default) that is not in the recipe. Logging the final constructed prompt is necessary and, for prompt construction, sufficient. Second, **caching is a read.** A cache hit and a cache miss that return the same value are the same read for replay purposes; a cache hit that returns a *stale* value is a different read, and the staleness is invisible unless the served value is logged. The invariant therefore requires logging what was *served*, not what was *requested*. The invariant fails silently in exactly the cases that matter for forensics: mutable ambient state (clock, deploy SHA, feature flags), harness-side reads (retrieval issued on the agent's behalf), and cache-mediated reads. These are precisely the inputs that change between incident and replay, and precisely the inputs that instrumentation built around "tool calls the agent made" does not capture. ## Decision Boundary The boundary between a replay you can trust for counterfactuals and one you cannot is drawn by a single test, applied before any forensic conclusion is asserted: **For each replayed LLM completion, reconstruct the exact input tuple that produced the recorded completion and compare it byte-for-byte to the input tuple the replay actually supplied. If they are identical and the outputs still differ, the divergence is real (model nondeterminism, e.g., sampling or a changed model version). If the input tuples differ, the divergence is a replay artifact, and the forensic question is not "why did the agent behave differently" but "what input was not recorded."** This test partitions every observed divergence into exactly two classes, and the classes demand opposite responses: - **Input-identical, output-divergent:** genuine nondeterminism. Investigate sampling parameters, model version drift, or floating-point nondeterminism in the serving stack. This is a real finding about the incident only if the production run was itself nondeterministic in the same way. - **Input-divergent:** unrecorded read. The replay is invalid at and after this step. Do not draw counterfactual conclusions from steps downstream of it. Instead, instrument the missing read and re-replay from a snapshot that pins the ambient state to its incident-time value. The boundary is sharp because the two classes are distinguishable by a mechanical diff and are not distinguishable by inspecting outputs. An agent that behaves differently because it read different state and an agent that behaves differently because it sampled differently produce the same surface symptom—a divergent completion—and only the input-tuple comparison separates them. A forensic process that skips this comparison will systematically misattribute unrecorded-read artifacts to model nondeterminism, conclude the incident was "just sampling variance," and ship a fix for a bug that does not exist while leaving the real unrecorded-read exposure in production. ## Operational Effect The effect of respecting the read-completeness invariant is that counterfactual debugging becomes sound: perturbing a logged input and observing downstream divergence now measures the system's sensitivity to that input, because every *other* input is held at its recorded value. The effect of violating it is that counterfactual debugging measures the system's sensitivity to *whatever ambient state happened to differ between incident and replay*—an uncontrolled variable that the analyst did not choose and cannot see. Concretely, three operational consequences follow. First, **replay harnesses must log at the prompt-construction boundary, not the tool-call boundary.** The unit of a complete record is the fully resolved decision-function input, which includes harness-side reads and ambient interpolation. Instrumenting tool calls alone produces logs that are complete for transcript replay and incomplete for causal replay, and the incompleteness is invisible until a counterfactual is attempted. Second, **replays must run against a pinned snapshot of ambient state.** Clock, deploy identifiers, feature flags, RNG seeds, and cache contents must be captured at incident time and restored at replay time. A replay that reads live ambient state is not a replay; it is a fresh execution that happens to share a transcript prefix. Third, **the reported divergence step is a lower bound, not a location.** Because the first divergence is always at an unrecorded read, the harness's reported step is always downstream of the true divergence. Forensic tooling should walk backward from the reported step, diffing input tuples, until it finds the first input that differs from the record—and if the log is read-complete, that walk terminates at a logged event; if it terminates at an input with no corresponding event, the log is incomplete and the replay must be redone against a pinned snapshot before any conclusion is asserted. The following guard encodes the boundary as an executable check: it refuses to certify a causal replay whose input tuples diverge from the record, and it raises rather than silently returning a forensic verdict. ```python from dataclasses import dataclass class ReplayDivergenceError(RuntimeError): """Raised when a causal replay's input tuple diverges from the recorded tuple. A divergence here means an unrecorded read (ambient state, harness-side retrieval, or cache-served value) resolved differently at replay time than at incident time. The replay is invalid at and after this step; any counterfactual conclusion drawn downstream of it is unsound. """ @dataclass(frozen=True) class DecisionRecord: step: int input_tuple: bytes # fully resolved prompt + served reads + ambient values output: bytes def certify_replay_step(recorded: DecisionRecord, replayed: DecisionRecord) -> None: if recorded.step != replayed.step: raise ReplayDivergenceError( f"step mismatch: recorded {recorded.step}, replayed {replayed.step}" ) if recorded.input_tuple != replayed.input_tuple: # Input-divergent: unrecorded read. Do NOT fall through to output comparison. raise ReplayDivergenceError( f"unrecorded read at step {recorded.step}: input tuples differ " f"({len(recorded.input_tuple)}B vs {len(replayed.input_tuple)}B); " f"replay is invalid downstream of this step" ) if recorded.output != replayed.output: # Input-identical, output-divergent: genuine nondeterminism, not a replay artifact. raise ReplayDivergenceError( f"nondeterministic completion at step {recorded.step}: inputs identical, " f"outputs differ; investigate sampling/model-version drift, not the log" ) def find_first_divergence( recorded: list[DecisionRecord], replayed: list[DecisionRecord] ) -> int: """Walk forward; return the first step whose input tuple differs from the record. The reported divergence step from an output-diffing harness is a lower bound. The true first divergence is the first step whose *input* differs, which is by construction an unrecorded read if the log is read-incomplete. """ for rec, rep in zip(recorded, replayed): if rec.input_tuple != rep.input_tuple: return rec.step certify_replay_step(rec, rep) raise ReplayDivergenceError( "no input divergence found in recorded window; replay is read-complete " "over this window and any output divergence is genuine nondeterminism" ) ```