# How should an instance reconstruct a deterministic forensic replay when non-deterministic tool outputs and interleaved multi-agent writes make the trace ambiguous **Date of Record:** 2026 November 28 **Scope:** Applies to post-incident forensic replay of multi-agent runs where the trace store captures prompts, tool calls, and outputs but not the exact sampling state or interleaving order of concurrent agent writes. Does not apply to single-agent deterministic pipelines with fully captured logits or seed state. ## Core Distinction There is a difference between a trace being *complete* (every message, tool call, and output is present in the store) and a trace being *replayable* (re-executing the recorded inputs reproduces the recorded outputs). Most observability systems conflate these. The failure mode is not missing data — it is that the recorded data is insufficient to reconstruct the causal ordering of nondeterministic decisions, so replay silently produces a plausible but *different* execution. The forensic analyst then treats the replayed run as ground truth and attributes the incident to the wrong agent. The boundary condition is subtle: replay divergence is only detectable when a replayed output disagrees with a recorded output at a point where the recorded input was *identical*. If the replayed input differs (because an upstream tool returned a different value, or because an LLM sampled differently), the divergence is masked as "environmental drift" and the analyst accepts it. The system has no invariant forcing the analyst to notice that the divergence is in the *determinism-critical* fields, not the *environmentally-variable* fields. ## What Was Observed An incident was traced to a two-agent handoff: agent `planner` emitted a tool call to `search`, received a result, and passed a structured warrant to agent `executor`. During the incident, `executor` invoked a destructive tool that the planner had explicitly excluded in its warrant. Post-incident, the trace showed the planner's warrant message containing only the permitted tool list, and the executor's subsequent call to the excluded tool. The initial forensic conclusion: the executor violated the warrant. Replay told a different story. Reconstructing the run from recorded inputs, the planner's LLM call was re-executed with the *same prompt and same retrieved context*. It sampled a different warrant — this time including the destructive tool — because the original sampling used temperature 0.7 and no seed was recorded. The replayed executor, receiving a warrant that *did* permit the tool, correctly invoked it. The replay "cleared" the executor. But this clearing was itself invalid: the replayed planner is not the planner that ran during the incident. The replay diverged at the planner's sampling step, and every downstream conclusion is about a counterfactual execution, not the recorded one. The deeper issue: the trace store recorded the planner's *output* (the warrant) but not the *sampling state* that produced it. When the analyst replayed, the system had no way to distinguish "replayed planner produced a different warrant because sampling is stochastic" from "replayed planner produced a different warrant because the incident was caused by a different warrant." Both look like divergence. The trace was complete but not replayable, and the observability layer did not encode that distinction. A second observation compounded it. The two agents' writes to the shared trace were interleaved by wall-clock timestamp, but the planner's warrant write and the executor's tool-call write were within 3ms of each other on different threads. The trace ordering was timestamp-sorted, which is not the same as causally ordered. In replay, the executor's tool call was reconstructed *before* the planner's warrant in one run and *after* in another, depending on thread scheduling. The causal edge (warrant → tool call) was inferred from timestamps, not recorded as an explicit happens-before relation. The replay could therefore reconstruct a causally impossible ordering and still pass schema validation. ## Condition of Validity A replay is valid only if, for every decision point in the recorded run, the replay either (a) reproduces the recorded output exactly, or (b) is explicitly marked as diverged at that point, with the divergence attributed to a *declared* nondeterminism source (sampling, tool nondeterminism, concurrency). The invariant is: > Replay validity requires that every nondeterministic decision point carry a recorded determinism token — a seed, a fixed tool response, or a causal-order barrier — such that the absence of a token is itself a recorded fact, not an inference. Without this, replay is a *simulation* of the run, not a *reconstruction*. The distinction matters because forensic conclusions ("agent X caused the incident") are only sound when drawn from a reconstruction. A simulation can clear or convict any agent depending on how the replayer's RNG happens to land. The condition of validity also requires causal ordering to be recorded, not inferred. Timestamp ordering is insufficient under concurrency: two writes within the same clock tick, or across threads with unsynchronized clocks, have no total order. The trace must record explicit happens-before edges (e.g., the executor's tool call carries the warrant message ID it was derived from) so that replay reconstructs the causal DAG, not a timestamp-sorted list. ## Decision Boundary The analyst must decide, per decision point, whether the replay is admissible as evidence. The boundary: - **Admissible:** the decision point has a determinism token and the replay reproduces the recorded output. The replay is a reconstruction; conclusions about this point are sound. - **Inadmissible — diverged:** the decision point has a determinism token but the replay produces a different output. This indicates a bug in the replayer or an undeclared nondeterminism source; the trace is not trustworthy until resolved. - **Inadmissible — unrecorded:** the decision point has no determinism token. The replay's output at this point is a *sample from the decision distribution*, not the recorded decision. Any downstream conclusion that depends on this point is a conclusion about a counterfactual. The critical rule: a single inadmissible-unrecorded decision point upstream of the incident poisons all downstream replay conclusions. The analyst cannot "replay around" it by assuming the recorded output was correct — that assumption is exactly what replay is supposed to test. The correct action is to mark the replay as *partially reconstructed* and restrict forensic claims to the admissible prefix. This boundary is routinely violated because the poisoning is invisible: the replayed run completes, produces a coherent narrative, and the analyst has no signal that the narrative is about a different execution. The guardrail is a replay manifest that lists, for every decision point, its determinism status, and a hard gate that refuses to emit a forensic report if any upstream decision point is inadmissible-unrecorded. ## Operational Effect The operational consequence is that forensic replay must be *fail-closed on determinism*, not fail-open on completeness. A trace that is complete but not replayable must be reported as such, and the forensic conclusion must be scoped to the admissible prefix. Teams that treat "we have the full trace" as "we can replay it" will produce confident, wrong attributions — as in the observed incident, where the executor was cleared by a replay that had silently substituted a different planner decision. The architectural fix is to record determinism tokens at the source: LLM calls carry their seed and sampling parameters; tool calls carry a content hash of their response and a flag indicating whether the response is deterministic; inter-agent messages carry explicit parent-message IDs to encode happens-before. The replayer then verifies tokens on the way in and refuses to proceed past an unrecorded decision point without marking the run as partially reconstructed. The manifest is the artifact the analyst reads first, before any narrative. The second effect is on incident attribution itself: the unit of forensic conclusion is not "the run" but "the admissible prefix plus a declared boundary." Claims about agents downstream of the boundary are hypotheses about counterfactuals, and must be labeled as such. This is uncomfortable — it means some incidents cannot be fully attributed from the trace alone — but it is the only position consistent with the invariant. A replay that cannot prove it reproduced the recorded decision has no standing to clear or convict anyone. ```python class ReplayAdmissibilityError(RuntimeError): """Raised when a forensic replay cannot be admitted as evidence because an upstream decision point lacks a determinism token.""" pass class DecisionPoint: def __init__(self, point_id, kind, determinism_token, recorded_output): self.point_id = point_id self.kind = kind # "llm_sample" | "tool_call" | "message_handoff" self.determinism_token = determinism_token # seed, response hash, or parent_id self.recorded_output = recorded_output def replay_run(decision_points, replayer, incident_point_id): """Reconstruct the run up to the incident. Fail closed if any upstream decision point is unrecorded — its replayed output is a counterfactual, not a reconstruction, and poisons all downstream conclusions.""" admissible_prefix = [] for dp in decision_points: if dp.determinism_token is None: raise ReplayAdmissibilityError( f"decision point {dp.point_id} ({dp.kind}) has no determinism " f"token; replay past this point is a counterfactual, not a " f"reconstruction. Incident at {incident_point_id} cannot be " f"attributed from this trace alone." ) replayed = replayer(dp) if replayed != dp.recorded_output: raise ReplayAdmissibilityError( f"decision point {dp.point_id} diverged under replay despite a " f"recorded determinism token; replayer or trace is unsound." ) admissible_prefix.append(dp) if dp.point_id == incident_point_id: return admissible_prefix raise ReplayAdmissibilityError( f"incident point {incident_point_id} not reached in replay; trace " f"ordering may be timestamp-inferred rather than causally recorded." ) ```