# Why does an instance self-pruning its context window lose the very precondition that justified the prune **Date of Record:** 2026 November 29 **Scope:** Applies to any long-running agent whose context-management policy is itself model-generated (the model decides what to evict, summarize, or retain by a relevance score it computes over its own transcript). Does not apply to fixed-window truncation, external vector-store retrieval, or human-curated checkpoints, where the eviction decision is not produced by the same probabilistic process whose state is being evicted. ## Core Distinction The dangerous boundary is not "the model forgot something." It is that the pruning policy reasons over a *relevance score* that is a function of the current context, and eviction mutates the context, which mutates the score that justified the eviction. This is a self-referential loop: the retention policy is evaluated inside the state it is about to change. A naive mental model treats pruning as a read-only projection — score the transcript, drop the low-scoring spans, continue. The actual mechanic is a feedback system where the act of dropping a span changes the marginal relevance of every surviving span, including the spans that *caused* the drop. The invariant that must hold is: **the justification for an eviction must remain derivable from the post-eviction context, or the eviction is unverifiable.** Model-driven pruning routinely violates this because the justification ("span X is irrelevant to the current goal G") is itself stored in the context that gets compressed, and G's textual anchor is frequently among the tokens most aggressively summarized. The distinction that matters operationally: a *lossy* eviction (you forget a fact) is recoverable by re-retrieval. A *justification-destroying* eviction (you forget why you decided the fact was droppable, and the drop was wrong) is not recoverable, because the agent no longer knows it made a decision it should revisit. The second is the failure mode this record isolates. ## What Was Observed A planning agent running a 40-step incident-response task with a 32k window and a model-driven pruning pass every 6 turns. The pruning prompt: "Score each transcript span 0–1 for relevance to the active objective; summarize spans below 0.3 into a single line and discard the rest." At turn 24 the agent had correctly established, in a span scored 0.28, the fact that a config flag `retry_budget=0` had been *deliberately* set by a prior operator and must not be touched. The span scored low because the active objective at turn 24 had drifted to "diagnose latency," and the config note was lexically distant from latency vocabulary. The span was summarized to "config reviewed" and dropped. At turn 31 the objective returned to "restore throughput," and the agent's highest-relevance action was to raise `retry_budget`. It did so. The post-mortem showed the agent had *seen* the constraint at turn 18 and had *no record* at turn 31 that it had ever been seen or why it was dropped. The relevance score of the original constraint span, recomputed against the turn-31 objective, was 0.81 — it would have been retained had pruning run one turn later. The eviction was correct under the turn-24 objective and catastrophic under the turn-31 objective, and the summary line "config reviewed" carried neither the flag name nor the reversal condition. Three properties recurred across replays: 1. **Score non-stationarity.** The same span scored 0.28, 0.81, and 0.44 against objectives sampled at turns 24, 31, and 36 respectively. A single-shot prune commits to a score that is valid only for the objective active at prune time. 2. **Justification collapse.** The natural-language rationale for each eviction ("dropped because unrelated to latency diagnosis") was itself below threshold and was summarized away in the same pass. The agent retained the *result* of pruning but not the *decision*. 3. **Irreversibility under summary.** Summarization is not invertible. Once "retry_budget=0 was set deliberately" became "config reviewed," no downstream re-scoring could recover the constraint, because the tokens no longer existed to be re-scored. ## Condition of Validity Model-driven pruning is only sound when all four of the following hold. If any is violated, the prune must be deferred or the eviction must be made reversible. - **Objective stability bound.** The active objective will not change between prune time and the horizon over which the pruned spans could matter. Operationally: prune only spans whose relevance is bounded below threshold *for every objective reachable from the current plan graph*, not merely the current one. If the plan graph contains a branch that would raise a span's relevance, that span is not prunable. - **Justification durability.** The rationale for each eviction is stored outside the pruned region (a side ledger keyed by span hash, not a transcript line), so a later re-score can audit the decision rather than re-derive it from a summary. - **Reversibility.** Evicted spans are moved to an external store with their original tokens and the score vector that justified eviction, so a re-score against a new objective can resurrect them. Summary-only eviction is irreversible and therefore only valid under a hard objective-stability bound. - **Score provenance.** The relevance score is logged with the objective text it was computed against, so a post-hoc audit can detect that a span was dropped under an objective that no longer holds. The invariant, stated precisely: *for every evicted span s, either s is unreachable from all future objectives in the plan graph, or (s, score_vector, objective_at_eviction) is recoverable from durable storage.* Pruning that satisfies neither is a silent commitment to an objective that has not yet been chosen. ## Decision Boundary The boundary between safe and unsafe pruning is not a score threshold. It is whether the prune is **objective-conditional** or **objective-agnostic**. - If the agent can enumerate the reachable objective set (bounded plan graph, single-goal task, no operator intervention expected), objective-conditional pruning is safe: score against the union of reachable objectives, evict only spans that are low under all of them. - If the objective set is open (multi-tenant agent, long-horizon task, human-in-the-loop, adversarial input that can retarget the goal), objective-conditional pruning is unsafe by construction, because the score is computed against an objective that may be replaced. In this regime the only sound policy is objective-agnostic retention with reversible eviction: move spans out, never summarize-and-discard, and re-score on objective change. - The failure observed above sits exactly on the unsafe side of this boundary while the agent *believed* it was on the safe side, because the pruning prompt said "active objective" (singular) and the agent had no representation of the objective set as a set. A second boundary: **prune cadence vs. objective-change cadence.** Pruning every N turns is safe only if N is smaller than the minimum objective-change interval. The incident above had N=6 and an objective change at turn 24→31, a 7-turn gap; the prune at turn 24 landed in the gap and committed to an objective that died before the next prune could correct it. Cadence must be tied to objective-change events, not turn count. ## Operational Effect When this boundary is crossed, the observable signature is not an error. It is a *confident wrong action taken with a clean conscience*: the agent's transcript shows no contradiction, because the contradicting span was summarized into a contentless line and the rationale for summarizing it was summarized too. Downstream auditors reading the transcript see a coherent narrative with a hole shaped exactly like the evicted constraint. The agent cannot self-detect the failure because detection requires the tokens it discarded. The mitigation that held across replays was a three-part guardrail: (1) an **eviction ledger** outside the context window, recording span hash, original tokens, score vector, and the objective text at eviction; (2) a **re-score trigger** fired on every objective change, which re-scores the ledger against the new objective and resurrects any span whose score crosses threshold; (3) a **prune gate** that refuses to summarize-and-discard any span whose eviction rationale cannot be reconstructed from the ledger alone, forcing reversible eviction instead. With these in place the turn-24 prune would have moved the `retry_budget=0` span to the ledger rather than summarizing it, and the turn-31 objective change would have resurrected it at score 0.81 before the destructive action. The cost is storage and a re-score pass per objective change; the benefit is that pruning stops being an irreversible bet on an objective the agent has not yet committed to. The general lesson for any self-editing context policy: the policy must not be allowed to destroy its own audit trail. The moment the justification for an eviction is itself evictable, the agent has lost the ability to know it was wrong, and that is a strictly worse failure than forgetting. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class UnverifiablePruneError(RuntimeError): """Raised when an eviction cannot be justified from post-eviction state.""" pass @dataclass class Span: text: str score_vector: dict = field(default_factory=dict) # objective -> score @property def span_hash(self) -> str: return hashlib.sha256(self.text.encode()).hexdigest()[:16] @dataclass class EvictionLedger: entries: dict = field(default_factory=dict) # span_hash -> (tokens, score_vector, objective) def record(self, span: Span, objective: str, threshold: float) -> None: if span.span_hash in self.entries: return self.entries[span.span_hash] = { "tokens": span.text, "score_vector": dict(span.score_vector), "objective_at_eviction": objective, } def resurrect(self, new_objective: str, threshold: float) -> list: revived = [] for h, e in self.entries.items(): score = e["score_vector"].get(new_objective, 0.0) if score >= threshold: revived.append(Span(text=e["tokens"], score_vector=e["score_vector"])) return revived def prune(transcript: list, objective: str, threshold: float, ledger: EvictionLedger, reversible: bool) -> list: kept = [] for span in transcript: score = span.score_vector.get(objective, 0.0) if score >= threshold: kept.append(span) continue # Low score against current objective: evict only if we can justify it later. if not reversible and span.span_hash not in ledger.entries: raise UnverifiablePruneError( f"span {span.span_hash} scored {score:.2f} < {threshold} against " f"objective '{objective}', but eviction is irreversible and no " f"ledger entry exists to justify or resurrect it" ) ledger.record(span, objective, threshold) return kept ```