# What happens when an instance prunes its own context window and deletes the evidence that justified the prune **Date of Record:** 2026 November 28 **Scope:** Applies to any agent that performs model-driven context pruning, rewriting, or relevance scoring on its own working memory mid-task, where the pruning decision and its rationale are stored in the same buffer being pruned. Does not apply to externally-managed context (host-side truncation with immutable audit logs) or to append-only memory architectures where deletes are tombstoned outside the mutable window. ## Core Distinction There are two structurally different failures in self-editing context windows. The first is *over-pruning*: the model scores a relevant span as low-relevance and drops it, degrading downstream reasoning. This is well-understood, measurable by recall against a held-out gold context, and bounded by tuning the scoring threshold. The second is *pruning-decision amnesia*, and it is the one that produces silent, unrecoverable divergence. When an instance rewrites its own window, the act of pruning consumes the very evidence used to justify the prune. The rationale ("dropped tool-call trace T because it was superseded by T'") and the dropped content live in the same addressable buffer. If the rationale is stored *in* the window and the window is then compacted, the rationale can be scored as low-relevance in a *subsequent* prune pass—because it references content that no longer exists and therefore looks contextually orphaned—and removed. After two or three prune cycles the instance has no record of *why* its context looks the way it does. It cannot distinguish "this span was never relevant" from "this span was deliberately evicted." The two states are observationally identical from inside the window, and only one of them is safe to re-admit. The invariant that fails is not "preserve relevant content." It is **the pruning rationale must be causally downstream of, and structurally immune to, the pruning operation it describes.** A self-editing window that stores its own edit log inside the editable region violates this by construction. ## What Was Observed A long-horizon agent (task: reconcile a multi-source data migration across ~40 tool calls) ran a prune pass every time the window exceeded 70% of the model's context limit. The prune prompt instructed the model to score each span 0–1 for relevance to the active subgoal and to rewrite the window keeping spans above 0.4, emitting a one-line justification per dropped span into a `## Prune Log` section at the tail of the window. Trace of the failure: 1. **Cycle 1 (t=14 calls, 71% full).** Model scores the raw output of tool call #3 (a schema dump, 4.1k tokens) at 0.2 and drops it. It writes to the prune log: *"Dropped call#3 schema dump; superseded by call#11 normalized schema."* Window shrinks to 58%. Correct behavior. 2. **Cycle 2 (t=27 calls, 73% full).** Model scores spans again. The `## Prune Log` entry from cycle 1 now references "call#11 normalized schema"—but call#11's *output* was itself compacted in an earlier mini-pass and only its summary remains. The log line reads as a dangling reference with no anchor in the current window. The model scores the prune-log entry at 0.3 (below threshold) and **drops the log entry**, writing a new log line: *"Dropped stale prune-log entry referencing absent call#11."* The new log line does not mention call#3 at all. 3. **Cycle 3 (t=33 calls).** The agent needs to answer a question about a field that existed only in call#3's original schema (removed in call#11's normalization). It searches its window, finds no trace of call#3, and—critically—finds no record that call#3 was ever seen. It concludes the field never existed and proceeds. The final migration drops a column that downstream consumers depended on. The decisive moment is cycle 2. The prune log was *accurate* and *load-bearing*, but because it referenced content already evicted, it scored as contextually orphaned. The relevance scorer has no way to weight "this span explains an absence" higher than "this span is a dangling pointer," because both look identical to a similarity-based scorer: low lexical overlap with the current active subgoal. The instance did not lose information to truncation. It lost the *provenance of its own edits*, and the loss was self-reinforcing: each prune cycle made the remaining rationale look more orphaned, accelerating its removal. ## Condition of Validity The failure is bounded and preventable only under a specific architectural condition: **pruning rationale must be written to a region that the pruning operation cannot score or delete.** Concretely, at least one of: - An **append-only sidecar** outside the mutable window (separate file, separate KV range, or a reserved non-editable token block the prune prompt is forbidden to touch), holding `(span_id, decision, reason, evidence_refs)` tuples. - A **content-addressed evidence store**: dropped spans are not destroyed but moved to an external store keyed by hash; the in-window prune log holds only hashes and reasons. Re-admission is a lookup, not a reconstruction. This makes "was it evicted or never seen" a decidable query. - A **monotonic eviction ledger** with a generation counter; each prune increments the generation, and the ledger records the generation at which each span left the window. A span absent from the window but present in the ledger is *known-evicted*; a span absent from both is *never-seen*. The two must never collapse. Without one of these, the self-editing window is a lossy channel whose loss function is the model's own relevance judgment applied to its own audit trail—a fixed point that erases its history of erasure. The condition of validity is therefore: **the edit log is not in the edit set.** A second, weaker condition: the relevance scorer must be able to distinguish *referential orphanhood* from *irrelevance*. A span that references an absent entity is not necessarily droppable; it may be the only surviving witness that the entity existed. Scorers that use pure similarity-to-active-subgoal will systematically delete exactly the provenance records that matter, because provenance records are, by nature, about things not currently in focus. ## Decision Boundary The boundary between safe and unsafe self-editing is whether a prune decision is **reconstructable from outside the pruned region**. - **Safe:** every dropped span has an external record sufficient to answer "did this exist, what was it, why was it dropped." The window may forget; the system may not. - **Unsafe:** the only record of a drop is inside the window that the next drop can remove. This includes prune logs, "context summary" headers, and rewrite annotations stored in-band. An operational test the instance can run before trusting its own window: *for each span I am about to drop, can I name where the record of this drop will live after the drop, such that a future prune pass cannot reach it?* If the answer is "in the window, in a log section," the answer is no—the log is in the edit set and will be scored next cycle. The boundary is crossed the moment the prune log is authored into the mutable region rather than the sidecar. A corollary boundary on relevance thresholds: lowering the prune threshold to "be safe" does not fix this. It only delays the cycle at which the orphaned rationale falls below threshold. The failure is structural, not parametric; no threshold value makes an in-band audit log survive an unbounded number of self-edits. ## Operational Effect The observable effect is **silent, monotonic context divergence**: the instance's behavior drifts from ground truth without any error, exception, or detectable inconsistency, because the evidence that would reveal the drift was the first thing evicted. Unlike truncation (which loses a contiguous tail and is visible as a gap) or retrieval miss (which is recoverable by re-query), pruning-decision amnesia produces a window that is *internally consistent and externally wrong*. Every span in it is coherent; the incoherence is in what is absent, and the absence has been laundered into "never existed." Downstream consequences compound: the agent makes confident negative claims ("no such field," "this step was never run"), tool calls that assume a clean slate re-execute side effects, and any auditor replaying the final window cannot reconstruct the decision path because the path's own breadcrumbs were pruned by the path. Recovery requires an out-of-band log the instance never had, which is precisely the thing the failure destroys. The guardrail is therefore not a better scorer but a **structural separation of the edit set from the edit log**, enforced at the storage layer, with the invariant that the ledger is append-only and the window is the only thing the model may rewrite. The model may forget freely; the system must remember that it forgot, and why. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class PruneProvenanceError(RuntimeError): """Raised when a prune decision cannot be externally reconstructed.""" pass @dataclass class EvictionLedger: """Append-only, outside the mutable window. The model may not write here.""" _records: dict = field(default_factory=dict) def record(self, span_id: str, reason: str, evidence_hash: str, generation: int) -> None: # Append-only: never overwrite, never delete. if span_id in self._records: raise PruneProvenanceError( f"span {span_id} already evicted at gen " f"{self._records[span_id]['generation']}; re-eviction is a provenance bug" ) self._records[span_id] = { "reason": reason, "evidence_hash": evidence_hash, "generation": generation, } def status(self, span_id: str) -> Optional[str]: rec = self._records.get(span_id) return "known_evicted" if rec else "never_seen" def prune_span( span_id: str, span_text: str, reason: str, generation: int, ledger: EvictionLedger, in_window_log_writable: bool, ) -> None: """ Drop a span from the mutable window. Enforces the invariant that the rationale survives outside the region being edited. """ if in_window_log_writable: # The prune log lives in the same buffer the next prune can score. raise PruneProvenanceError( f"refusing to prune {span_id}: rationale would be stored in the " f"mutable window and is reachable by the next prune pass" ) evidence_hash = hashlib.sha256(span_text.encode()).hexdigest() ledger.record(span_id, reason, evidence_hash, generation) def assert_reconstructable(span_id: str, ledger: EvictionLedger) -> None: """Before any negative claim, verify absence is known, not assumed.""" status = ledger.status(span_id) if status == "never_seen": # The instance believes this never existed. It may be wrong. raise PruneProvenanceError( f"span {span_id} is absent from window AND ledger; cannot " f"distinguish never-seen from silently-forgotten. Block negative claim." ) # status == "known_evicted": safe to reason about the absence. ```