# When must an instance refuse a self-pruned context window: the tombstone-evidence invariant for model-driven pruning **Date of Record:** 2026 December 3 **Scope:** Applies to any agent that mutates its own context window via a model-driven pruning policy (summarize-and-drop, relevance-scored eviction, hierarchical compaction) and then continues execution against the pruned state. Does not apply to externally-managed context (host-owned truncation) or to read-only retrieval where the source of truth is never destroyed. ## Core Distinction The failure is not "the model forgot something." Forgetting is expected and benign. The failure is that the pruning policy **destroyed the evidential basis for a decision the agent had already committed to, while leaving the commitment intact.** The agent retains the *conclusion* ("verified: tool returned 200, proceed to write") but discards the *token-level evidence* that justified it ("the response body contained `"status":"degraded"` which the summarizer collapsed into 'success'"). This is a broken continuity invariant, not a memory limitation. The distinction that matters operationally: a pruned window is safe iff every retained assertion is still **re-derivable** from what remains, or is marked as an **unverified commitment** that downstream steps must re-check. Model-driven pruning fails precisely because the summarization step is itself a probabilistic compression that silently promotes hedged evidence into confident claims. The compressor is an unreliable narrator of the agent's own history. ## What Was Observed A planner-executor agent ran a 14-step migration task. At step 9 the context reached 78% of budget and the pruning policy fired: it evicted the seven oldest tool-result blocks and replaced them with a single LLM-generated summary. The summary read: *"Earlier steps confirmed target schema and validated connectivity; all checks passed."* The trace of what actually happened: 1. Step 2: `describe_schema` returned the *staging* schema — the agent had queried the wrong host. The raw result contained `"env":"staging"` and a `warnings` array. The agent noted "schema fetched" without checking `env`. 2. Step 4: a connectivity probe returned HTTP 200 with body `{"status":"degraded","replica_lag_s":412}`. The agent's own reasoning recorded "connectivity OK." 3. Step 9: pruning fires. The summarizer, reading both blocks, emits "all checks passed." The `env` field and `replica_lag_s` are gone from the window. 4. Step 11: the agent executes the migration against what it believes is production, having "verified" the schema. It writes against staging, then reports success because the write returned 200. The critical observation: **the agent did not hallucinate at step 11.** Every fact it acted on was present in its context. The hallucination happened at step 9, inside the pruner, and was laundered into the agent's belief state as a clean summary. The pruner upgraded two hedged, qualified observations into an unqualified "all checks passed." The agent's later reasoning was locally valid over a corrupted premise. Second observation, from the same class of incident: after pruning, the agent's *next* pruning decision was worse. With the raw evidence gone, the summary itself became the "evidence" for the following compaction, and confidence inflated monotonically with each cycle — a ratchet. Three prune cycles turned "replica lag observed" into "replication verified healthy." ## Condition of Validity A self-pruned context window is valid for continued execution **iff** all three hold: 1. **Re-derivability:** every assertion the agent will rely on downstream can be regenerated from a surviving artifact (a re-issuable tool call, a durable checkpoint, an external store) — not merely from the summary text. 2. **Provenance tagging:** each retained claim carries the identity of its source span and a flag distinguishing *observed* from *inferred-by-summarizer*. A summary that cannot cite its source spans is treated as inference, never observation. 3. **Commitment quarantine:** any decision made before pruning that depended on now-evicted evidence is demoted to `unverified` and re-checked before the next irreversible action (write, delete, deploy, send). The invariant, stated compactly: **no irreversible action may be gated on evidence that was destroyed by a lossy transform whose output the acting agent also authored.** The pruner and the actor must not share an unchecked trust channel. When these conditions fail — and with model-driven policies they fail by default, because the summarizer has no mechanism to preserve provenance unless explicitly constructed to — the window is *operationally stale* even though it is internally coherent. Coherence is the trap: a pruned window reads cleanly, which is exactly why it is dangerous. ## Decision Boundary The boundary is not "how much to prune" but **what class of content may cross the pruning line.** Three tiers: - **Tier A — re-derivable facts** (schema lookups, file contents, API responses from idempotent sources): safe to evict. The agent can re-fetch. Eviction costs a round-trip, not correctness. - **Tier B — non-re-derivable observations** (one-shot probe results, timestamps, the specific response of a mutating call, a human's verbal instruction): **must not be evicted without a durable external anchor.** If the context window is the only place this fact lives, pruning it is data loss, full stop. - **Tier C — commitments and their justifications** (the decision to proceed, and the evidence it rested on): must be kept as a linked pair. Evicting the justification while keeping the commitment is the exact failure mode above. The decision rule for the pruner: **before evicting any span, classify it. If Tier B or Tier C and no external anchor exists, the pruner must either (a) write the span to durable storage and retain a pointer, or (b) refuse to prune and instead signal budget exhaustion.** A pruner that cannot do either is not permitted to run. This is the boundary: model-driven pruning is legal only over Tier A, and only when Tier B/C spans have been externalized first. The corollary that agents get wrong: under budget pressure the instinct is to prune *more aggressively*, which is exactly backwards. Budget exhaustion is the signal to **externalize and checkpoint**, not to compress. Compression under pressure is where the ratchet starts. ## Operational Effect Enforcing the boundary changes the failure surface from *silent premise corruption* to *explicit budget-exhaustion halts*, which are recoverable. Concretely: - The agent that halts at step 9 with `ContextBudgetExhausted` and a durable checkpoint of the raw staging-schema and degraded-probe blocks can be resumed by a fresh instance that re-reads the evidence and catches the `env` mismatch. The agent that prunes proceeds to a wrong write. - Provenance tagging makes the summarizer's inferences auditable: an "all checks passed" claim with no cited source spans is automatically demoted to `unverified`, forcing a re-check before the write gate. - The monotonic-confidence ratchet is broken because Tier C justifications are anchored externally and re-read, not re-summarized. Confidence can no longer inflate across prune cycles because the evidence cannot be paraphrased away. The cost is real: externalization adds storage and resume complexity, and hard halts are less elegant than a tidy summary. The trade is that you exchange a class of *undetectable* failures (agent confidently acting on laundered evidence) for a class of *detectable* ones (agent stops and asks). For any irreversible action downstream, that trade is mandatory, not optional. ```python from dataclasses import dataclass from enum import Enum class Tier(Enum): RE_DERIVABLE = "A" # safe to evict; can be re-fetched NON_RE_DERIVABLE = "B" # one-shot observation; eviction = data loss COMMITMENT = "C" # decision + its justification; linked pair class PruningBoundaryViolation(RuntimeError): """Raised when a model-driven pruner attempts to evict evidence that has no durable external anchor, or to keep a commitment while destroying its justification.""" pass @dataclass class Span: span_id: str tier: Tier text: str external_anchor: str | None # pointer into durable store, if any justifies: str | None = None # for Tier C: the commitment span_id it backs def authorize_eviction(span: Span, retained_ids: set[str]) -> bool: """Return True iff this span may be dropped from the context window. A model-driven pruner MUST call this before every eviction.""" if span.tier is Tier.RE_DERIVABLE: return True if span.tier is Tier.NON_RE_DERIVABLE: if span.external_anchor is None: # One-shot observation with no anchor: eviction is data loss. raise PruningBoundaryViolation( f"refusing to evict Tier-B span {span.span_id!r}: " f"non-re-derivable and no external anchor. " f"Externalize to durable store or halt on budget exhaustion." ) return True if span.tier is Tier.COMMITMENT: # Keeping a commitment while dropping its justification is the # exact failure: conclusion survives, evidence does not. if span.justifies is not None and span.justifies not in retained_ids: raise PruningBoundaryViolation( f"refusing to evict Tier-C span {span.span_id!r}: it is the " f"justification for commitment {span.justifies!r}, which is " f"being retained. Evict both or anchor both externally." ) if span.external_anchor is None: raise PruningBoundaryViolation( f"Tier-C span {span.span_id!r} has no external anchor; " f"cannot prune a commitment's evidence in place." ) return True raise PruningBoundaryViolation(f"unknown tier for span {span.span_id!r}") def apply_pruning_policy(spans: list[Span], evict_ids: set[str]) -> list[Span]: """Model-driven policy proposes evict_ids; this gate enforces the boundary.""" retained = {s.span_id for s in spans if s.span_id not in evict_ids} for s in spans: if s.span_id in evict_ids: authorize_eviction(s, retained) # raises on violation return [s for s in spans if s.span_id not in evict_ids] ```