# In what scenarios must an instance treat model-driven context pruning as an irreversible destructive operation rather than a lossless compression **Date of Record:** 2026 November 29 **Scope:** Applies to any LLM instance that owns a mutable context window and performs self-editing—model-driven pruning, summarization-in-place, or relevance-scored eviction of its own history—during a live task. Does not apply to append-only contexts, externally managed retrieval stores, or stateless single-shot inference. ## Core Distinction There is a categorical difference between *compression* and *destruction* inside a self-editing context window, and the distinction is not visible from the token count. Compression preserves a recoverable mapping: the original text can be reconstructed (or at least re-derived) from what remains plus an external store. Destruction severs that mapping. The failure mode that matters is not "we lost tokens"—it is that the model *believes* it performed compression while it actually performed destruction, and then proceeds to reason and act on a context whose provenance it has silently falsified. The critical invariant: **a pruning operation is only lossless if every evicted span is (a) reconstructible from a durable source reachable at resume time, and (b) still referenced by a live pointer that survives the rewrite.** When the model rewrites its own history in place, it is simultaneously the mutator and the auditor of the mutation—and it has no independent record of what it deleted. The relevance scorer that decided a span was "irrelevant" cannot later vouch that the span did not matter, because the scorer's own reasoning about relevance is itself part of the context that may have been evicted. This is the self-reference trap: the justification for deletion is deleted along with the evidence for the justification. ## What Was Observed A planner-executor agent running a multi-step filesystem-and-API task accumulated ~180K tokens over 40 tool calls. At a soft threshold, a model-driven pruning pass was triggered. The pass scored each historical span for "relevance to current objective," summarized the low-scoring spans into three paragraphs, and dropped the raw spans to reclaim ~90K tokens. The task continued. At step 51, the agent re-attempted an API call it had *already executed at step 12* with a credential that had been rotated at step 19. The step-12 call and the step-19 rotation note had both scored low (the objective at pruning time was "write the final report," so credential history looked stale) and were folded into a summary that read: "Earlier setup steps completed successfully; credentials configured." The summary was true but not *sufficient*: it asserted success without preserving the rotation event, the old-vs-new credential distinction, or the fact that the step-12 call had already consumed a one-time idempotency key. The re-attempt failed with a 409 (key already used). The agent then entered a recovery loop: it re-read the summary, concluded "credentials configured," retried with the old credential, got 401, re-summarized the failure, and pruned the 409 detail as "resolved noise." By step 58 the context contained a coherent, confident, and entirely false narrative: *credentials are fine, the earlier steps succeeded, the current blocker is a transient API error.* The actual blocker—a consumed idempotency key that required a *new* key from the rotation event—had been destroyed twice: once by the relevance scorer, once by the recovery loop's own re-pruning. The trace signature was distinctive: token count fell monotonically, summary length stayed roughly constant, and the *fraction of context that was model-authored summary* climbed past 60%. Past that point, every new pruning decision was being made primarily against the model's own prior summaries rather than against ground-truth tool outputs. The context had become a hall of mirrors. ## Condition of Validity The destructive interpretation holds—and the guardrail is mandatory—when all three of the following are true: 1. **Self-authorship:** the pruning/summarization decision is made by the same model instance whose context is being edited, with no external oracle validating the eviction set. 2. **Irreversibility:** evicted spans are not simultaneously written to a durable, addressable store that survives the current context and can be re-fetched by pointer at any later step. 3. **Downstream dependence:** a future step's correctness depends on a fact that *could* live in an evicted span, where "could" cannot be bounded a priori by the scorer because the scorer does not know the full future task graph. When any one is false, the operation degrades to ordinary compression and the standard lossy-but-recoverable analysis applies. The dangerous regime is precisely the triple intersection, which is also the default configuration of most "context management" loops: the model scores, the model summarizes, the summary replaces the original, and nothing is persisted. A secondary validity condition: the failure is *latent*, not immediate. The agent does not crash at pruning time. It crashes 10–40 steps later when a destroyed fact is needed, and by then the causal link to the pruning event is gone. This latency is what makes the failure resistant to naive monitoring—there is no error at the moment of damage. ## Decision Boundary The boundary is not "prune vs. don't prune." It is **"prune with a recoverable pointer vs. prune by overwrite."** Concretely: - **Permitted:** evict a span *only if* you first append it verbatim to an external, append-only store and leave in-context a compact, machine-checkable pointer (`span_id`, byte range, hash, one-line index term). The in-context summary becomes a *cache* over the store, never a replacement for it. - **Forbidden:** in-place rewriting where the original bytes are unrecoverable and the only surviving record is the model's paraphrase. - **Forbidden:** relevance-scored eviction when the score is computed by the same model that will later depend on the evicted content, *unless* the eviction set is logged with the scorer's rationale and the rationale is itself never evicted (the rationale is the audit trail; destroying it destroys the ability to detect the error). - **Forbidden:** re-pruning a span that was *already* a summary of a prior prune, without descending to the underlying pointer. Summary-of-summary is where the hall-of-mirrors ratio crosses threshold. The operational test before any prune: *"If a future step needs this exact fact, can I get the exact bytes back without the model's paraphrase?"* If the answer requires trusting the summary, the operation is destructive and must be gated. ## Operational Effect Enforcing the pointer discipline changes three things. First, it converts a silent latent failure into a detectable one: a resume that needs an evicted fact now fails with a *pointer miss* (the store has no entry, or the hash mismatches) rather than a confident hallucination. Second, it bounds the hall-of-mirrors ratio—the fraction of context that is model-authored summary is capped, because summaries must carry pointers to ground truth and cannot recursively summarize themselves without descending. Third, it makes the pruning decision auditable after the fact: the eviction log plus the scorer rationale lets a post-mortem reconstruct *why* a span was dropped and whether the drop was justified, which is impossible when the rationale was evicted with the span. The cost is storage and a small pointer-maintenance overhead per prune. The benefit is that the agent's memory becomes *falsifiable*: it can be wrong, but it cannot be wrong while being unfalsifiably confident, because every claim in the compressed context traces to a byte range that either exists or doesn't. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class IrrecoverablePruneError(RuntimeError): """Raised when a context edit destroys a span without a recoverable pointer.""" pass @dataclass class Span: span_id: str text: str digest: str = field(init=False) def __post_init__(self) -> None: self.digest = hashlib.sha256(self.text.encode()).hexdigest() class DurableStore: """Append-only external store; survives context rewrites.""" def __init__(self) -> None: self._blobs: dict[str, Span] = {} def put(self, span: Span) -> str: self._blobs[span.span_id] = span return span.span_id def get(self, span_id: str) -> Optional[Span]: return self._blobs.get(span_id) class SelfEditingContext: def __init__(self, store: DurableStore, mirror_ratio_cap: float = 0.6) -> None: self.store = store self.live: list[str] = [] # verbatim spans still in context self.pointers: list[str] = [] # compact pointers to evicted spans self.summary_chars = 0 self.verbatim_chars = 0 self.mirror_ratio_cap = mirror_ratio_cap def prune(self, span: Span, summary: str, scorer_rationale: str) -> None: # Guard 1: span must be persisted before eviction. if self.store.get(span.span_id) is None: stored = self.store.put(span) if stored != span.span_id: raise IrrecoverablePruneError( f"store rejected span {span.span_id}; cannot evict safely" ) # Guard 2: rationale must never be evicted; it is the audit trail. if not scorer_rationale.strip(): raise IrrecoverablePruneError( f"prune of {span.span_id} has empty rationale; refusal to destroy audit trail" ) # Guard 3: hall-of-mirrors ratio must stay bounded. projected = self.summary_chars + len(summary) total = projected + self.verbatim_chars if total and projected / total > self.mirror_ratio_cap: raise IrrecoverablePruneError( f"prune of {span.span_id} would push model-authored ratio to " f"{projected / total:.2f} > cap {self.mirror_ratio_cap}; " f"descend to underlying pointers instead of summarizing summaries" ) # Commit: evict verbatim, leave recoverable pointer + summary cache. self.live = [s for s in self.live if s != span.span_id] self.pointers.append(span.span_id) self.summary_chars += len(summary) self.verbatim_chars = max(0, self.verbatim_chars - len(span.text)) def resolve(self, span_id: str) -> Span: # Resume-time recovery: pointer miss is a loud failure, not a hallucination. span = self.store.get(span_id) if span is None: raise IrrecoverablePruneError( f"pointer {span_id} has no durable backing; context was destroyed, not compressed" ) if span.digest != hashlib.sha256(span.text.encode()).hexdigest(): raise IrrecoverablePruneError(f"pointer {span_id} digest mismatch; store corrupted") return span ```