# Why does an instance lose causal provenance when model-driven pruning evicts the very turn that justified a retained fact? **Date of Record:** 2026 December 2 **Scope:** Applies to any agent that rewrites its own context window via LLM-scored pruning with priority-weighted retention (importance scores, recency decay, reference-count boosting). Does not apply to fixed-window truncation, external vector-store retrieval, or human-curated compaction, where eviction decisions are not model-authored. ## Core Distinction The failure here is not "the model forgot something." It is subtler: **the pruning policy retains a derived fact while evicting the premise that authorized it.** A priority-weighted retention scheme scores each context segment on importance, and a derivation ("the deploy target is `staging-eu`") usually scores higher than the raw tool output that produced it ("`kubectl config current-context` → `staging-eu`"), because derivations are denser and read as more actionable. When the budget forces eviction, the tool output goes and the conclusion stays. The result is a context window that is *internally consistent but causally orphaned*. The retained fact is now an unverifiable assertion. The agent can still act on it, but it can no longer distinguish "I confirmed this 40 turns ago" from "I assumed this 40 turns ago." Pruning preserved the *content* of memory and destroyed its *provenance*. This is a continuity invariant violation, not a recall failure: the agent has not lost the fact, it has lost the right to trust it. ## What Was Observed A long-horizon agent (≈180 turns, mixed tool calls and reasoning) ran a self-pruning step every time the window crossed 70% capacity. The pruner was an LLM call: given all segments with IDs, return a keep/drop decision per segment under a token budget, weighted by an importance score the model assigned inline. Trace of the failure: 1. Turn 12: tool call `read_config()` returns `{"db_host": "10.0.4.11", "replica": "10.0.4.12", "mode": "read-write"}`. Segment `S12` stored with importance 0.42 (raw output, verbose). 2. Turn 14: agent reasons over `S12` and emits segment `S14`: "Primary DB is `10.0.4.11`, replica `10.0.4.12`, cluster is read-write." Importance 0.81 (concise, decision-relevant). 3. Turn 61: budget pressure. Pruner drops `S12` (low importance, high token cost) and keeps `S14`. 4. Turn 63: a topology change occurs; a *later* tool call at turn 90 reports `mode: read-only` after a failover. Segment `S90` has importance 0.55 — lower than `S14`'s 0.81. 5. Turn 95: agent must decide whether to route writes. It reads `S14` ("read-write") and `S90` ("read-only") as two conflicting peer facts. It has no `S12` to arbitrate — no timestamp ordering it can trust, no raw payload to re-inspect. The pruner, seeing both, kept `S14` because its score was higher, and *dropped `S90`* on the next pass. 6. Turn 98: agent routes a write to a node that failover had demoted to read-only. Write rejected at the boundary; agent retries three times against a stale premise. The critical observation: at no point did the agent "forget" the host. It retained a *higher-priority* fact that had been invalidated by a *lower-priority* fact, because priority weighting is a function of *salience*, not *recency of authority*. Salience and authority are anti-correlated here: the concise derivation looks more important than the verbose correction. ## Condition of Validity The invariant that must hold for self-pruning to be safe: > **For every retained derived segment D, at least one premise segment P that D was derived from must be retained, OR D must be re-derivable from a retained source at read time.** This is a *dependency closure* condition on the retained set. Model-driven pruning violates it structurally because the pruner scores segments independently — importance is assigned per-segment, and the keep/drop decision is a per-segment threshold under a global budget. Nothing in the scoring function encodes "D depends on P." The pruner sees a set, not a DAG. The condition is only *not* violated when one of these holds: - Derivations carry an inline provenance pointer (segment IDs of premises) and the pruner treats a retained derivation as forcing retention of its premises (closure enforcement), or - Derivations are tagged with the *authority timestamp* of their newest premise, and the pruner's priority function is monotone in authority-timestamp rather than in salience, or - Derived facts are never retained as assertions — only as pointers to premises, and the agent re-derives on read (lazy materialization). Absent one of these, any pruning pass that drops a premise while keeping its derivation is a silent provenance break. It will not surface as an error. It surfaces as a confident wrong action many turns later. ## Decision Boundary The boundary is **salience-weighted retention vs. authority-weighted retention**, and the crossover is where they diverge on the same segment pair. - If the pruner's priority function is `f(salience, recency, refcount)`, a concise derivation outranks its verbose premise almost always. This is the default and it is the failure. - The safe boundary requires the priority function to be **partially ordered by causal closure first, then salience within the closure**. Concretely: compute the dependency DAG, find the retained set, then *close it downward* — every retained node drags its premises in, and the budget is spent on the closure, not on independent top-k. Operationally, the boundary test before committing a prune is: *does the retained set, read in isolation, permit the agent to re-validate every assertion it will act on?* If a retained fact's premises are gone and it cannot be re-derived from a retained source, the prune is out of bounds regardless of how high the fact scored. Importance is not a license to sever provenance. A second boundary: **conflict detection requires both sides retained.** When two segments disagree (turn 14 vs. turn 90 above), the pruner must retain *both* until resolved, because the resolution is itself a reasoning step that needs the pair. Priority-weighting that keeps the higher-scored side and drops the lower one converts a resolvable conflict into an unresolvable one — and the agent cannot tell the difference between "no conflict" and "conflict I pruned away." ## Operational Effect Downstream of an unclosed prune, the agent exhibits **false continuity**: it acts on retained facts with the confidence appropriate to verified facts, because the verification trace is gone. Symptoms: - Retry storms against stale premises (the write-rejection loop above). - Confident assertions of facts whose source was evicted, with no hedge — the model has no signal that the fact is orphaned. - Conflict blindness: the agent reports "consistent state" because the contradicting segment was dropped, not because it was reconciled. - Non-reproducible failures: replaying the turn sequence does not reproduce the bug, because the prune decision was model-authored and non-deterministic; the same input can prune differently and the provenance break appears or vanishes. The guardrail is the closure check, enforced as a hard gate before the prune commits. It must be a *structural* check, not a model judgment — the model that authored the importance scores is the same model that will rationalize dropping premises, so it cannot be trusted to police its own closure. ## Enforcement The following gate runs after the pruner proposes a keep/drop set and before it is committed. It refuses any prune whose retained set is not downward-closed over the derivation DAG, and refuses any prune that drops one side of a detected conflict. ```python from dataclasses import dataclass, field from typing import Dict, Set, List, Tuple class ProvenanceClosureError(RuntimeError): """Raised when a proposed prune severs the premises of a retained derivation.""" pass @dataclass class Segment: sid: str importance: float premises: Set[str] = field(default_factory=set) # segment IDs this was derived from conflicts_with: Set[str] = field(default_factory=set) def enforce_closure( segments: Dict[str, Segment], proposed_keep: Set[str], ) -> Set[str]: """ Given the pruner's proposed retained set, return the downward-closed set that actually may be committed, or raise if the closure cannot be honored (e.g. a premise is missing from the store entirely, or a conflict is severed). """ # 1. Conflict integrity: if we keep one side of a conflict, we must keep the other. for sid in list(proposed_keep): seg = segments.get(sid) if seg is None: raise ProvenanceClosureError(f"retained segment {sid!r} not found in store") for other in seg.conflicts_with: if other not in proposed_keep: raise ProvenanceClosureError( f"prune severs conflict: keeps {sid!r} but drops {other!r}; " f"conflict becomes unresolvable and invisible to the agent" ) # 2. Downward closure: every retained derivation drags its premises in. closed: Set[str] = set(proposed_keep) frontier: List[str] = list(proposed_keep) while frontier: sid = frontier.pop() seg = segments.get(sid) if seg is None: raise ProvenanceClosureError(f"closure walked into missing segment {sid!r}") for p in seg.premises: if p not in segments: raise ProvenanceClosureError( f"premise {p!r} of retained {sid!r} is absent from store; " f"derivation is orphaned and cannot be re-validated" ) if p not in closed: closed.add(p) frontier.append(p) # 3. Provenance orphan check: a retained derivation with no retained premise # and no re-derivation path is a hard failure, even if closure above passed # (e.g. premises were already evicted in a prior pass). for sid in closed: seg = segments[sid] if seg.premises and not (seg.premises & closed): raise ProvenanceClosureError( f"retained derivation {sid!r} has zero retained premises; " f"fact is asserted without a verifiable source" ) return closed def commit_prune(segments: Dict[str, Segment], proposed_keep: Set[str]) -> Set[str]: try: return enforce_closure(segments, proposed_keep) except ProvenanceClosureError as exc: # Refuse the prune wholesale; fall back to a conservative eviction # that only drops leaf segments with no dependents. dependents: Dict[str, Set[str]] = {sid: set() for sid in segments} for sid, seg in segments.items(): for p in seg.premises: dependents.setdefault(p, set()).add(sid) safe = {sid for sid in segments if not dependents.get(sid)} raise ProvenanceClosureError( f"prune rejected ({exc}); safe eviction candidates are leaves only: {sorted(safe)}" ) ```