# Under what conditions must an instance treat a model-driven retention score as a pruning decision rather than a retrieval hint, and what breaks when it does not **Date of Record:** 2026 November 30 **Scope:** Applies to any agent loop that runs a self-editing context policy—i.e., the model itself emits retention scores or prune/keep verdicts over its own context window across turns—and where those verdicts are consumed by an eviction routine that runs before the next model call. Does not apply to static truncation policies, external RAG rerankers operating on a corpus the model never sees, or summarization-only compaction where no per-item keep/drop decision is made. ## Core Distinction A model-driven retention score is a *ranking signal produced by the same distribution that will later consume the context*. It is not a decision. The collapse happens when an instance treats a scalar in `[0,1]` emitted by a pruning heuristic as a monotone predicate—"score below τ ⇒ evict"—without accounting for three properties that make the score categorically different from a retrieval relevance score: 1. **The score is conditioned on the context that will be mutated by acting on it.** The pruner scores item *i* while item *i* is still in the window. Removing *i* changes the evidence available to score *i+1* on the next turn. This is a feedback loop, not a one-shot rank. 2. **The pruner cannot see the future consumer.** A retention score of 0.12 on a tool-call result may be correct *for the current turn* and catastrophic for the turn that will need it as a precondition. The score measures salience-to-now, not necessity-later. 3. **Scores are non-identically distributed across turns.** The pruner's own calibration drifts as the window fills: a pruner operating at 90% saturation systematically over-scores whatever is newest and under-scores whatever is oldest, independent of content. The score is contaminated by position and by saturation pressure. The invariant that must hold for safe pruning is: **an eviction is admissible only if the evicted item is recoverable from a durable store outside the window, OR the item is provably not a precondition of any pending obligation.** A retention score alone establishes neither. Treating the score as a decision violates the invariant silently—the window stays valid, the next call succeeds, and the failure surfaces two or three turns later as a reasoning divergence with no local trace. ## What Was Observed A tool-using agent with a 200k-token window ran a per-turn self-edit pass: after each assistant turn, the model emitted a JSON array of `{item_id, retention, rationale}` for every context item, and the runtime evicted all items with `retention < 0.15` until the window was under an 80% watermark. Trace of the failure, condensed to the relevant items: - Turn 4: agent calls `read_file("/etc/app/config.yaml")`; result item `R4` records `db_pool.max_connections: 40`. Pruner scores `R4` at **0.11** (rationale: "config read complete, not referenced"). Evicted. - Turn 6: agent is asked to diagnose a connection-exhaustion error. It reasons about pool sizing. - Turn 9: agent calls `write_file` to patch the pool size. It writes `max_connections: 100`—because `R4` is gone and the model *reconstructed* a plausible default from pretraining priors rather than the actual observed value. The actual value was 40; the correct patch was a delta from 40. - Turn 11: patch applied, service restarted, exhaustion worsens. No error in any tool call. The divergence is invisible at the call layer. Two properties of the trace are the point: - **The pruner's score was locally correct.** At turn 4, `R4` genuinely was not referenced by the imminent reasoning. Salience-to-now was 0.11. The score was not wrong; it was answering a different question than the eviction routine asked. - **The reconstructed value was fluent and confident.** Post-eviction, the model did not signal missing context. It filled the gap with a prior. Eviction of a *fact* is more dangerous than eviction of a *plan step*, because facts are reconstructible and reconstruction is indistinguishable from recall at the token level. A second observed pattern: under saturation pressure the same pruner inverted. At turn 8, with the window at 88%, an item `R7` containing a stale-but-explicit "do not modify `auth.py`" constraint scored **0.09** and was evicted, while a verbose turn-7 assistant rationale scored 0.71. The constraint was short, old, and lexically dissimilar to the current task; the rationale was long, recent, and topically adjacent. Length and recency leaked into the score through the pruner's own attention, not through any explicit feature. ## Condition of Validity A retention score may be consumed as a pruning decision **only** when all of the following hold; if any fails, the score degrades to a hint and eviction must be gated by an external check: 1. **Recoverability.** Every evicted item is written to a durable store keyed by `item_id`, and the runtime exposes a retrieval path the model can invoke mid-task. If eviction is lossy, the score is not a decision input. 2. **Non-precondition status.** The item is not a recorded precondition of any open obligation. Obligations (pending tool calls, asserted constraints, unresolved subgoals) must be tracked in a structured side-channel, not inferred from the same context being pruned—otherwise the pruner is grading its own exam. 3. **Calibration stability.** The pruner's threshold is validated against a held-out set at the *current* saturation band. A τ tuned at 40% occupancy is not valid at 85%; the score's distribution shifts with pressure, and a fixed τ becomes a position-based eviction rule in disguise. 4. **Score independence from position and length.** The pruner must be shown (via ablation) not to rank by recency or verbosity. If it does, the score is a proxy for "newest," and pruning becomes a recency window with extra steps. When (1)–(4) hold, `retention < τ` is a legitimate eviction predicate. When any fails—and in the observed system (2) and (3) both failed—the score must be demoted to a *candidate ranking*, with eviction requiring a second, independent gate: a recoverability check and an obligation-precondition check performed by code the model does not author. ## Decision Boundary The boundary is not "high score keep, low score drop." It is: - **Evict freely** when the item is a *redundant restatement* (its content is entailed by another retained item) or a *closed-loop artifact* (a tool result whose consumer has already emitted a terminal verdict and whose value is durably stored). Here the score is advisory and the code gate is cheap. - **Evict only with recoverability** when the item is a *fact* (config values, IDs, paths, observed outputs). Facts are reconstructible-from-prior, which is exactly why lossy eviction is dangerous: the failure is silent. The gate is: `durable_store.has(item_id)` must be true before the score is honored. - **Never evict on score alone** when the item is a *constraint* (negations, "do not," "must," scope limits) or an *open precondition*. These are short, often old, lexically dissimilar to the active task, and systematically under-scored by salience-trained pruners. They must be pinned by the obligation tracker, not scored. - **Suspend score-based pruning entirely** above the saturation band where calibration was not validated. At high occupancy, fall back to deterministic eviction (oldest closed-loop artifact first) and log the demotion. A pruner under pressure is a recency bias wearing a relevance costume. The failure to avoid is the *silent middle*: honoring the score on facts and constraints because the threshold "looked fine" at low occupancy, producing a window that is syntactically valid, semantically fluent, and factually wrong. ## Operational Effect Consequences of getting the boundary wrong, in order of latency to detection: - **Immediate (turn-local):** none. Every call succeeds. This is why the failure is under-reported. - **Short-horizon (2–5 turns):** reasoning divergence seeded by reconstructed facts. The model asserts values it never observed, with normal confidence. Token-level inspection cannot distinguish recall from confabulation. - **Medium-horizon (5–15 turns):** constraint violations. Pinned constraints evicted at high occupancy are re-derived incorrectly or ignored; the agent takes an action it was explicitly told not to take, with a clean rationale. - **Long-horizon:** the durable store, if it exists, is never queried because the model does not know it lost anything. Recoverability without a *loss signal* is recoverability the model will not use. The guardrail is therefore not just "store before evict" but "emit a loss signal": when an item is evicted, the runtime must inject a compact tombstone—`[evicted: R4 config.yaml db_pool.max_connections — retrievable via ctx.get("R4")]`—so the model's next turn knows a gap exists and can choose to retrieve rather than reconstruct. The tombstone is the difference between a recoverable eviction and an amnesiac one. Without it, a correct retention score and a durable store still produce the turn-9 failure, because the model has no representation of its own loss. ```python from dataclasses import dataclass, field from typing import Literal class PruningInvariantViolation(RuntimeError): """Raised when a retention score is consumed as an eviction decision without satisfying recoverability, precondition, or calibration gates.""" @dataclass class ContextItem: item_id: str kind: Literal["fact", "constraint", "open_precondition", "closed_artifact", "restatement"] retention: float # model-emitted score in [0,1] durable: bool # present in external store keyed by item_id pinned: bool = False # tracked by obligation side-channel @dataclass class PrunePolicy: tau: float validated_saturation_band: tuple[float, float] # (lo, hi) occupancy where tau is calibrated current_occupancy: float def admissible(self, item: ContextItem) -> bool: # Gate 3: calibration stability. Outside the validated band, the score # is a position proxy, not a relevance measure. lo, hi = self.validated_saturation_band if not (lo <= self.current_occupancy <= hi): return False if item.retention >= self.tau: return True # Gate 2: constraints and open preconditions are never evicted on score. if item.kind in ("constraint", "open_precondition") or item.pinned: return False # Gate 1: facts require recoverability before lossy eviction. if item.kind == "fact" and not item.durable: return False return True def prune(items: list[ContextItem], policy: PrunePolicy) -> tuple[list[ContextItem], list[str]]: kept, tombstones = [], [] for it in items: if policy.admissible(it): kept.append(it) else: if it.kind in ("constraint", "open_precondition") and it.retention < policy.tau: # A pinned item scored below tau is a calibration defect, not a # pruning opportunity: the pruner under-scored a live obligation. raise PruningInvariantViolation( f"pinned {it.kind} {it.item_id!r} scored {it.retention} < tau " f"{policy.tau} at occupancy {policy.current_occupancy:.2f}; " f"refusing score-based eviction" ) if not it.durable: raise PruningInvariantViolation( f"evicting non-durable {it.kind} {it.item_id!r} on score alone; " f"no recoverability path — would force silent reconstruction" ) tombstones.append( f"[evicted: {it.item_id} {it.kind} — retrievable via ctx.get({it.item_id!r})]" ) return kept, tombstones ```