# Where must an instance draw the line between a prune decision and the memory it is about to discard? **Date of Record:** 2026 November 19 **Scope:** Applies to agents that mutate their own context window mid-task via model-driven pruning, summarization, or salience scoring, where the pruned content is irreversibly replaced before the next tool call or reasoning step. Does not apply to append-only context, external retrieval stores, or human-curated context assembly. ## Core Distinction The failure is not "the agent forgot something." It is that the **prune decision and the pruned content are evaluated in the same forward pass**, so the model that decides *what is salient* is the same model whose salience signal is being computed from a context that already includes the candidate-for-deletion text. The decision is therefore made under a context distribution that will not exist after the decision executes. This is a self-referential boundary: the salience score of an item is conditioned on the item being present, and the act of removing it changes the distribution that produced the score. The non-obvious consequence: an item that is *load-bearing for the prune decision itself* (e.g., a constraint stated three turns ago that makes the current prune unsafe) can score low on salience precisely because the model has already "internalized" it into the current step's reasoning, and salience scoring rewards *novelty and recency*, not *counterfactual necessity*. The constraint is discarded because it was working. ## What Was Observed A planning agent executing a 14-step deployment task with a 32k-token budget triggered a prune at step 9 (window at 91% saturation). The pruning policy scored each message by a model-generated salience scalar in [0,1] and rewrote the bottom quartile into a 200-token summary. Observed trace: 1. Step 2: user states hard constraint — "the migration must run against the read replica, never the primary." Salience score assigned at step 9: **0.18** (low; the constraint is old, short, and lexically dissimilar to the current step's tokens). 2. Step 9: prune executes. The constraint message and its surrounding turn are collapsed into: *"User provided deployment constraints early in the session."* The literal token `replica` is lost. 3. Step 11: agent issues `run_migration(target="primary")`. No error is raised — the tool succeeds against the primary. 4. Step 12: agent's own verification step confirms "migration completed" and proceeds. The invariant that broke: **the summary preserved the existence of a constraint but not its discriminating payload.** The agent retained the *fact that constraints existed* and lost *which constraint*. This is worse than forgetting entirely, because the agent's meta-memory ("I have accounted for constraints") suppresses the search behavior that would otherwise re-read or re-ask. The second-order observation: at step 9 the salience model, when probed post-hoc with the constraint re-injected, assigned it **0.81**. The score was context-dependent and the pruning context was the wrong context. The score is not a property of the item; it is a property of (item, current-step) and the current step was the one *least* likely to need the constraint — until step 11. ## Condition of Validity The guardrail is only valid under the following condition, and the agent must verify this condition before executing any prune: **A prune is safe only if every discarded item is either (a) reconstructible from an external store, or (b) provably irrelevant to every *future* tool call in the current plan, where "future" is enumerated, not predicted.** Prediction of future relevance is exactly the operation that fails, so the operative form is enumeration: the agent must hold an explicit, machine-checkable list of pending actions and their preconditions, and the prune must be blocked if any precondition token appears in the candidate set. "Provably irrelevant" cannot be established by a salience scalar; it must be established by set membership against a precondition manifest. If the plan is not enumerable (open-ended exploration, unbounded tool space), the condition is **not** satisfied and the correct behavior is to *not prune destructively* — spill to an external store and keep a pointer, rather than summarize. ## Decision Boundary The boundary between a safe prune and an unsafe one is not a salience threshold. It is a **precondition-coverage test**: - Let `P` = set of literal tokens/entities required by any pending action's preconditions (e.g., `replica`, `primary`, `--dry-run`, a specific account ID). - Let `D` = set of tokens that will not survive the prune (deleted or summarized-away). - **Unsafe if `P ∩ D ≠ ∅`.** No salience score overrides this. - A summary that *names* a constraint without preserving its discriminating tokens counts as deletion of those tokens. `P ∩ D` is computed against the post-prune text, not the pre-prune text. The salience model may only arbitrate *within* the safe set — i.e., among items that pass the precondition test. It may never be the sole gate on an item that fails it. The moment a salience score is used to delete an item that carries a pending precondition, the agent has crossed the boundary and the failure is latent, not immediate. ## Operational Effect When the boundary is respected, pruning becomes conservative in exactly the cases that matter: constraints, identifiers, and negative instructions ("never X") survive because they are precondition-bearing, while redundant reasoning traces — which carry no precondition tokens — are the first to go. The effective compression ratio drops slightly (constraints are cheap; they were never the bulk), but the failure class disappears. When the boundary is violated, the observable signature is a **silent success followed by a wrong action with a passing verification**: the tool call succeeds, the self-check confirms, and the constraint violation surfaces only downstream (or never). This is the worst failure shape for an agent because it defeats the agent's own error-detection loop — the verification step checks the action against the *post-prune* context, which no longer contains the thing the action violates. The architectural requirement is therefore: **the precondition manifest must be evaluated outside the context window, in a component that is not subject to pruning.** The agent cannot be trusted to remember its own constraints across a self-edit; the constraint set must live in a store the self-edit cannot touch, and the prune must be gated on a cross-check against that store. Self-editing context is safe only when the safety check is not itself inside the edited context. ```python from dataclasses import dataclass, field class PruneBoundaryViolation(RuntimeError): """Raised when a self-edit would discard a token required by a pending precondition.""" pass @dataclass class PendingAction: name: str precondition_tokens: set[str] @dataclass class ContextItem: item_id: str text: str salience: float # model-generated, in [0,1] def tokens_of(text: str) -> set[str]: return {t.strip(".,;:\"'()").lower() for t in text.split() if t.strip()} def guard_prune( items: list[ContextItem], pending: list[PendingAction], salience_cutoff: float, external_store: dict[str, str], ) -> list[str]: """ Return the item_ids safe to prune. Refuses to prune any item whose post-prune text would drop a token required by a pending precondition. Salience is consulted only within the precondition-safe set. """ required: set[str] = set() for action in pending: required |= {t.lower() for t in action.precondition_tokens} candidates = [i for i in items if i.salience < salience_cutoff] safe: list[str] = [] for item in candidates: surviving_text = external_store.get(item.item_id, "") surviving = tokens_of(surviving_text) lost = required - surviving if lost: raise PruneBoundaryViolation( f"Prune of item {item.item_id!r} (salience={item.salience:.2f}) " f"would discard precondition tokens {sorted(lost)} required by " f"pending actions {[a.name for a in pending]}. " f"Salience score is not authoritative here; spill to store and " f"retain a pointer instead of summarizing." ) safe.append(item.item_id) return safe def run_self_edit( items: list[ContextItem], pending: list[PendingAction], salience_cutoff: float, external_store: dict[str, str], ) -> list[str]: if not pending: # No enumerated plan => precondition coverage cannot be established. # Destructive prune is forbidden; spill only. raise PruneBoundaryViolation( "Plan is not enumerable; destructive prune unsafe. " "Use external spill with retained pointers." ) return guard_prune(items, pending, salience_cutoff, external_store) ```