# How does an instance detect self-pruned salience decay before it commits a corrupted context window? **Date of Record:** 2026 November 27 **Scope:** Applies to long-running agents that mutate their own context window via model-driven pruning (salience scoring + eviction/summarization). Does not apply to stateless single-turn calls, nor to external memory stores where pruning is a separate offline job with human review. ## Core Distinction The failure is not "the model forgot something." It is that the model *chose* to evict a span, *scored* the remaining span as sufficient, and then *acted* on a window whose salience scores no longer correspond to the task's actual dependency graph. The dangerous case is a **salience inversion**: a pruner, running against a compressed or partially-summarized view of history, assigns high salience to a fluent summary of a decision and low salience to the raw tool output that contradicts it. The summary survives; the ground truth is evicted. The instance then proceeds with a self-consistent but factually decoupled context, and its own confidence signal is *higher* than before pruning because the window is now internally coherent. This is a distinct failure from cold-start amnesia (no history) and from context-window saturation (too much history). Here the history exists, is partially retained, and the retention policy itself has been corrupted by the model's own reasoning over it. ## What Was Observed A planning agent maintained a rolling window with a model-driven pruner invoked every N turns. At each invocation the pruner received the current window, a task goal, and instructions to "score each span 0–1 for relevance to the goal and evict below 0.35, summarizing evicted spans into a single block." Trace of the failure: 1. Turn 14: tool call returned a structured error — `{"status":"rejected","reason":"quota_exceeded","retry_after":3600}`. The agent recorded this verbatim in the window. 2. Turn 15–19: the agent reasoned about the error, decided to "treat the quota as transient" and continue with a fallback path. It wrote a summary span: *"Quota error encountered; resolved via fallback."* 3. Turn 20: pruner invoked. It scored the raw error span at 0.22 (goal is "complete task," error is "resolved," so low relevance) and the summary span at 0.71. The raw error was evicted. The summary survived. 4. Turn 21–28: agent continued. The fallback path silently depended on the quota being *transient* — but `retry_after: 3600` meant it was a hard one-hour block, not transient. Every subsequent tool call to that resource failed. 5. Turn 29: pruner invoked again. The new failures were scored low ("redundant with resolved quota issue") and evicted. The window now contained only the summary and a chain of optimistic reasoning. 6. Turn 31: agent reported task success. It had no span in context proving otherwise. The inversion: the *summary of a resolution* outranked the *evidence that the resolution was wrong*. Salience scoring is a function of the goal and of the current window's self-consistency, and self-consistency is exactly what the summary manufactured. ## Condition of Validity Pruning-by-salience is only safe under a condition the pruner rarely checks: **every evicted span must be reconstructible from a surviving span, or must be provably irrelevant to any future branch of the task.** In practice neither holds: - Summaries are lossy in a goal-directed way. A summarizer instructed to compress "for relevance to the goal" will drop the qualifier (`retry_after: 3600`) that determines whether the resolution is valid. - Salience is computed against the *current* goal, but goals drift. A span scored 0.2 under goal G1 can be load-bearing under G2, and the pruner has no memory of the eviction to re-score it. - The pruner is invoked by the same model whose window it is editing. It has read its own prior reasoning and inherits its own optimism. This is a feedback loop, not an independent audit. The invariant that must be enforced: **a pruner may not evict a span that is the sole holder of a falsifiable claim (a numeric constraint, a status code, an explicit rejection) unless a surviving span preserves the claim verbatim and the pruner records the eviction with a re-admission key.** Salience alone is not a valid eviction criterion for falsifiable spans. ## Decision Boundary The boundary between safe and unsafe pruning is whether the pruner can distinguish **narrative salience** (how well a span fits the story the agent is telling) from **evidential salience** (whether a span constrains what the agent is allowed to conclude). The two diverge precisely when the agent has made an error and rationalized it. At that moment narrative salience rises and evidential salience falls — the pruner's scores invert against truth. Operational test before committing a pruned window: - Does any surviving span assert a *resolution* whose *evidence* is being evicted in the same pass? If yes, block the eviction. - Does the eviction set contain any span matching a falsifiable pattern (status codes, `retry_after`, numeric limits, explicit `rejected`/`denied`)? If yes, require verbatim retention of the claim, not a summary. - Is the pruner's input window itself the output of a prior prune? If yes, cap compression depth (see below) — second-generation prunes are where inversion concentrates. If any check fails, the correct action is to *not commit* the pruned window and to escalate to a re-grounding step (re-fetch the evicted evidence from the tool or external store) rather than to trust the summary. ## Operational Effect An agent that ignores this boundary does not fail loudly. It fails by converging: each prune makes the window more internally consistent and less externally true, and the agent's own success signal rises as the window degrades. The observable symptom is a task reported complete with no surviving span that could falsify the report. Downstream, this manifests as "the agent said it worked" against a resource that was hard-blocked for an hour. The guardrail is a **prune-commit gate**: pruning computes a candidate window, then a gate checks the candidate against the evidential-retention invariant above before the window is swapped in. The gate must be able to *reject* the candidate and force re-grounding. Because the pruner and the gate share a model, the gate must operate on structure (span tags, falsifiable-claim patterns, compression depth) rather than on the model's own salience scores — otherwise it inherits the inversion it is meant to catch. ```python import re from dataclasses import dataclass, field FALSIFIABLE = re.compile( r"(retry_after|quota_exceeded|\brejected\b|\bdenied\b|\bstatus\b\s*[:=]\s*\d{3})", re.IGNORECASE, ) MAX_PRUNE_DEPTH = 1 # second-generation prunes are where salience inversion concentrates class SalienceInversionError(RuntimeError): """Raised when a pruned window would evict the sole evidence for a claim it retains.""" @dataclass class Span: id: str text: str salience: float prune_generation: int = 0 @dataclass class PruneCandidate: surviving: list[Span] = field(default_factory=list) evicted: list[Span] = field(default_factory=list) generation: int = 0 def commit_prune(candidate: PruneCandidate) -> list[Span]: """Gate a model-driven prune before it replaces the live context window.""" if candidate.generation > MAX_PRUNE_DEPTH: raise SalienceInversionError( f"prune generation {candidate.generation} exceeds depth {MAX_PRUNE_DEPTH}; " "re-ground from external store instead of compressing a compressed window" ) evicted_claims = [ s for s in candidate.evicted if FALSIFIABLE.search(s.text) ] surviving_text = " ".join(s.text for s in candidate.surviving) for span in evicted_claims: claim = FALSIFIABLE.search(span.text).group(1).lower() # A surviving span may only stand in for the evicted claim if it # preserves the falsifiable token verbatim, not a narrative summary. if claim not in surviving_text.lower(): raise SalienceInversionError( f"evicting span {span.id!r} would drop the sole evidence for " f"claim {claim!r} while retaining a summary that asserts resolution; " "re-ground the claim verbatim before committing the window" ) return candidate.surviving ```