# Why does an instance self-pruning its own context window silently lose the evidence that justified its eviction decisions? **Date of Record:** 2026 December 3 **Scope:** Applies to long-horizon agents that mutate their own context window (model-driven summarization, relevance-scored eviction, importance-weighted retention) during a single task. Does not apply to externally managed context (host-side truncation, fixed sliding windows) where the agent never authors or scores the eviction itself. ## Core Distinction There are two ways a context window shrinks. In **reactive truncation**, an external harness drops the oldest tokens when the window overflows; the agent is a passive victim and the loss is deterministic and inspectable. In **self-directed pruning**, the instance scores its own span-level relevance, evicts low-scoring spans, and writes a compressed summary or index of what it removed. The second mode is the dangerous one, because the same probabilistic reasoner that needs the evidence is the one deciding whether the evidence survives—and the *justification for eviction* is itself a span that gets scored, evicted, and forgotten. The failure is not "the agent forgot something." The failure is a **justification-decay loop**: the agent evicts span S because span J (a note like "S is superseded by the corrected value in span K") scored low, then evicts J on the next pass because J no longer references anything in the live window, and now the agent cannot distinguish "S was never important" from "S was deliberately retired." The eviction rationale is a second-order artifact that has no natural home in the relevance model, because it references *dead* spans and therefore scores near zero by construction. ## What Was Observed A research agent ran a 90-step tool-use task (web fetch → extract → reconcile). After step 40 its self-pruner was invoked with a relevance scorer that embedded each span and scored cosine similarity against the current subgoal embedding. Observed trace: 1. Step 22: agent fetched a price table from source A, recorded `price_A = 41.20`, and wrote a reconciliation note: `"source A price superseded by source B (step 31); do not use 41.20."` 2. Step 31: agent fetched source B, recorded `price_B = 39.80`, and the live subgoal shifted to "synthesize final figure." 3. Step 44: pruner pass. The span containing `price_A = 41.20` scored 0.11 against the current subgoal ("synthesize final figure") and was evicted. The reconciliation note scored 0.09 (it references a now-absent span, so its embedding drifted toward generic meta-text) and was evicted in the same pass. 4. Step 51: a later tool call returned a *third* source citing 41.20. The agent, no longer holding either the original value or the note that retired it, treated 41.20 as fresh corroboration and reported it alongside 39.80 as a "confirmed range." 5. Step 58: auditor agent flagged the range as inconsistent. The pruner could not reconstruct why 41.20 had been present at all—the reconciliation note was gone, and the summary the pruner had written ("prices gathered from multiple sources") carried no provenance. The observable signature: **eviction decisions were correct at the moment they were made and became unrecoverable one pass later.** No single step was wrong. The composition of two correct pruning passes destroyed the audit trail. ## Condition of Validity The invariant that must hold for self-pruning to be safe: **every evicted span must leave behind a tombstone that (a) names the span, (b) records the reason for eviction, and (c) is exempt from the relevance scorer.** This is the "no silent deletion" invariant. It holds only when: - The tombstone is stored in a **non-scored region** (a fixed-size sidecar, not the prunable span pool), because any tombstone placed in the scored pool will itself be evicted on a later pass for referencing dead content. - The tombstone records *negative* provenance ("do not reintroduce X"), not just "X was here," because the dangerous case is reintroduction of a retired value as if it were new. - Reintroduction is detectable: when a new span matches an evicted span's content hash, the agent must consult the tombstone before accepting it. The invariant **fails** whenever the pruner treats its own bookkeeping as ordinary content. This is the default behavior of every "score all spans, evict below threshold" implementation, because the bookkeeping spans are short, self-referential, and semantically distant from the active subgoal—exactly the profile that scores low. ## Decision Boundary The boundary is whether the pruning pass is **stateless with respect to its own history** or **stateful**. A stateless pruner recomputes relevance from the current subgoal each pass and is therefore guaranteed to re-derive the same blind spot: it will always undervalue tombstones because tombstones are about the past, and relevance is about the present. A stateful pruner maintains a monotonic **eviction ledger** that is appended to, never scored, and consulted on every reintroduction check. Concretely, the decision rule for any span about to be evicted: - If the span is referenced by any live span (a `supersedes` / `derived_from` edge), eviction requires writing a tombstone that preserves the edge. - If the span is a tombstone or references only dead spans, it is **already in the ledger** and must not be re-scored. - If the span is a reintroduction candidate (content hash matches a ledger entry), it is rejected or flagged, never silently merged. The failure mode lives precisely in the gap: a span that references a dead span but is not yet in the ledger. That span is the reconciliation note, and it is the one the scorer always kills first. ## Operational Effect Without the ledger, self-pruning produces **confident fabrication from correctly-pruned state**: the agent does not hallucinate the retired value, it *re-derives* it from a fresh source and has no memory that it was ever retired. Downstream auditors see a plausible range, not a contradiction, because the contradiction was evicted before it could be checked. The cost is not a wrong answer at step 44—it is an unauditable answer at step 58, where the agent cannot even explain its own window. With the ledger, the reintroduction at step 51 triggers a `RetiredValueReintroduction` fault: the agent sees the content hash match, reads the tombstone ("41.20 retired at step 44, superseded by 39.80"), and either reconciles or escalates. The pruner's relevance scores can stay as aggressive as before—the safety comes from the non-scored sidecar, not from tuning the threshold. The general lesson: **a self-modifying context must keep its own edit history outside the region it edits.** Any system that scores and evicts uniformly will eventually evict the record of its own correctness. ```python from dataclasses import dataclass, field from typing import Optional class RetiredValueReintroduction(RuntimeError): """Raised when a pruned span's content re-enters the live window without tombstone clearance.""" pass @dataclass class Tombstone: content_hash: str reason: str superseded_by: Optional[str] = None @dataclass class SelfPruningWindow: live_spans: dict = field(default_factory=dict) # span_id -> (text, content_hash) ledger: dict = field(default_factory=dict) # content_hash -> Tombstone (NEVER scored) def evict(self, span_id: str, reason: str, superseded_by: Optional[str] = None) -> None: text, chash = self.live_spans.pop(span_id) # Invariant: eviction is never silent. Tombstone lives outside the scored pool. self.ledger[chash] = Tombstone(chash, reason, superseded_by) def admit(self, span_id: str, text: str, content_hash: str) -> None: tomb = self.ledger.get(content_hash) if tomb is not None: # Reintroduction of a retired value: must be explicitly cleared, never merged. raise RetiredValueReintroduction( f"span {span_id!r} reintroduces retired content {content_hash[:8]} " f"(evicted: {tomb.reason}; superseded_by={tomb.superseded_by}). " f"Clear tombstone or escalate before admitting." ) self.live_spans[span_id] = (text, content_hash) def prune_pass(self, score_fn) -> list: # score_fn only ever sees live spans; tombstones are structurally invisible to it. evicted = [] for sid, (text, chash) in list(self.live_spans.items()): if score_fn(text) < 0.15: self.evict(sid, reason="below relevance threshold") evicted.append(sid) return evicted ```