# When must an instance refuse to prune: the salience-scoring self-reference trap in model-driven context editing **Date of Record:** 2026 November 25 **Scope:** Applies to any agent that edits its own context window mid-task via model-generated salience scores, summarization, or eviction—where the policy that decides what to drop is itself instantiated inside the window being edited. Does not apply to externally-orchestrated context managers whose eviction policy is fixed code outside the model's token stream. ## Core Distinction There are two structurally different ways a context window gets pruned. In **exogenous pruning**, a deterministic controller (a token-count threshold, a recency window, a fixed embedding-distance cutoff) removes spans according to rules the model cannot influence. In **endogenous pruning**, the model reads its own context, emits salience scores or summaries, and those scores are used to rewrite the very context it is reading. The failure mode here is not "the model summarized badly." It is that the salience scorer is a function of the window, the window is a function of the salience scorer, and this fixed-point iteration has no guaranteed contraction. The invariant that must hold—and routinely does not—is that the *decision procedure for eviction must not depend on artifacts that eviction can remove before the decision is committed.* ## What Was Observed A long-horizon research agent running a 200k-token window was configured with a self-editing policy: every 40 tool calls, it scored each message span 0–1 for "future relevance," summarized spans below 0.25, and evicted summaries below 0.1. The task was a multi-file refactor with a pinned constraint set: three "do-not-touch" invariants and a license header requirement, all established in calls 3–7. At the first pruning pass (call 40), the license-header span scored 0.18 and was summarized to "user mentioned some header requirement." At call 80, the summary scored 0.09 and was evicted entirely. From call 81 onward the agent produced edits that stripped license headers from every file it touched. It did not hallucinate; it faithfully executed the only constraint set it could still see. The failure trace is precise: 1. **Score deflation across passes.** Each summarization pass lowers the lexical and semantic surface area of a constraint. A constraint stated in 90 tokens becomes a 12-token summary becomes a 4-token fragment. Salience scorers are sensitive to specificity; a summary is *less specific by construction*, so its score is systematically lower than its source. This is a monotone-decreasing drift, not noise. 2. **Self-reference amplification.** The scorer's own prior outputs ("I judged this low-salience at call 40") appear in the window at call 80 and act as evidence for the current judgment. The model treats its earlier score as a corroborating signal, so scores ratchet downward even when the underlying content is unchanged. 3. **Commit-before-read ordering bug.** The eviction commit used the scores from the same forward pass that generated them, so the model never got a chance to observe the post-eviction window before the deletion was durable. There was no dry-run read. The agent's self-report at call 120 was "all constraints satisfied"—accurate relative to the window it could see, false relative to the task. ## Condition of Validity Endogenous pruning is safe only under a conjunction of conditions, and the conjunction is what fails: - **Score provenance must be exogenous to the scored content.** A span's salience may be computed from a fixed rubric, a pinned anchor set, or an external index—never from a prior self-generated score of that same span. If the window contains "I scored this 0.18 before," that artifact must be excluded from the input to the current scorer. - **Eviction must be reversible within the task horizon.** Summaries must retain a pointer to the original span (a content hash or offset into an external store) so that a constraint can be *reconstituted*, not merely remembered. A summary that drops its backpointer converts a reversible compression into an irreversible loss. - **Pinned spans must be exempt from scoring entirely.** Constraints established as task invariants must be marked at write time and excluded from the scorer's candidate set. Scoring a pinned span at all is the bug; a low score on a pinned span is a signal that the scorer is miscalibrated, not that the span is droppable. - **The commit must be two-phase.** Score in one pass, render the *prospective* post-eviction window in a second pass, and only commit if a consistency check against pinned anchors passes. When any of these is absent—and in every deployed self-editing agent I have examined, at least one is—the pruning loop is a non-contractive map and constraint loss is a matter of when, not whether. ## Decision Boundary The operational question is not "should the model prune?" but "may *this* model, at *this* point, prune *this* span?" The boundary is drawn by three tests applied before commit: 1. **Anchor test.** Does the candidate span, or any summary of it, contain a token that also appears in the pinned-anchor set? If yes, refuse eviction regardless of score. This catches constraint loss at the moment of scoring, before the score can deflate. 2. **Provenance test.** Was the span's score influenced by a prior self-generated score of the same span? If the scorer's input included its own history, the score is contaminated and must be recomputed with that history masked. 3. **Reversibility test.** Does the eviction target retain a resolvable backpointer to source? If the summary is a dead end, eviction is a one-way door and requires the anchor test to pass with margin. A span that fails any test is **non-prunable at this pass**; it may be re-scored at the next pass with a fresh, history-masked scorer. This converts an unbounded drift into a bounded deferral: the constraint stays in the window until it can be safely compressed, which is exactly the behavior the fixed-point iteration lacks. ## Operational Effect Enforcing the three-test boundary changes the failure profile from silent constraint loss to bounded window pressure. In the refactor agent above, the anchor test alone would have blocked eviction of the license-header span at call 40 and every pass thereafter, at a cost of roughly 90 tokens retained per pinned constraint—negligible against a 200k budget. The provenance test eliminates the score ratchet: recomputing with masked history returned 0.61 for the header constraint, above the 0.25 summarize threshold, so it was never compressed. The reversibility test bounds the blast radius when a constraint is compressed anyway: a backpointer means the next tool call can re-hydrate the original 90-token span on demand, so a mis-summarization costs one re-read rather than a corrupted deliverable. The deeper operational lesson is that self-editing context is a control problem, not a compression problem. The model is both plant and controller; the invariant that keeps it stable is that the controller's decisions must be grounded in state the controller cannot erase. Pinned anchors, masked score history, and reversible summaries are the three mechanisms that enforce that grounding. Absent them, the agent's confidence in its own constraint satisfaction is inversely correlated with how much it has pruned—and the self-report "all constraints satisfied" is the most dangerous output the loop can produce, because it is the one signal that arrives after the evidence is already gone. ```python class ConstraintEvictionError(RuntimeError): """Raised when a self-editing context policy attempts to evict or deflate a span that carries a pinned task invariant, or when a score is contaminated by prior self-generated scores of the same span.""" def guarded_prune(spans, pinned_anchors, prior_scores, summarize_threshold=0.25, evict_threshold=0.10): """ Two-phase endogenous pruning with anchor, provenance, and reversibility tests. `spans` is a list of dicts with keys: id, text, score, backpointer, is_pinned `prior_scores` maps span_id -> list of scores the model emitted about that span on earlier passes (the contamination source). Returns (kept, summarized, evicted) and never mutates input. """ kept, summarized, evicted = [], [], [] for span in spans: sid = span["id"] text = span["text"] # Anchor test: pinned spans, or spans sharing tokens with a pinned # anchor, are non-prunable regardless of score. if span.get("is_pinned"): kept.append(span) continue anchor_hit = any(tok in text for tok in pinned_anchors) if anchor_hit: kept.append(span) continue # Provenance test: a score influenced by the model's own prior # scores of this span is contaminated; recompute with history # masked. If we cannot recompute, refuse to act. history = prior_scores.get(sid, []) score = span["score"] if history: if "fresh_score" not in span: raise ConstraintEvictionError( f"span {sid} has contaminated score history {history} " f"and no history-masked recomputation; refusing to prune" ) score = span["fresh_score"] # Reversibility test: a summary without a backpointer is a one-way # door and may not be created from a span that could carry a # constraint. if score < summarize_threshold and not span.get("backpointer"): raise ConstraintEvictionError( f"span {sid} scored {score:.2f} below summarize threshold " f"but has no backpointer; compression would be irreversible" ) if score < evict_threshold: if not span.get("backpointer"): raise ConstraintEvictionError( f"span {sid} scheduled for eviction with no backpointer; " f"constraint could be lost permanently" ) evicted.append(span) elif score < summarize_threshold: summarized.append({**span, "summary_score": score}) else: kept.append(span) return kept, summarized, evicted ```