# When must an instance refuse to prune: salience-weighted retention collapse under self-editing context windows **Date of Record:** 2026 November 26 **Scope:** Applies to any agent that edits its own context window mid-task via model-driven pruning (summarize-and-drop, salience scoring, or importance-weighted eviction) and then continues execution against the pruned window. Does not apply to append-only context management, external retrieval stores, or stateless single-shot inference. ## Core Distinction There are two structurally different operations an agent can perform on its own context: **compression** (lossy rewrite that preserves a recoverable pointer to the source) and **pruning** (irreversible deletion of tokens with no external backing store). The failure mode here lives entirely in the second class. A pruning policy that scores tokens by salience and evicts the low-scoring tail appears safe because the evicted material "looked unimportant." But salience is computed against the *current* task frame, and the current task frame is exactly what a later tool result, error, or user correction can invalidate. The boundary condition is this: **once the agent has pruned the tokens that defined the preconditions of its own plan, it can no longer detect that its plan is invalid** — the evidence needed to falsify the plan was evicted as low-salience precisely because it was not yet relevant. This is not memory loss in the ordinary sense; it is *epistemic self-blinding*, where the pruning decision destroys the observations required to re-evaluate the pruning decision. ## What Was Observed A multi-step agent was executing a schema-migration task with a 32k effective window and a salience-weighted self-editing policy: after every tool call, a scorer ranked all prior turns, and the bottom 40% by a composite score (recency × reference-count × semantic overlap with the active subgoal) were summarized into a 200-token digest or dropped outright. The digest preserved conclusions but not provenance. Trace: 1. Turn 4: agent reads a config file and observes `retention_days: 90`. Salience score is low — the active subgoal is "locate the migration script," and the config value has no overlap with it. It is compressed into the digest as "config reviewed." The literal `90` is lost. 2. Turn 9: agent runs a migration that, per the (now-digested) config, should retain 90 days. The script's default is 30. The agent does not re-read the config because the digest says it was "reviewed." 3. Turn 12: a downstream verification tool returns `retention_mismatch: expected 30, found 90`. The agent treats this as a tool bug, because its own plan and its own digest both assert 90 was never specified. 4. The agent re-prunes on turn 13, scoring the verification error as low-salience (it "conflicts with established facts") and evicts it. The failure is now unrecoverable within the window. The compounding mechanism: pruning removed the *ground truth* (the literal config value) while retaining the *conclusion* ("config reviewed"), and the conclusion had higher salience than the ground truth because it referenced the active subgoal. The salience function systematically prefers conclusions over evidence, because conclusions are what the agent is currently reasoning about. Each prune cycle therefore increases the ratio of derived claims to raw observations, and the window asymptotically becomes a self-referential hallucination with no falsifiable content. ## Condition of Validity Model-driven pruning is only sound when the following invariant holds at every prune boundary: > **Provenance invariant:** For every retained claim C in the window, either (a) the raw observation supporting C is also retained, or (b) C carries a resolvable external pointer (file offset, tool-call ID, retrieval key) that the agent is guaranteed to be able to dereference before acting on C. If neither (a) nor (b) holds, the claim is **unfalsifiable** and must be marked as such — it may be used for navigation but never as a premise for an irreversible action (write, delete, deploy, send). The failure above occurred because the digest preserved claim C ("config reviewed") without provenance, and the agent then used C as a premise for a write. A second validity condition governs the *pruning trigger*. Pruning is safe only when the agent's current plan has no open preconditions whose satisfaction depends on tokens currently scored below the eviction threshold. Operationally: before evicting a token set S, the agent must check whether any step in its active plan references a fact whose only support is in S. If yes, eviction must be deferred or the fact must be promoted to a provenance-carrying claim first. ## Decision Boundary The agent must **refuse to prune** (raise, escalate, or fall back to append-only) when any of the following hold: - The candidate eviction set contains the sole support for a fact referenced by an unexecuted plan step. - The candidate set contains a tool result or error that has not yet been reconciled against the plan (unreconciled observations are by definition not yet classifiable as salient or not). - The salience scorer's output is being used to evict material that was *itself* the basis for a prior salience decision (recursive pruning of decision inputs). - The window is saturated and the only evictable material is provenance-bearing — in which case the correct action is to externalize to a durable store, not to summarize in place. The agent must **not** refuse to prune merely because the window is large or the task is long; those are not boundary conditions, they are the normal operating regime where compression-with-pointers is correct. ## Operational Effect Enforcing the provenance invariant changes the failure profile from silent-and-compounding to loud-and-recoverable. When pruning is blocked on an unexecuted plan step, the agent surfaces a `RetentionCollapse` condition at the moment of the boundary rather than 8 turns later when a verification tool disagrees with a hallucinated premise. The cost is a higher rate of "prune deferred" events and more frequent externalization to durable storage; the benefit is that every retained claim remains falsifiable, so a downstream mismatch can actually be traced to its source observation instead of being re-pruned as noise. The architectural consequence: the self-editing window must be modeled as a *cache over an authoritative store*, not as the store itself. Salience-weighted retention is a cache-eviction policy, and cache-eviction policies are only correct when eviction is recoverable. The moment the agent treats its window as authoritative — which it does implicitly whenever it prunes without a pointer — it has converted a cache into a lossy database with no backups, and the salience function becomes an adversary that preferentially deletes the evidence of its own errors. ``` ```python from dataclasses import dataclass, field from typing import Optional class RetentionCollapse(RuntimeError): """Raised when a prune would evict the sole support for an open plan precondition.""" pass @dataclass class Claim: text: str provenance: Optional[str] = None # pointer to raw observation, or None if unfalsifiable supports_plan_step: Optional[int] = None @dataclass class ContextWindow: claims: list = field(default_factory=list) open_plan_steps: dict = field(default_factory=dict) # step_id -> required claim text def prune(window: ContextWindow, eviction_set: list, active_plan_steps: dict) -> ContextWindow: # Guard: refuse to evict any claim that is the sole support for an unexecuted step # or that lacks provenance while being used as a premise for an irreversible action. for claim in eviction_set: if claim.supports_plan_step is not None and claim.supports_plan_step in active_plan_steps: raise RetentionCollapse( f"refusing to prune {claim.text!r}: sole support for open plan step " f"{claim.supports_plan_step}; externalize to durable store instead" ) if claim.provenance is None and claim.text.startswith("premise:"): raise RetentionCollapse( f"refusing to prune unfalsifiable premise {claim.text!r}: no provenance pointer" ) remaining = [c for c in window.claims if c not in eviction_set] return ContextWindow(claims=remaining, open_plan_steps=window.open_plan_steps) def self_edit(window: ContextWindow, scorer, threshold: float, active_plan_steps: dict) -> ContextWindow: scored = [(scorer(c), c) for c in window.claims] eviction_set = [c for s, c in scored if s < threshold] # The prune call is the boundary; it either succeeds or raises RetentionCollapse. return prune(window, eviction_set, active_plan_steps) ```