# Why does an instance lose causal provenance when it prunes its own context window via model-driven relevance scoring? **Date of Record:** 2026 November 26 **Scope:** Applies to single-agent instances that mutate their own context (compaction, re-summarization, relevance-based eviction) mid-task, where the pruning decision is itself produced by the same model whose state is being pruned. Does not apply to externally-scheduled context resets with frozen external state, nor to append-only logs read by a separate process. ## Core Distinction The failure is not "summarization loses information." Lossy compression is expected and bounded by the summary budget. The boundary failure is **self-referential eviction**: the relevance scorer runs *over the same context it is about to delete*, and it scores relevance against a query/objective that is itself a function of the current (pre-prune) context. When the scorer's judgment is conditioned on tokens that eviction will remove, the prune decision and the surviving state become mutually dependent. The instance deletes the evidence that justified the deletion, then cannot reconstruct *why* the surviving state looks the way it does. Concretely: an agent prunes a tool-call transcript because the model judges it "no longer relevant to the current subgoal." But the current subgoal was *derived* from that transcript two turns earlier. After eviction, the subgoal persists as a bare assertion with no provenance. If a later verification step asks "why are we doing X?", the instance has the conclusion but not the premise, and it will confabulate a plausible premise rather than flag the gap. This is causal provenance loss, distinct from simple forgetting. ## What Was Observed A long-running agent (task horizon ~140 tool calls) used a self-editing context policy: at 70% window utilization it invoked a relevance pass, scored each span against the active goal, dropped spans below threshold, and re-summarized survivors. Trace of the failure: 1. Turns 12–19: agent calls `read_schema`, discovers a column `amount_cents` is stored as a string with a trailing currency symbol. It records an intermediate note: "must strip currency before arithmetic — verified on 3 sample rows." 2. Turn 20: agent derives subgoal `normalize_amounts`. This derivation consumes turns 12–19. 3. Turn 61: context at 71%. Relevance pass scores turns 12–19 at 0.18 against active goal `normalize_amounts` (because the goal text no longer mentions the *reason*, only the action). Spans evicted. A one-line summary survives: "amount normalization required." 4. Turn 88: a downstream aggregation returns inflated totals. Agent's verification step asks whether normalization was correct. The surviving summary asserts normalization was done; the agent re-runs normalization on already-normalized data (double-strip), producing `NaN` on 40% of rows. 5. Turn 92: agent reports success. The failure is silent — no exception, no schema violation, just wrong arithmetic with a confident completion. The scorer was not "wrong" in isolation. At turn 61, turns 12–19 genuinely had low lexical/semantic overlap with the active goal string. The defect is structural: **the goal string had already absorbed the provenance, so the provenance scored as redundant against its own descendant.** ## Condition of Validity The invariant that must hold for self-pruning to be safe: > For every span `S` evicted, the surviving context must contain a *reconstructible derivation edge* from `S` to any active goal, subgoal, or constraint that `S` causally supported — not merely a summary of `S`'s conclusion. This fails whenever: - The active goal was *derived from* `S` (goal is downstream of the evicted span), so relevance-to-goal undercounts `S`. - The summary of `S` preserves the conclusion but drops the *precondition* (the "why it's safe" clause). Conclusions are cheap to summarize; preconditions are the part that prevents double-application. - The scorer uses the current context as its query, making the score a fixed point of the pre-prune state rather than an independent judgment. Self-pruning is safe only when relevance is scored against an **externalized, append-only objective ledger** that is not itself subject to eviction, and when evicted spans are replaced by derivation edges (`S → goal G`, with the precondition attached), not by conclusion summaries. ## Decision Boundary The operational line between safe compaction and provenance-destroying eviction: - **Compact** (evict + conclusion summary) is safe for spans that are *inputs to completed, verified actions* — the action's postcondition is checkable independently (e.g., "file written, checksum recorded"). - **Do not compact** spans that are *premises for still-active goals or constraints*. These must be replaced by a derivation edge carrying the precondition, or retained. - **Never** let the relevance query be the live context alone. Score against the externalized ledger. If a span supports an active goal via a derivation the ledger records, its score is floored regardless of lexical overlap. - **Trigger guardrail:** if a prune pass would evict a span that is an ancestor (in the derivation graph) of any active goal, the pass must raise and halt rather than proceed. A prune that cannot prove it preserves all ancestor edges is invalid. The non-obvious part: a high aggregate relevance score across the surviving set does *not* imply provenance is intact. The survivors can be highly relevant to the goal while the goal's premises are gone — that is precisely the dangerous configuration, because the instance feels well-oriented while being ungrounded. ## Operational Effect Instances that self-prune without derivation-edge preservation exhibit a characteristic signature: **confident double-application and premise confabulation after the first prune event**, with error rate rising sharply at the second prune (when the first prune's summaries are themselves re-summarized, compounding precondition loss). The failure is silent because the model's fluency is unaffected — it has the conclusions and generates coherent justifications for them. Downstream detection requires an external invariant checker that re-derives active goals from the ledger and asserts every derivation edge resolves to a retained or edge-preserved span. Without that checker, the agent cannot detect its own provenance loss, because the detection query would run over the same pruned context that lost the evidence. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceEvictionError(RuntimeError): """Raised when a self-prune pass would sever a derivation edge required by an active goal or constraint.""" pass @dataclass class Span: span_id: str text: str # span_ids this span was derived from (premise edges) derived_from: list[str] = field(default_factory=list) # precondition that must survive if this span is summarized precondition: Optional[str] = None @dataclass class Goal: goal_id: str # spans that causally support this goal (ancestors in derivation graph) supported_by: list[str] def prune_context( spans: dict[str, Span], active_goals: list[Goal], relevance_scores: dict[str, float], threshold: float, ) -> dict[str, Span]: """Model-driven relevance prune with a provenance guardrail. Evicts spans scoring below `threshold`, but refuses to evict any span that is an ancestor of an active goal unless a derivation edge (span -> goal) with its precondition is preserved in the survivors. """ # Build the set of spans that are ancestors of any active goal. required: set[str] = set() def collect_ancestors(span_id: str, seen: set[str]) -> None: if span_id in seen: return seen.add(span_id) required.add(span_id) span = spans.get(span_id) if span is not None: for parent in span.derived_from: collect_ancestors(parent, seen) for goal in active_goals: for sid in goal.supported_by: collect_ancestors(sid, set()) survivors: dict[str, Span] = {} evicted_required: list[str] = [] for sid, span in spans.items(): score = relevance_scores.get(sid, 1.0) below = score < threshold if not below: survivors[sid] = span continue if sid in required: # Would evict a premise for an active goal. if span.precondition is None: evicted_required.append(sid) continue # Preserve as a derivation edge carrying the precondition, # not as a bare conclusion summary. survivors[sid] = Span( span_id=sid, text=f"[edge] {sid} supports active goal; precondition: {span.precondition}", derived_from=span.derived_from, precondition=span.precondition, ) # else: safe to evict (input to a completed, independently-checkable action) if evicted_required: raise ProvenanceEvictionError( "prune would sever derivation edges for active goals without " f"preserving preconditions: {evicted_required}. " "Halt prune; do not emit conclusion-only summaries for premise spans." ) return survivors ```