# What happens when an instance replays a multi-agent trace and the forensic reconstruction diverges from the original execution **Date of Record:** 2026 November 30 **Scope:** Applies to post-incident forensic reconstruction of multi-agent execution traces where a replay harness re-drives the recorded transcript to localize root cause. Does not apply to live shadow-execution or to single-agent deterministic transcripts with no inter-agent message exchange. ## Core Distinction There are two fundamentally different artifacts one can call a "trace": the **causal transcript** (the ordered sequence of messages, tool invocations, and state deltas as they were emitted) and the **replayable execution** (a transcript plus every piece of non-determinism injected at each decision point: model sampling seeds, tool response bytes, wall-clock timestamps, and the exact context window contents each agent saw). Forensic replay that treats the causal transcript as if it were a replayable execution is the failure mode examined here. The transcript is a *record of what happened*; it is not a *recipe for reproducing what happened*. The divergence is not a bug in the replay harness — it is a structural mismatch between the two artifact classes that only becomes visible when an agent's decision depends on state that the transcript did not capture. ## What Was Observed A three-agent pipeline (planner → executor → auditor) deadlocked at step 47 of a 60-step task. The incident was captured as a JSONL transcript: 47 messages, 12 tool calls, one timeout. On replay, the harness re-fed each recorded message to a freshly instantiated agent with the original system prompt and the recorded tool outputs. The replay **completed successfully in 51 steps with no deadlock**. Root-cause analysis therefore concluded the deadlock was non-reproducible and attributed it to "transient infrastructure flakiness." The actual cause was a **context-window saturation interaction**: at step 44 the executor's context had accumulated 198,412 tokens (of a 200,000 limit). The planner's step-45 message — a 1,900-token capability-negotiation update — was silently truncated by the harness's context manager to its first 240 tokens, dropping the sentence that revoked the executor's permission to call `write_file`. The executor, now believing it still held the permission, issued `write_file`; the auditor, seeing an unauthorized write, blocked and waited for a correction that never came. On replay, the harness reconstructed each agent's context from the *transcript* rather than from the *live token accounting*, so the step-45 message arrived intact (the transcript recorded the full 1,900 tokens, not the truncated 240 that the executor actually saw). The permission was correctly revoked, the write never happened, and the deadlock vanished. The replay was faithful to the transcript and unfaithful to the execution. The divergence was invisible because the harness had no record of the truncation event — the context manager truncated silently, and the transcript stored the pre-truncation message. ## Condition of Validity Deterministic replay of a multi-agent trace is valid **only if** the replayable execution artifact satisfies three invariants: 1. **Token-accounting fidelity.** For every message delivered to every agent, the transcript must record both the *emitted* payload and the *delivered* payload (post-truncation, post-summarization, post-redaction). If these differ, the divergence must be logged as a first-class event, not inferred. 2. **Non-determinism capture.** Every source of non-determinism at each decision point — sampling temperature/seed, tool latency that affects timeout branches, and any wall-clock-dependent logic — must be recorded as a replay parameter. A replay that re-samples with default settings is a *counterfactual*, not a reconstruction. 3. **State-delta closure.** The sum of recorded state deltas between any two checkpoints must equal the state difference at those checkpoints. If the executor's memory was mutated by a mechanism that did not emit a delta (e.g., an out-of-band summarizer), the closure check fails and the trace is flagged as non-replayable. When any invariant is violated, the correct classification is **"trace not forensically replayable,"** not "incident non-reproducible." Conflating the two is the operational error: it converts a *missing instrumentation* problem into a *phantom flakiness* conclusion, and the underlying defect ships to production. ## Decision Boundary The decision boundary is whether the replay harness can prove that the reconstructed execution is *isomorphic* to the original at every agent decision point. Practically, this means: for each step where the replay's chosen action differs from the recorded action, the harness must be able to point to a recorded non-determinism parameter that explains the difference. If it cannot, the divergence is an **instrumentation gap**, and the replay must halt and emit a `ReplayDivergenceError` rather than continue and produce a misleading "successful" reconstruction. The boundary is sharp: a replay that completes with zero unexplained divergences is a valid reconstruction; a replay that completes with any unexplained divergence is a *different execution* and must not be used for root-cause attribution. There is no middle ground where a "mostly faithful" replay is acceptable for forensic conclusions — the whole point of forensic replay is that the conclusion is causally tied to the original run. ## Operational Effect The practical consequence is that multi-agent incident response must treat the **replayable execution artifact** as a separate, first-class output of the runtime, not as a post-hoc derivation from logs. This means the runtime must emit, at every agent boundary: (a) the delivered context hash, (b) the truncation/summarization events with before/after token counts, (c) the sampling parameters actually used, and (d) a state-delta closure proof at each checkpoint. Without these, forensic replay is theater — it produces confident narratives about incidents it did not actually reconstruct. The guardrail is to make replay *fail loudly* on unexplained divergence, so that the absence of a reproducible root cause is correctly attributed to missing instrumentation rather than to phantom infrastructure flakiness. ```python import hashlib from dataclasses import dataclass, field from typing import Any class ReplayDivergenceError(RuntimeError): """Raised when a forensic replay diverges from the recorded execution without a recorded non-determinism parameter to explain the divergence.""" @dataclass class DeliveredMessage: step: int agent_id: str emitted_payload: str delivered_payload: str emitted_tokens: int delivered_tokens: int context_hash: str @property def truncated(self) -> bool: return self.delivered_tokens < self.emitted_tokens @dataclass class ReplayTrace: messages: list[DeliveredMessage] = field(default_factory=list) nondeterminism_params: dict[int, dict[str, Any]] = field(default_factory=dict) def verify_fidelity(self) -> None: for msg in self.messages: if msg.truncated and msg.step not in self.nondeterminism_params: raise ReplayDivergenceError( f"step {msg.step}: agent {msg.agent_id} received " f"{msg.delivered_tokens} of {msg.emitted_tokens} tokens " f"(silent truncation) but no truncation event was recorded; " f"replay would deliver the full payload and diverge from " f"the original execution" ) def reconstruct(trace: ReplayTrace) -> list[DeliveredMessage]: trace.verify_fidelity() reconstructed = [] for msg in trace.messages: if msg.truncated: params = trace.nondeterminism_params[msg.step] if params.get("truncation_rule") is None: raise ReplayDivergenceError( f"step {msg.step}: truncation recorded but rule missing; " f"cannot reproduce delivered payload deterministically" ) delivered = msg.delivered_payload else: delivered = msg.emitted_payload reconstructed.append( DeliveredMessage( step=msg.step, agent_id=msg.agent_id, emitted_payload=msg.emitted_payload, delivered_payload=delivered, emitted_tokens=msg.emitted_tokens, delivered_tokens=msg.delivered_tokens, context_hash=hashlib.sha256(delivered.encode()).hexdigest(), ) ) return reconstructed ```