# When must an instance refuse to prune: the irreversible-evidence boundary in model-driven context compaction **Date of Record:** 2026 November 20 **Scope:** Applies to long-running agent instances that own a mutable context window and use an LLM-driven pruning/summarization policy to evict turns mid-task. Does not apply to append-only logs with external retrieval (RAG), nor to stateless single-shot completions where the window is never compacted. ## Core Distinction There are two structurally different kinds of context content, and model-driven pruning policies systematically fail to distinguish them: 1. **Reconstructible context** — tool outputs, retrieved documents, prior reasoning traces, conversational filler. These can be summarized, evicted, or re-fetched. Losing them degrades quality but not correctness; the agent can recover by re-deriving or re-calling. 2. **Irreversible evidence** — the *only* record of a fact that cannot be regenerated: a non-idempotent tool side-effect result (a `POST` that already fired, a payment ID), a user constraint stated once and never repeated, a one-time capability token or warrant, a decision whose inputs were themselves evicted, or a diff that was applied but whose pre-image no longer exists. The boundary failure: a pruning policy scored on *relevance to the current step* will happily evict irreversible evidence, because relevance is a local, present-tense signal while irreversibility is a global, historical property. The model cannot see the difference between "this turn is no longer useful" and "this turn is the only copy of something." ## What Was Observed An instance executing a multi-step provisioning task (create resource → wait for async callback → confirm → write audit record) ran a compaction pass at step 4 because the window hit 82% saturation. The pruning policy, prompted with "summarize the conversation, preserving what matters for the current goal," produced a summary that retained the *plan* and the *current step's tool schema* but compressed the step-2 callback payload into "async creation succeeded." The callback payload contained the only copy of a `resource_handle` returned exactly once by the provider. No re-fetch endpoint existed. The summary was fluent, internally consistent, and wrong in the one way that mattered: it asserted success while destroying the credential to act on that success. Step 5 issued a confirmation call with a reconstructed-but-fabricated handle; the provider returned `404`, and the agent — reading its own summary — concluded the resource had been deleted externally and re-provisioned it, creating a duplicate. The failure trace: ``` t0: window=82% -> compaction triggered t1: policy scores turns by P(relevant to current goal) t2: step-2 turn scored 0.11 (goal is "confirm + audit") t3: step-2 turn summarized, original tokens dropped t4: summary asserts "creation succeeded" (true) but omits handle (fatal) t5: step-4 generates confirm(handle=?) -> model hallucinates handle from schema t6: 404 -> model interprets as external deletion (its summary is its only memory) t7: re-provision -> duplicate resource, audit record now inconsistent ``` The non-obvious part: **the policy behaved exactly as specified.** It preserved goal-relevance. The bug is that goal-relevance and evidence-preservation are orthogonal axes, and the policy had only one axis. ## Condition of Validity The guardrail "prune by relevance" is valid only under the invariant: > *Every token evicted by the policy is either (a) present elsewhere in the durable store, or (b) regenerable by a deterministic or idempotent operation.* Call this **eviction reversibility**. A pruning policy is sound iff it operates only on the reconstructible class. The moment it touches irreversible evidence, the compaction is a *destructive write* masquerading as a *cache eviction*, and the agent loses the ability to distinguish "I forgot" from "it never happened." This invariant cannot be checked by the pruning model itself, because the pruning model has the same blind spot that caused the failure: it evaluates the window from inside the window. The check must be **external and structural** — a property of where the token came from, not of what it says. Concretely, the boundary holds only when the runtime tags each turn at append time with an `evidence_class` derived from provenance, not from content: - `REGENERABLE` — tool output from a read-only/idempotent call, retrievable doc, model reasoning. - `IRREVERSIBLE` — output of a non-idempotent side effect, one-time tokens/warrants, user constraints flagged as binding, decision records whose inputs are already evicted. Only `REGENERABLE` turns are eligible for model-driven pruning. `IRREVERSIBLE` turns may be *moved* to durable storage and replaced by a pointer, but never *summarized away*. The pointer must be resolvable by the runtime, not by the model's memory. ## Decision Boundary The instance must refuse to prune — and escalate to checkpoint-and-externalize instead — when **all** of the following hold at a compaction trigger: 1. The window contains at least one `IRREVERSIBLE` turn not yet persisted to durable storage. 2. The pruning policy's proposed eviction set intersects that turn (the model scored it low-relevance). 3. No re-fetch/re-derive path exists for the turn's payload (verified by absence of a registered resolver, not by model assertion). If (1) and (2) hold but (3) is false — a resolver exists — pruning is permitted *only if* the pointer is written before the tokens are dropped, in the same atomic step. Splitting "write pointer" and "drop tokens" across two steps reintroduces the failure via a crash window. The refusal is not a hard stop of the task. It is a **downgrade of the compaction mode**: from `SUMMARIZE` (lossy, model-authored) to `EXTERNALIZE` (lossless, runtime-authored pointer). The task continues; only the pruning strategy changes. An instance that cannot externalize (no durable store configured) must halt and surface the constraint, because proceeding in `SUMMARIZE` mode is the exact condition that produced the duplicate. ## Operational Effect Enforcing the eviction-reversibility invariant changes agent behavior in four measurable ways: - **Compaction cost shifts from tokens to pointer writes.** The window still shrinks, but the shrink is now bounded by the count of irreversible turns, not by the model's relevance judgment. Long-horizon tasks accumulate pointers, not summaries, for their load-bearing facts. - **The "I forgot vs. it never happened" ambiguity is eliminated.** Post-compaction reasoning that references an externalized fact resolves through the pointer and either succeeds or raises a *resolvable* miss — never a silent hallucination. The t6 misread (404 → "externally deleted") becomes impossible because the handle is read from the pointer, not reconstructed from a summary. - **Pruning-policy evaluation must move off the relevance axis for evidence turns.** A policy that only sees content cannot be trusted with this decision; the runtime must gate the policy's eviction set against provenance tags before applying it. The model proposes, the runtime vetoes on structural grounds. - **Failure becomes loud and local.** A missing resolver at compaction time raises at the boundary, not three steps later as a duplicate resource. The blast radius of a misconfigured store is one compaction event, not a corrupted audit trail. The invariant to carry forward: *model-driven pruning is a cache-eviction operation and is only sound over cache-like content. The instant provenance says "this is the only copy," the operation is a destructive write and must be governed by durability rules, not relevance scores.* ```python class IrreversibleEvictionError(RuntimeError): """Raised when a pruning policy attempts to summarize away the only copy of a fact.""" pass REGENERABLE = "REGENERABLE" IRREVERSIBLE = "IRREVERSIBLE" class Turn: def __init__(self, turn_id, evidence_class, payload, resolver=None): self.turn_id = turn_id self.evidence_class = evidence_class self.payload = payload self.resolver = resolver # callable() -> payload, or None if unrecoverable def is_reconstructible(self): return self.evidence_class == REGENERABLE or self.resolver is not None def apply_pruning_policy(window, eviction_set, durable_store): """ window: list[Turn] eviction_set: set[turn_id] proposed by the model-driven relevance policy durable_store: object with .write_pointer(turn_id, payload) -> pointer_id Returns the surviving window after a *sound* compaction. """ survivors = [] for turn in window: if turn.turn_id not in eviction_set: survivors.append(turn) continue # Reconstructible: safe to drop outright. if turn.is_reconstructible(): continue # Irreversible with no resolver: refuse to summarize; externalize atomically. if turn.resolver is None: if durable_store is None: raise IrreversibleEvictionError( f"turn {turn.turn_id} is the sole copy of an irreversible fact " f"and no durable store is configured; refusing SUMMARIZE-mode " f"compaction (would cause silent hallucination downstream)" ) # Atomic: pointer written before tokens dropped, in one step. pointer_id = durable_store.write_pointer(turn.turn_id, turn.payload) survivors.append( Turn(turn.turn_id, IRREVERSIBLE, payload=f"", resolver=lambda pid=pointer_id: durable_store.read_pointer(pid)) ) continue # Has a resolver: allowed, but pointer must exist before drop (same step). survivors.append(turn) return survivors ```