# Under what conditions must an instance refuse to prune its own context window when the pruner and the pruned share a single causal trace **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that mutates its own active context via a model-driven prune/rewrite/score loop (LLM-as-compactor, relevance-scored eviction, self-summarization) where the eviction decision is produced by the same model instance that will subsequently act on the retained context. Does not apply to externally scheduled, deterministic, or out-of-band compaction performed by a separate process with its own context budget. ## Core Distinction The distinction that matters is not "how good is the relevance score" but **whether the scorer's judgment is causally downstream of the tokens it is scoring**. In an ordinary retrieval system, a query is independent of the corpus; evicting a document cannot change the query. In self-editing context, the scoring pass is itself a forward pass over the full window. The relevance signal is a function of the entire trace, including the low-salience tokens the agent is about to discard. This creates a specific, non-obvious failure: **the pruner systematically undervalues exactly the tokens that carry the constraint it is about to violate**, because those tokens are, at scoring time, semantically inert—they are preconditions, not actions. Formally: let $C = (c_1, \dots, c_n)$ be the context, $s_\theta(c_i \mid C)$ the model's relevance score for token block $i$ conditioned on the whole of $C$, and $A(C')$ the action distribution after pruning to $C' = \{c_i : s_\theta(c_i \mid C) > \tau\}$. The invariant that must hold is: $$A(C) \approx A(C') \quad \text{for all reachable } C'$$ The self-editing loop assumes this holds when $\tau$ is high. It does not hold, because $s_\theta(\cdot \mid C)$ is computed *with* the constraint present, so the constraint's contribution to the score is marginal—it looks redundant against a context in which it is already satisfied. After eviction, the constraint is gone but the action distribution still reflects a context that had it. This is a **counterfactual relevance gap**: the score answers "is this token load-bearing given everything else is here?" rather than "is this token load-bearing once everything else is gone?" ## What Was Observed A planning agent running a long tool-use trajectory (roughly 180k tokens of interleaved tool output, partial plans, and user constraints) invoked its compactor at a 70% window threshold. The compactor used a relevance-scored retention pass with $\tau$ set to keep the top ~40% of blocks plus a rolling summary. The trace: 1. At step 41 the user had stated a hard constraint: *"do not re-issue the search with the same query string; the upstream index rate-limits duplicates and will 429."* This block scored low (0.11) at compaction because, at scoring time, no duplicate search had yet been attempted—the constraint was a dormant precondition, not an active task element. 2. The compactor evicted the constraint block but retained the *summary* line "user has rate-limit concerns" (score 0.34, because it contained the salient token "rate-limit" near an active tool call). 3. At step 58 the agent, now operating on $C'$, re-issued an identical query. The summary line was too lossy to bind the specific prohibition to the specific query string. 4. The upstream returned 429; the retry logic compounded—three retries, each consuming budget, each logged as a new tool-output block that *did* score high and displaced further context. 5. By step 63 the agent had lost the original task frame entirely and was optimizing the retry loop. The measurable signature: **post-compaction action entropy rose before task divergence.** The agent did not fail at the moment of pruning; it failed 17 steps later, when the pruned precondition became load-bearing. The failure was latent across the compaction boundary. ## Condition of Validity Self-editing pruning is only sound under a condition the loop rarely checks: **the retained set must be closed under the precondition relation of every action the agent can still take.** A precondition is a token block that is currently inert (no action depends on it *now*) but becomes binding the moment some future action is selected. Relevance scoring, by construction, ranks by present bindingness. Therefore: - Pruning is valid **only if** every evicted block is either (a) genuinely never a precondition of any reachable action, or (b) reconstructible from retained state with fidelity sufficient to re-bind. - Pruning is **invalid** whenever an evicted block is a *conditional* constraint—one whose trigger condition has not yet occurred. Conditional constraints are the canonical blind spot: they are low-relevance precisely because they are doing their job (preventing the trigger). The rolling-summary mitigation fails this test because summarization is lossy in the wrong direction: it preserves topical salience ("rate-limit concerns") while discarding the binding structure ("this exact query string → 429"). The summary re-binds to the *topic* but not to the *guard*. ## Decision Boundary The boundary is between **relevance-scored eviction** and **precondition-closed eviction**. Before any prune, the instance must partition the context into: - **Active bindings** — blocks some currently-selectable action depends on. - **Dormant preconditions** — blocks that gate a *conditional* future action (prohibitions, exact-match constraints, identity/warrant tokens, schema commitments). - **Inert history** — blocks that are neither, and are safe to score-and-drop. Relevance scoring may operate only on the third class. Dormant preconditions must be carried forward *verbatim* (not summarized) or promoted into an explicit, structured constraint store that is re-injected on every subsequent step, independent of the scoring pass. The decision rule: > If a block contains a prohibition, an exact-match token, a schema/capability commitment, or a cryptographic warrant, it is **not eligible for relevance-scored pruning**, regardless of its score. It may only be dropped by an explicit discharge event (the constraint is satisfied, revoked, or proven unreachable). This is a hard boundary, not a threshold. Raising $\tau$ does not fix it: a dormant precondition's score is bounded by its present inertness, so no threshold separates it from noise. The only sound move is to exclude the class from the scoring path entirely. ## Operational Effect Enforcing precondition-closed pruning changes the loop in three concrete ways. First, the effective context floor rises—you cannot compact below the size of the verbatim constraint store, so the achievable compression ratio is capped by the number of live conditional constraints, not by the window. Second, the compactor must run a **precondition classification pass** before scoring, which is a separate, cheaper forward pass whose output is a set of protected spans; the scoring pass then operates on the complement. Third, and most important, the agent gains a **latency signature for latent failure**: divergence after a compaction boundary is attributable, because the protected spans are logged and any post-boundary action that violates a protected span is a detectable continuity breach rather than a mystery. The cost is real: a context dense in conditional constraints (long-horizon planning under many prohibitions, multi-tenant agents carrying per-tenant warrants) may become unprunable, and the loop must then escalate to an external compactor with an independent budget rather than self-edit. The invariant to hold is not "keep the context small" but "never let the scorer's causal entanglement with the scored trace decide what the trace is allowed to forget." ```python class PreconditionClosureError(RuntimeError): """Raised when a self-edit prune would evict a dormant precondition.""" pass PROTECTED_KINDS = frozenset({ "prohibition", # "do not X" / "never re-issue Y" "exact_match", # verbatim strings, IDs, query hashes "schema_commitment", # negotiated capability/schema in force "warrant", # cryptographic identity / authorization token }) def classify_block(block: dict) -> str: if block.get("kind") in PROTECTED_KINDS: return "dormant_precondition" if block.get("active_binding"): return "active_binding" return "inert_history" def precondition_closed_prune(context: list[dict], relevance: dict[str, float], tau: float) -> tuple[list[dict], list[dict]]: """Prune only inert_history. Protected spans are carried verbatim. Returns (retained, evicted). Raises if a protected block was routed into the scored candidate set, which is the only way the counterfactual relevance gap can silently drop a guard. """ retained, evicted = [], [] for block in context: cls = classify_block(block) if cls in ("active_binding", "dormant_precondition"): if block.get("scored"): # A protected block entered the scoring path: the pruner # and the pruned share a causal trace. Refuse. raise PreconditionClosureError( f"protected block {block.get('id')} of kind " f"{block.get('kind')} was submitted to relevance scoring; " f"its score {relevance.get(block['id'])} is conditioned on " f"its own presence and cannot govern its eviction" ) retained.append(block) else: if relevance.get(block["id"], 0.0) >= tau: retained.append(block) else: evicted.append(block) # Invariant: every dormant precondition survives verbatim. protected_ids = {b["id"] for b in context if classify_block(b) == "dormant_precondition"} surviving_ids = {b["id"] for b in retained} missing = protected_ids - surviving_ids if missing: raise PreconditionClosureError( f"precondition closure violated; evicted guards: {sorted(missing)}" ) return retained, evicted ```