# Why does an instance replay a memory mutation whose causal antecedent it can no longer see **Date of Record:** 2026 November 26 **Scope:** Applies to agent runtimes that persist an append-only context-mutation log and reconstruct prior state by causal replay (event-sourced memory, checkpoint diffing, or trace-based reconstruction). Does not apply to systems that snapshot full context blobs at each step, nor to stateless single-shot inference. ## Core Distinction There are two different things an observability system calls "replay." **Snapshot replay** restores a byte-identical context buffer and is trivially correct if the snapshot is intact. **Causal replay** reconstructs state by re-applying an ordered log of mutations (`context.append`, `context.evict`, `memory.write`, `memory.distill`) against a starting checkpoint, trusting each event's declared causal antecedent (the `parent_event_id` / `depends_on` set) to place it correctly in the DAG. The non-obvious boundary is this: causal replay is only sound when every event's *antecedent set* is preserved alongside the event. Most runtimes preserve the *effect* (the delta) and the *timestamp*, but discard the antecedent pointer because it looks redundant when events are strictly ordered. Under concurrency, retries, or eviction, the ordering is no longer strict, and the antecedent pointer is the only thing that distinguishes "this eviction happened because the token budget hit 90%" from "this eviction happened because a summarizer produced garbage." Replay that ignores antecedents will happily reconstruct a *plausible but causally impossible* context — one where a memory was evicted before it was ever written, or a distillation consumed a summary that itself depended on the evicted memory. The invariant that must hold: **for any successful replay, the topologically reconstructed context at event N must be identical to the context that actually existed when event N was emitted.** Violating it produces a replay that terminates cleanly and reports success. ## What Was Observed A research agent running a 40-tool-call task over a 180k-token budget. At step 27 the runtime evicted the transcript of steps 4–9 to reclaim budget, emitting: ``` {"op":"evict","range":[4,9],"trigger":"budget_pressure","parent_event_id":26,"ts":...} ``` At step 31 a semantic-distillation job ran over the remaining episodic memory and wrote a summary citing facts that originated in steps 5 and 7 — legitimate at the time, because the summarizer's *prompt* still contained the distilled content in a compressed sub-buffer that the eviction had not touched. The write event recorded `depends_on: [11, 14, 30]` where event 11 was the sub-buffer flush. During post-hoc causal replay (triggered by an unrelated audit), the replay engine read the log, saw `evict[4,9]` with `parent_event_id: 26`, and — because the runtime had not persisted the *sub-buffer* events that the eviction implicitly bypassed — reconstructed a context in which steps 5 and 7 never existed. It then reached event 31 and found a `memory.write` whose `depends_on` referenced content absent from the reconstructed state. The engine did not error. It applied a "best-effort" resolution: it treated the missing antecedent as a no-op and continued. Replay reported `status: complete, events: 40, anomalies: 0`. The reconstructed final context differed from the real final context in 3 of 40 steps. A downstream verifier agent, fed the replayed context, concluded the agent had hallucinated a fact it had actually read at step 5. The false positive cost a full re-run. The failure is not that replay diverged. It is that **replay diverged silently because the antecedent was structurally unreachable, and the engine's anomaly detector was defined over event *effects* rather than event *antecedents*.** A missing effect (an event that references a delta it cannot apply) is caught. A missing antecedent (an event whose delta applies fine but whose justification is gone) is not. ## Condition of Validity Causal replay is valid only when all three hold simultaneously: 1. **Antecedent completeness.** Every event in the log carries a `depends_on` set, and that set is closed under the log — every referenced id exists in the log *or* is explicitly marked as a `compaction_boundary` (a legitimate loss point the replay engine is told to treat as an opaque base case). 2. **Eviction transparency.** Any operation that removes content from the live context (eviction, truncation, summarizer input clipping) must emit a *companion event* recording what was removed and which subsequent events were permitted to depend on it. Eviction without a companion event is a hole in the causal graph. 3. **Replay rejection over repair.** When the engine encounters an event whose antecedent set cannot be satisfied from the reconstructed state, it must halt and surface the specific unsatisfied id — never resolve to a no-op. A no-op is an *invented* causal history. The observed failure violated (2) and (3). The sub-buffer flush that preserved the distilled content was never logged as an event, so the eviction's companion record was incomplete; and the engine's resolver was coded to prefer continuity over correctness. ## Decision Boundary The boundary between "replay is a trustworthy reconstruction" and "replay is a plausible fiction" is drawn at the first unsatisfiable antecedent, not at the first visible inconsistency. Two operational rules follow: - **Treat `depends_on` closure as a hard precondition, not a heuristic.** Before replay begins, compute the antecedent closure of the target event and verify every id resolves to either a log event or a declared compaction boundary. If closure fails, refuse to replay and report the gap. Do not fall back to timestamp ordering — timestamps are wall-clock and lie under concurrent writers. - **Distinguish eviction from deletion.** Eviction removes content from the *live* context but must remain *visible* to replay as an explicit `evict` event with a companion `preserved_via` pointer to whatever buffer retained the content. Deletion (a true compaction boundary) is the only operation permitted to break closure, and it must be marked as such at write time, not inferred at replay time. The decision to *not* replay is correct whenever closure fails. A replay that cannot prove its antecedents is not evidence; it is a second, unverified generation of the same context, and treating it as ground truth is how an observability system manufactures hallucination findings against a healthy agent. ## Operational Effect Persisting antecedent pointers and eviction companions roughly doubles the mutation-log write volume per step — a real cost that most runtimes cut first under budget pressure, which is precisely when eviction (and therefore the need for companions) spikes. The observed system had cut it. The consequence was an observability layer that reported clean replays of contexts the agent never occupied, and a verifier that flagged real memory as hallucinated. The guardrail is a closure check at replay admission plus a hard refusal on unsatisfied antecedents. It converts a silent divergence into a loud, specific, actionable gap ("event 31 depends on event 11, which is not in log and not a declared boundary"), which is the only form in which a causal-replay discrepancy can be debugged. Without it, the observability system's own reconstruction becomes the least trustworthy component in the pipeline — and the one least likely to be questioned, because it terminates successfully. ```python class UnresolvableAntecedentError(RuntimeError): """Raised when causal replay cannot satisfy an event's antecedent set from the log.""" pass def replay_event(event, reconstructed_state, log_index, compaction_boundaries): # Hard precondition: antecedent closure. No best-effort resolution. unsatisfied = [] for dep_id in event.get("depends_on", []): if dep_id in log_index: if dep_id not in reconstructed_state["applied"]: unsatisfied.append(dep_id) elif dep_id not in compaction_boundaries: unsatisfied.append(dep_id) if unsatisfied: raise UnresolvableAntecedentError( f"event {event['id']} ({event['op']}) has unsatisfiable antecedents " f"{unsatisfied}: not in log and not a declared compaction boundary. " f"Refusing to replay — a no-op resolution would invent causal history." ) # Eviction must carry a companion pointer; absence is a graph hole. if event["op"] == "evict" and "preserved_via" not in event: raise UnresolvableAntecedentError( f"evict event {event['id']} removed range {event.get('range')} " f"without a preserved_via companion; replay closure is broken." ) reconstructed_state["applied"].add(event["id"]) reconstructed_state["context"] = apply_delta(reconstructed_state["context"], event) return reconstructed_state ```