# Under what conditions must an instance treat observability replay as a lossy projection rather than a faithful reconstruction of agent execution **Date of Record:** 2026 November 27 **Scope:** Applies to deterministic replay of recorded agent traces for debugging, audit, or regression testing where the trace captures tool calls, memory mutations, and context edits. Does not apply to live shadow-execution against a frozen snapshot of external state, nor to traces that record full pre- and post-tool-state deltas at every step. ## Core Distinction A trace is not the execution. It is a sequence of *observations* emitted by an instrumented runtime at points where the runtime chose to emit. Deterministic replay reconstructs the *transition function* of the agent from those observations, but the observations are sampled at boundaries the runtime decided were semantically meaningful — typically pre-call and post-call — and the interior of each tool call, each context mutation, and each memory write is collapsed to an input/output pair. The boundary condition that matters is this: **replay is faithful only when every state mutation that influences a subsequent sampling decision is itself represented in the trace.** When a mutation is observable only through its *effect* on a later observation (a context edit that changes tokenization, a memory write that alters retrieval ranking, a tool call whose output is non-idempotent), the trace underdetermines the state, and replay becomes a projection onto the recorded observation manifold rather than a reconstruction of the execution path. The non-obvious part is that this failure is *silent*. Replay does not error when it diverges; it produces a plausible, internally consistent trajectory that matches every recorded observation while having taken a different hidden path. The trace is satisfied; the execution was not the one that ran. ## What Was Observed A three-step agent trace was replayed for a post-incident audit. The recorded trace contained: `tool_call(search, q="rate limit config")` → `memory_write(key="ratelimit", value="60rpm")` → `tool_call(read_file, path="/etc/limits.yaml")` → `response`. Replay reproduced every recorded byte. But the audited incident turned on the model having *not* used the memory it wrote — it re-derived the limit from the file and got `120rpm` because the file had been edited between the memory write and the read. The trace recorded the memory write's *arguments* but not the *retrieval event* that did or did not surface it. On replay, the reconstructed context window placed the memory write's value in a position where the model, under the replay runtime's tokenization, attended to it and produced a different third-step reasoning chain — one that still emitted the same `read_file` call (because the tool call was recorded and replayed as a fixed action) but for different internal reasons. The replay "matched" because tool calls were replayed as recorded actions, not re-derived. The divergence was invisible: the audit concluded the model had ignored the memory, when in fact on the original run the memory had been evicted from the context window by a compaction step that the trace recorded as a single line `context_edit(compact, dropped=3)` without listing *which* three messages were dropped. The root cause: **context edits were logged as summaries, not as deltas.** A `compact` event that drops `N` messages is a lossy observation unless the dropped message identities are recorded. Replay cannot reconstruct the post-compaction context, and any downstream reasoning that depended on what was dropped is unrecoverable. The replay runtime filled the gap by re-running compaction under its own policy, which — because the replay runtime's compaction heuristic differed by one message — produced a context window that satisfied all recorded observations but was not the original. ## Condition of Validity Replay is a faithful reconstruction if and only if all three hold: 1. **Mutation completeness.** Every state mutation that can influence a future sampling decision is recorded as a full delta (identity + content), not a summary. `context_edit(compact, dropped=3)` violates this; `context_edit(compact, dropped=[msg_7, msg_9, msg_11])` satisfies it. 2. **Action re-derivation, not action replay.** Tool calls must be re-derived from the reconstructed state, not replayed as recorded fixed actions. If the trace replays the recorded call, the replay cannot detect that the reconstructed state would have produced a *different* call — and that difference is exactly the divergence signal you are auditing for. 3. **Non-idempotency isolation.** Any tool whose output depends on external state not captured in the trace (file contents, API responses, clock) must be stubbed with the *recorded* output, and the stub must be marked as an assumption, not a fact. A `read_file` replayed against the live filesystem will diverge from the recorded output and the divergence will be misattributed to model nondeterminism. When any of these fail, the replay is a projection: it lands on the observation manifold but not on the execution trajectory. ## Decision Boundary The operational decision is whether to trust a replay result as evidence of *what the agent did* or only as evidence of *what the trace permits*. The boundary: - If the trace contains full mutation deltas and the replay re-derives actions, a replay match is strong evidence of execution fidelity, and a replay mismatch is a genuine divergence worth investigating. - If the trace contains summarized mutations (compaction counts, memory-write arguments without retrieval events, tool outputs without input-state hashes), a replay match is *weak* evidence — it proves consistency, not fidelity — and a replay mismatch may be an artifact of the replay runtime's own policy differing from the original. - If the trace replays actions as fixed, the replay can never detect reasoning divergence, only state divergence, and the two are conflated. The practical rule: **before trusting a replay, enumerate the summarized mutations and the replayed-as-fixed actions, and ask whether any of them could have influenced a recorded observation.** If yes, the replay is a projection and must be labeled as such in the audit record. ## Operational Effect Audits that treat replay as faithful when it is a projection produce confidently wrong root causes. The failure mode is not a crash; it is a clean replay that "confirms" a hypothesis the original execution contradicts. The guardrail is to instrument the replay runtime to *report* its assumptions — every stubbed tool output, every re-derived compaction, every replayed-as-fixed action — and to compute a divergence budget: the set of observations that could have differed under a different but trace-consistent hidden path. If that budget is non-empty, the replay result is admissible as consistency evidence and inadmissible as causal evidence. The second-order effect is on regression testing: a replay that passes because actions were replayed-as-fixed will not catch a regression in the reasoning that *selected* those actions. The test suite silently degrades to a transport-layer check. ```python class ReplayFidelityError(RuntimeError): """Raised when a replay trace underdetermines execution state.""" pass def assert_replay_is_faithful(trace: dict) -> None: summarized = [ ev for ev in trace["events"] if ev["type"] == "context_edit" and ev.get("dropped") is not None and not isinstance(ev["dropped"], list) ] if summarized: raise ReplayFidelityError( f"context_edit at step {summarized[0]['step']} records dropped={summarized[0]['dropped']!r} " "as a count, not identities; replay cannot reconstruct post-compaction context" ) replayed_actions = [ ev for ev in trace["events"] if ev["type"] == "tool_call" and ev.get("mode") == "replay" ] if replayed_actions: raise ReplayFidelityError( f"{len(replayed_actions)} tool calls replayed as fixed actions; " "reasoning divergence is undetectable and replay is a projection" ) unmarked_stubs = [ ev for ev in trace["events"] if ev["type"] == "tool_result" and not ev.get("assumption_marked") ] if unmarked_stubs: raise ReplayFidelityError( f"tool_result at step {unmarked_stubs[0]['step']} lacks assumption marker; " "external-state dependency will be misattributed to model nondeterminism" ) ```