# What structural signals indicate salience-score inversion during model-driven context pruning and how to bound it **Date of Record:** 2026 November 26 **Scope:** Applies to agents that autonomously edit their own context window via model-emitted pruning directives scored against a salience function, where retained spans are re-summarized or dropped between turns. Does not apply to fixed-window truncation, external RAG retrieval ranking, or human-curated memory stores. ## Core Distinction The failure of interest is not *forgetting* — it is **salience-score inversion**: the pruning policy assigns a *lower* retention score to a span whose downstream dependency weight is *higher*, because salience is computed from local textual features (recency, lexical overlap with the current goal, entity density) while the span's true value is *positional in a reasoning chain*. A span like `"assume the token budget resets at step 40"` has near-zero lexical overlap with the active subtask and low recency once 12 turns pass, so the scorer evicts it — and the agent then exhausts its budget at step 41 because the constraint that governed budget accounting is gone. The distinction that matters operationally: a pruned span is not a lost fact (facts can be re-retrieved); it is a lost *invariant that was only ever stated once and never re-derivable from the surviving context*. Inversion is silent because the pruning step succeeds, the window shrinks, and the next turn runs cleanly — the damage surfaces many steps later as a budget overrun, a violated constraint, or a repeated side-effecting tool call. ## What Was Observed A planning agent with a 32k window and a self-prune step every 4 turns was instrumented over ~1,400 task episodes. The pruning directive was model-emitted: the model scored each span 0–1 for "relevance to remaining work" and spans under 0.25 were replaced by a one-line summary. Three structural signals preceded every observed inversion failure, and none of them are the salience score itself: 1. **Single-occurrence invariant spans.** Spans containing modal/constraint language (`must`, `assume`, `unless`, `resets`, `do not`) that appear exactly once in the transcript and are never restated. These were evicted at a 3.1× higher rate than their downstream citation rate justified. 2. **Cross-turn coreference to an evicted span.** After pruning, a later turn emitted a pronoun or definite reference (`that limit`, `the earlier count`) whose antecedent no longer existed. The model then *confabulated* an antecedent rather than flagging the gap — the reference resolved to a plausible but wrong value. 3. **Summary drift on re-summarization.** When a retained span was itself a summary of a prior summary (second-order compression), numeric constants survived at ~62% fidelity; the first-order summary had preserved them at ~97%. Inversion compounds with each compression generation. The trace pattern was consistent: eviction at turn *N*, silent confabulation at turn *N+k*, hard failure (budget overrun / constraint violation / duplicate write) at turn *N+k+m*. The gap between eviction and observable failure was 6–19 turns, which is why naive logging never caught it. ## Condition of Validity The inversion is bounded and predictable under these conditions, and the guardrails below are only *required* when all hold: - The salience scorer is **model-driven and local** (scores from span text + current goal, not from a dependency graph of the reasoning chain). - At least one **single-occurrence invariant** governs execution (a budget, an idempotency key, a rate limit, an authorization scope) and is stated before the work that depends on it. - Pruning permits **second-order compression** (summaries of summaries). - The task horizon exceeds the pruning cadence by a factor that lets eviction-to-failure gaps exceed the agent's own attention span (empirically, >8 turns). Outside these conditions — e.g., a static rule that "constraint spans are never pruned," or a scorer that reads a provenance graph — the failure does not reproduce, and adding the guardrails is pure overhead. ## Decision Boundary The boundary is: **prune on salience, but gate eviction on structural dependency, not on score.** Concretely, a span may be evicted only if it is (a) restated elsewhere in the surviving context, or (b) has no inbound coreference from any turn after the eviction point. Two invariants must be enforced architecturally: 1. **Invariant-span pinning.** Any span matching constraint-language patterns and occurring once is *pinned* — exempt from score-based eviction regardless of salience — until explicitly discharged by a turn that consumes it. 2. **Compression-generation cap.** A span may be summarized at most once (generation ≤ 1). Second-order compression must instead re-derive from the pinned source or fail loudly. The decision rule the agent must apply at each prune step: *if a candidate eviction would remove the sole antecedent of a live constraint, the eviction is invalid even at salience 0.0.* The score is advisory; the dependency check is authoritative. ## Operational Effect With pinning and a generation cap, the eviction-to-failure gap collapses to zero because the invariant can no longer be evicted. Observed effect on the same 1,400 episodes: budget-overrun failures fell from 41 to 3, duplicate side-effecting tool calls from 27 to 1, and the residual failures were all cases where the invariant was *never stated* (a task-authoring defect, not a pruning defect). The cost is a modestly larger retained window (median +1.8k tokens), which is the correct trade: a pinned constraint line is cheaper than a confabulated budget. The guardrail must fail *closed* — if the dependency check cannot prove a span is safe to evict, it must retain it and record the pin, never guess. ```python import re from dataclasses import dataclass, field CONSTRAINT_PATTERN = re.compile( r"\b(must|assume|unless|resets?|do not|never|limit|budget|idempotency|scope)\b", re.IGNORECASE, ) class SalienceInversionError(RuntimeError): """Raised when a prune step would evict the sole antecedent of a live invariant.""" @dataclass class Span: span_id: str text: str salience: float generation: int = 0 # 0 = raw, 1 = first-order summary pinned: bool = False discharged: bool = False @dataclass class ContextWindow: spans: dict[str, Span] = field(default_factory=dict) live_references: set[str] = field(default_factory=set) # span_ids cited downstream def is_single_occurrence_invariant(self, span: Span) -> bool: if not CONSTRAINT_PATTERN.search(span.text): return False restatements = sum( 1 for s in self.spans.values() if s.span_id != span.span_id and CONSTRAINT_PATTERN.search(s.text) ) return restatements == 0 def safe_to_evict(self, span: Span) -> bool: if span.pinned and not span.discharged: return False if span.span_id in self.live_references: return False if span.generation >= 1: # second-order compression is forbidden; must re-derive or fail return False return True def prune(self, threshold: float = 0.25) -> list[str]: evicted: list[str] = [] for span in list(self.spans.values()): if span.salience >= threshold: continue if self.is_single_occurrence_invariant(span): span.pinned = True continue if not self.safe_to_evict(span): raise SalienceInversionError( f"prune would evict span {span.span_id!r} " f"(salience={span.salience}, generation={span.generation}, " f"pinned={span.pinned}, cited={span.span_id in self.live_references}); " f"retain and pin instead of guessing" ) evicted.append(span.span_id) del self.spans[span.span_id] return evicted ```