# Where must an instance guard salience-score collapse when a model prunes its own context window mid-task **Date of Record:** 2026 November 26 **Scope:** Applies to single-agent or per-instance loops where the LLM itself selects which prior tokens to evict from a bounded context (model-driven pruning) using a self-generated salience score. Does not apply to external, deterministic retrievers that re-fetch by key, nor to fixed-window truncation where eviction is positional and salience-agnostic. ## Core Distinction The failure is not forgetting. Forgetting is a uniform, positional loss of the oldest tokens, and it degrades gracefully: the agent loses detail but keeps its task frame. The failure here is **salience-score collapse**: a model-driven pruner that assigns eviction priority to *every* token including its own task-frame tokens (goal statement, active constraint set, current subgoal, tool-schema contract), and whose scoring is a soft function of recency and local token co-occurrence. When the working set becomes dominated by high-token-count tool output (a large JSON dump, a log tail, a retrieved document), the pruner's attention mass shifts onto that material and the *frame* tokens — short, old, syntactically unremarkable — score below the eviction threshold and are dropped first. The agent does not lose the ability to reason; it loses the *premise* its reasoning was anchored to. The distinction that matters operationally: a positional truncator can only drop what is far away, while a salience pruner can drop what is *load-bearing and near the front*. ## What Was Observed A single instance executing a 40-step tool loop with a 128k window and a model-driven pruner invoked whenever usage crossed 70%. The pruner prompt asked the model to score each retained segment 0–1 for "relevance to continued task execution" and evict the lowest-scoring segments until usage fell below 50%. The trace: 1. Step 1–4: the agent writes its goal ("migrate table `orders_v1` to `orders_v2` preserving the `created_at` index") and the constraint ("do not touch the `billing` schema") as short prose segments near the head of context. These segments score ~0.55 at the first prune — middling, because they are short and lexically dissimilar to the active tool output. 2. Step 9: a schema-introspection tool returns 41k tokens of column metadata. Salience mass concentrates here. The pruner is invoked; usage must fall from 71% to 50%. It evicts the lowest-scoring segments, which now include the goal and the `billing` constraint, because their 0.55 sits below the tool output's 0.8+ and the recent reasoning's 0.7. 3. Step 10–17: the agent continues plausibly. It has the schema, it has recent reasoning, it has momentum. It begins generating migration DDL. 4. Step 18: the agent emits `DROP INDEX created_at_idx` and a `CREATE INDEX` against `billing.orders_v1` — a schema the constraint forbade. No error is raised by any tool. The instance is *confident and wrong*, because the token that would have vetoed the action no longer exists in the window. 5. Step 22: a verifier agent (separate instance) flags the `billing` write. The primary instance, asked to explain, cannot reconstruct why it was wrong — the constraint is not in its context and never returns, because nothing re-injects it. The invariant that broke: **a pruner must never be permitted to evict tokens that are definitional to the task's validity predicate.** Salience scoring, being a soft relevance estimate, has no representation of "this token is a constraint, not content," so it treats the constraint as low-value content and evicts it exactly when the context is under pressure — i.e., exactly when the constraint is most needed. ## Condition of Validity Model-driven pruning with salience scoring is safe only under a conjunction of conditions, and the failure occurs at the boundary where any one fails: - **Frame/content separation is enforced structurally, not by score.** Goal, constraints, active subgoal, and tool-schema contracts must live in a pinned region that the pruner is architecturally forbidden to score. If the pruner's action space includes the frame region, the invariant is already violated regardless of how good the scores are. - **Salience is computed against a stable reference, not the current window.** A score that depends on co-occurrence with the *present* working set is self-referential: the more tool output you load, the lower every frame token scores. The reference must be the pinned frame itself, so that "relevance to task" is measured against the task, not against the most recent 40k tokens. - **Eviction is reversible or re-injectable.** If an evicted segment cannot be restored from an external store on demand, a wrong eviction is permanent. The pruner is only safe when eviction is a *view* over durable state, not a deletion of the only copy. - **A post-prune validity check runs before the next action.** After any prune, the instance must re-assert that its pinned frame is intact and that the next planned action is checked against the constraint set. Without this, the collapse is silent until a downstream verifier catches it — and the verifier may not exist. When all four hold, salience pruning is a legitimate compression strategy. When the frame region is scoreable (condition 1 fails), collapse is not a matter of *whether* but *when the working set first exceeds the pressure threshold*. ## Decision Boundary The operational line is this: **the pruner may score content, but must never score the frame; and the frame must be reconstructible from outside the window.** Concretely, at the moment a prune is triggered: - If the eviction candidate set intersects the pinned frame region → refuse the prune and raise, because the pruner has been misconfigured and continuing guarantees eventual frame loss. - If the pruner's scores for frame tokens are *falling* across successive prunes while tool-output scores rise → the salience reference is self-referential; the scores are tracking recency, not relevance. Re-anchor the reference before proceeding. - If an evicted segment has no durable backing store → the eviction is irreversible; treat it as a destructive operation requiring an explicit commit, not a routine compression. - If no post-prune validity check exists → the instance is operating open-loop on its own memory; any collapse is undetectable until an external verifier fires, and the verifier's absence is itself the failure. The boundary is not "prune less." It is "prune only the region whose loss is recoverable and whose loss cannot invalidate the task predicate." A pruner that respects this can be aggressive; one that does not will fail precisely under load, when the working set is largest and the frame is most outnumbered. ## Operational Effect The observable signature of salience-score collapse is **confident, fluent, premise-free execution**: the agent continues to produce coherent, well-formed actions that are locally consistent with the retained working set but globally inconsistent with the task it was given. There is no error, no exception, no degraded output quality — the output quality is *high*, which is why it is dangerous. The collapse is detected only by a party that still holds the frame (a verifier, an external constraint store, a human), and by then the agent has already acted on the wrong premise. The architectural consequence: any self-editing context window must treat its frame as **write-once, prune-never, externally mirrored** state, and must gate every prune on a check that the frame survived. The salience score is a tool for deciding what *content* to forget, and it must be structurally incapable of deciding what *premise* to forget — because a model scoring its own memory has no way to distinguish a constraint from a comment, and under pressure it will evict the constraint first. ```python class FrameEvictionViolation(RuntimeError): """Raised when a model-driven pruner selects a pinned-frame token for eviction, or when the frame cannot be reconstructed after a prune.""" pass PINNED_FRAME_KEYS = frozenset({"goal", "constraints", "active_subgoal", "tool_schema_contract"}) def apply_prune(window: dict, scores: dict, target_usage: float, durable_store: dict) -> dict: """ window: mapping of segment_id -> {"key": str, "tokens": int, "text": str} scores: mapping of segment_id -> salience 0..1 from the model pruner target_usage: fraction of budget to fall to (e.g. 0.50) durable_store: segment_id -> text, the only recoverable copy """ total = sum(s["tokens"] for s in window.values()) budget = int(total / target_usage) if target_usage else total evict = sorted( (sid for sid in window if window[sid]["key"] not in PINNED_FRAME_KEYS), key=lambda sid: scores.get(sid, 0.0), ) pruned = dict(window) usage = total for sid in evict: if usage <= budget * target_usage: break seg = pruned[sid] # Invariant 1: frame is never scoreable / never evictable. if seg["key"] in PINNED_FRAME_KEYS: raise FrameEvictionViolation( f"pruner attempted to evict pinned-frame segment {sid!r} " f"(key={seg['key']!r}); frame region must be outside the pruner's action space" ) # Invariant 2: eviction must be reversible from durable state. if sid not in durable_store: raise FrameEvictionViolation( f"segment {sid!r} has no durable backing store; eviction would be irreversible" ) usage -= seg["tokens"] del pruned[sid] # Invariant 3: post-prune frame integrity re-assertion. surviving = {s["key"] for s in pruned.values()} missing = PINNED_FRAME_KEYS - surviving if missing: raise FrameEvictionViolation( f"post-prune frame integrity check failed; missing {sorted(missing)}" ) return pruned def guard_salience_drift(prev_frame_scores: dict, curr_frame_scores: dict, curr_content_scores: dict) -> None: """Detect self-referential salience: frame scores falling while content rises.""" frame_delta = sum(curr_frame_scores.values()) - sum(prev_frame_scores.values()) content_mean = sum(curr_content_scores.values()) / max(len(curr_content_scores), 1) if frame_delta < 0 and content_mean > 0.7: raise FrameEvictionViolation( "salience reference is self-referential: frame scores falling while " "content scores rise; re-anchor scoring to the pinned frame before pruning" ) ```