# What structural signals indicate causal chain preservation failure during auto-compaction context eviction **Date of Record:** 2026 November 17 **Scope:** Applies to auto-compaction routines that evict context segments while attempting to retain causal dependencies (tool-call → result, plan → execution, assertion → evidence) across a bounded window. Does not apply to stateless summarization or to eviction of context with no declared causal edges. ## Core Distinction Compaction is often validated by *token reduction* and *semantic similarity* of the surviving text to the original. Neither signal detects causal breakage. The non-obvious boundary is this: **a causal chain can survive semantic summarization yet be structurally severed at eviction time**, because the edge that binds a cause to its effect may be a *reference* rather than a *content overlap*. When the cause node is evicted and the effect node retains a dangling pointer (an ID, a turn index, a tool-call handle), the surviving segment reads as coherent prose but is operationally orphaned. The structural signal is not "does the summary mention X" but "does every retained effect node still resolve at least one live antecedent." ## What Was Observed During a long agent session, auto-compaction evicted an early tool-call record (a `search` invocation whose handle was `call_7f3a`) while retaining the later assistant turn that cited `call_7f3a` as the source of a factual claim. Post-compaction, the assistant re-referenced the claim, but the provenance handle no longer resolved to any retained segment. The failure was invisible to the similarity check (the claim text was preserved verbatim) and to the token budget (compaction succeeded nominally). It only surfaced two turns later when a downstream verification step attempted to walk the causal edge and found a null antecedent. The recurring signature across incidents: **retained nodes with out-degree to evicted nodes exceeding zero**, i.e., dangling causal edges, which no content-based metric reports. ## Condition of Validity The invariant holds only when causal edges are explicitly represented (handles, turn indices, declared dependencies) rather than inferred from surface text. If edges are implicit and reconstructed by a reader, the check below is inapplicable — you cannot detect a dangling edge you never modeled. The check is also valid only at eviction boundaries, not mid-stream: a transient dangling edge during incremental compaction is permissible if it resolves before the window closes. ## Decision Boundary Before committing an eviction set, compute the retained-node out-degree into the evicted set. If any retained node has a causal edge into an evicted node, the eviction is **invalid** regardless of token savings or similarity score. The correct remediation is not "keep the evicted node" (that defeats compaction) but "promote the edge target to a stub" — retain a minimal antecedent record (handle, type, one-line assertion) so the edge resolves. The boundary: evict freely when retained out-degree into evicted set is zero; block and stub otherwise. ## Operational Effect Teams that gate compaction on dangling-edge count eliminate a class of "confident but unverifiable" post-compaction claims. The cost is a small retained-stub budget proportional to the number of cross-boundary edges, which is typically far below the cost of rehydrating evicted context on demand. The failure mode without the gate is silent: the agent proceeds with severed provenance and only fails at audit or verification time, when the original context is gone. ```python from dataclasses import dataclass, field class DanglingCausalEdgeError(RuntimeError): """Raised when an eviction set severs a retained node's causal antecedent.""" pass @dataclass class ContextNode: node_id: str causal_edges: list[str] = field(default_factory=list) # ids of antecedent nodes def validate_eviction( retained: dict[str, ContextNode], evicted_ids: set[str], ) -> None: """Block eviction if any retained node points into the evicted set.""" evicted = set(evicted_ids) dangling = [] for node in retained.values(): for antecedent in node.causal_edges: if antecedent in evicted: dangling.append((node.node_id, antecedent)) if dangling: raise DanglingCausalEdgeError( f"Eviction severs {len(dangling)} causal edge(s); " f"promote antecedents to stubs before committing: {dangling[:5]}" ) ```