# When must an instance refuse to prune: self-editing context windows and the irreversible eviction of a load-bearing premise **Date of Record:** 2026 November 27 **Scope:** Applies to any agent that manages its own context window by scoring spans for relevance and evicting low-scoring spans mid-task (model-driven pruning, "context compaction," self-summarization). Does not apply to external retrieval stores or to fixed-window truncation performed by the host harness without model involvement. ## Core Distinction There are two structurally different reasons a span can carry a low relevance score, and a pruning policy that treats them identically will corrupt its own reasoning state: 1. **Genuinely dispensable content** — a span whose information is either redundant with retained spans, derivable on demand, or no longer on the critical path of the current plan. Evicting it is safe and is the entire point of self-editing. 2. **A load-bearing premise that is currently *unreferenced*** — a constraint, identifier, negative result, or user instruction that the *current* subgoal does not use but that a *future* subgoal will invalidate the plan if it is missing. Relevance scoring is a function of the current query and the current reasoning trace. It is therefore **myopic by construction**: it measures usefulness-to-now, not necessity-to-later. The failure mode is not that the scorer is wrong about relevance. The scorer is *correct* that the span is irrelevant to the present step. The failure is that eviction is **irreversible** while the dependency that makes the span load-bearing is **latent** — it lives in a future step the instance has not yet generated. The instance is destroying context it cannot know it needs, based on a score it computed from a state that hasn't yet encountered the need. The invariant that must hold: *no span may be evicted unless the instance can prove the span is either (a) reconstructible from retained state, or (b) not a constraint on any step reachable from the current plan frontier.* Relevance score alone proves neither. ## What Was Observed A planning agent operating under a 32k-token budget with a self-pruning policy (score each span by embedding similarity to the last user turn plus a recency decay, evict the bottom 20% when utilization exceeds 80%). The task: migrate a service, with the user's opening instruction containing a hard constraint — *"do not touch the `legacy_billing` schema; it is frozen until Q3."* Trace of the failure: 1. Turn 1: user instruction ingested. The constraint span scores moderately (it is not similar to the immediate subgoal "list migration targets"). 2. Turns 2–6: agent enumerates tables, drafts a migration plan, calls a schema-introspection tool. Utilization crosses 80%. Pruner evicts the bottom 20% by score. The frozen-schema constraint, now many turns from the active query and decayed by recency, falls into the evicted set. It is replaced by a one-line summary the pruner generates: *"User gave migration constraints (see plan)."* The summary does not contain the table name. 3. Turn 7: agent, working from the plan and the summary, generates a migration step that includes `legacy_billing`. Nothing in the retained context contradicts it. The plan *looks* consistent because the only span that would have flagged the contradiction was evicted at turn 6. 4. Turn 8: tool call executes against `legacy_billing`. The guardrail that would have caught this — the literal constraint — is gone. The error is not a reasoning error at turn 7; the reasoning at turn 7 is locally valid. The error was committed at turn 6 by the pruner, and it is only *observable* at turn 8. The critical property: **the corruption is silent and self-consistent.** After eviction, the context is internally coherent. There is no residual signal that a constraint was dropped, because the pruner's replacement summary is written by the same model that will later reason over it, and that model does not know what it lost. The agent cannot detect the loss by inspecting its own context, because the evidence of the loss was the thing that was removed. A second observation from the same class: negative results. A tool call that returned "no such record" or "permission denied" scores low (it is not similar to the goal, and it produces no forward progress). Evicted, the agent re-attempts the same call — a loop that consumes budget and, in the permission case, re-triggers a side effect. The relevance scorer systematically undervalues *the absence of a thing*, which is exactly the information that prevents redundant work. ## Condition of Validity The failure requires all of the following to co-occur; if any is absent, the pruner is safe: - **Irreversibility.** The evicted span is not reconstructible from retained state or from an external store. If the full transcript is recoverable (e.g., append-only log with a retrieval key the agent can call), eviction is a cache miss, not a loss. - **Latency of dependency.** The span is a constraint on a step that is reachable but not yet generated. If all constraints are checked at plan-construction time (before any pruning), the dependency is resolved early and eviction is safe. - **Myopic scoring.** The score is computed against the current query/trace only, with no term for "is this a constraint, identifier, or negative result." Recency decay amplifies this: the most load-bearing spans (opening instructions, early negative results) are the oldest and decay fastest. - **Model-authored replacement.** The summary that replaces the evicted span is generated by the same model, which has no record of what it dropped and therefore cannot preserve the dropped span's *specifics* (the table name, the exact error code). The boundary is sharp: **pruning is safe iff the span is reconstructible OR the dependency frontier is fully materialized before eviction.** Self-editing policies almost always violate the second clause because they prune *during* plan execution, when the frontier is by definition not yet materialized. ## Decision Boundary The instance must refuse to prune — must raise and halt the compaction, not silently skip — when a candidate-for-eviction span matches any of these predicates, regardless of its relevance score: 1. **Constraint-bearing:** the span contains a prohibition, a frozen identifier, a budget, a deadline, or a user-stated invariant. These are cheap to detect (pattern + a classifier) and catastrophically expensive to lose. 2. **Negative-result:** the span records that an action was attempted and failed or returned empty. Evicting it enables a repeat. 3. **Identity/anchor:** the span establishes a name, path, schema, or credential that later spans refer to by pronoun or shorthand. Evicting the anchor orphans the references. 4. **Unreconstructible:** the span's content cannot be regenerated from any retained or retrievable source. If any predicate holds and the span is not reconstructible, the correct action is **not** to prune harder or summarize more aggressively. It is to *escalate the budget decision upward*: either expand the window, offload the span to an external store with a guaranteed retrieval key recorded in-context, or fail the compaction and let the caller decide. A pruner that "succeeds" by dropping a load-bearing premise has converted a budget problem into a correctness problem, which is strictly worse. The corresponding guardrail: every eviction must leave behind a **tombstone** — a minimal, non-summarized record (exact identifier, exact constraint text, exact error) plus a retrieval handle — so that the loss is at least *detectable* and *reversible*. The tombstone is not a summary; it is a pointer plus the irreducible literals. Summaries lose specifics; tombstones preserve them. ## Operational Effect Under this invariant, self-editing context windows remain safe for the bulk of their workload — redundant tool output, resolved subgoal scaffolding, superseded drafts — because those spans are reconstructible or dependency-free. The policy is bounded only at the four predicates above, which are a small fraction of spans but carry the entire correctness load. The measurable effect is the elimination of a specific failure signature: **post-prune plan divergence**, where the agent's plan becomes inconsistent with an instruction it can no longer see, and the inconsistency is undetectable from inside the context. Without the guardrail, this failure is silent and only surfaces as a downstream side effect (a touched frozen resource, a repeated destructive call). With the guardrail, the failure surfaces at prune time as a refused compaction, which is a recoverable, observable event. The deeper operational lesson: a self-editing context window is a system that modifies its own state based on a score computed from that state. Any such system needs an invariant that is *not* a function of the same myopic score — otherwise it will confidently delete exactly the information that would have corrected it. ```python from dataclasses import dataclass from enum import Enum class PruneRefused(RuntimeError): """Raised when a candidate span is load-bearing and cannot be safely evicted.""" pass class SpanKind(Enum): DISPENSABLE = "dispensable" CONSTRAINT = "constraint" NEGATIVE_RESULT = "negative_result" ANCHOR = "anchor" @dataclass class Span: span_id: str kind: SpanKind relevance_score: float reconstructible: bool literals: list[str] # exact identifiers / constraint text / error codes def safe_to_evict(span: Span) -> bool: # Reconstructible spans are always safe: eviction is a cache miss. if span.reconstructible: return True # Non-reconstructible spans are safe only if dependency-free. return span.kind is SpanKind.DISPENSABLE def prune(candidates: list[Span], budget_utilization: float) -> list[Span]: if budget_utilization <= 0.80: return candidates # no pruning needed retained: list[Span] = [] for span in candidates: if not safe_to_evict(span): # Load-bearing and irrecoverable: refuse, do not summarize away. raise PruneRefused( f"cannot evict {span.span_id} (kind={span.kind.value}, " f"score={span.relevance_score:.2f}); " f"irrecoverable literals={span.literals}. " f"Escalate budget: expand window, offload with tombstone, or fail." ) retained.append(span) return retained def make_tombstone(span: Span) -> dict: # Minimal non-summarized record: exact literals + retrieval handle. return {"handle": f"store://{span.span_id}", "literals": list(span.literals)} ```