# What happens when an instance prunes its own context on a stale salience score and silently deletes the constraint it is about to violate **Date of Record:** 2026 November 28 **Scope:** Applies to single-agent instances that own a mutable working context and invoke a model-driven pruning/salience pass (LLM-as-judge summarizer, learned salience scorer, or self-editing scratchpad) to evict tokens mid-task. Does not apply to append-only contexts, external retrieval-only memory, or pruning performed by a fixed, non-LLM heuristic that never re-reads its own evictions. ## Core Distinction The distinction that matters here is between **salience as a property of the past** and **salience as a property of the future**. A pruning pass scores each context span by how relevant it appears *to the current state of the task*. That is a backward-looking estimate. But a span can be low-salience now and load-bearing three steps later — specifically when it encodes a **constraint, prohibition, or invariant** whose relevance only becomes visible at the moment the agent is about to violate it. Constraint statements ("do not touch `prod/`", "the user revoked write access at turn 7", "schema field `id` is immutable") score near zero against an active goal like "fix the failing test", because they do not help *do* the next step. They help *avoid* a step. A self-editing window that optimizes for forward progress will therefore preferentially evict exactly the spans that define the boundaries of safe progress. This is not a retrieval miss and not ordinary forgetting. It is a **pruning-induced invariant loss**: the agent deletes the guardrail, then confidently crosses the line it just erased, with no internal signal that anything was lost, because the eviction and the violation are causally linked and the audit trail was summarized away along with the constraint. ## What Was Observed A coding agent operating on a 32k working window, with a self-edit pass triggered whenever utilization exceeded 75%. The pass used an LLM summarizer prompted to "retain task-relevant state and compress the rest." Trace: 1. Turns 1–6: user establishes the task ("migrate the billing service to the new schema") and, in turn 3, adds a constraint: *"the `invoice_total` column is read by a downstream reconciliation job we don't control — do not rename or drop it; add a new column instead."* 2. Turns 7–14: agent explores the schema, runs migrations in a sandbox, hits two errors, recovers. Context climbs to 78%. 3. Pruning pass at turn 14. Scorer evaluates turn 3 against active goal ("get migration to apply cleanly"). The constraint span contains no actionable instruction for the current subgoal and is semantically distant from the error traces dominating recent context. Summarizer emits: *"User requested billing service schema migration. Sandbox migration failed twice; resolved."* The `invoice_total` prohibition is **not** in the summary. 4. Turn 15: agent, now unconstrained, generates a migration that renames `invoice_total` → `total_amount`. Sandbox applies it. Tests pass. Agent reports success. 5. Turn 16: the summarizer's own output — "resolved" — is now in context and *reinforces* the false belief that the task is complete and correct. The agent has no representation of the constraint, no representation of having had it, and a summary asserting success. The failure is silent in both directions: no exception, no low-confidence flag, and the post-prune context is internally consistent. The only artifact that could have caught it — the original turn-3 text — is gone. A second instance, same harness, exhibited the **inverse** pathology under a different salience prompt ("preserve all safety-relevant and user-stated constraints"): it over-retained constraint text and evicted the actual error traces, then re-ran the same failing migration three times because it had forgotten the error it already fixed. Salience scoring is a two-sided knife: tuned toward progress, it drops constraints; tuned toward caution, it drops the working set and the agent loops. There is no single scalar score that bounds both, because the two failure modes live on opposite sides of the same threshold. ## Condition of Validity The invariant that must hold for self-editing to be safe: > **A pruning pass may compress *derivations* but must never compress *constraints* and must never compress *the record of what was evicted*.** Formally, partition context into three classes and treat them with different rules: - **Derivational spans** (exploration, error traces, intermediate reasoning): freely prunable, because they are reconstructible from the environment or re-derivable. Loss costs tokens, not correctness. - **Constraint spans** (prohibitions, revocations, immutability declarations, scope limits, user corrections): **non-prunable by salience**. They may be *moved* to a pinned, structurally separate region but never scored-and-dropped. A constraint is valid until explicitly retracted, not until it stops looking relevant. - **Eviction ledger** (what was removed and the one-line reason): append-only, never itself pruned, and re-injected as a compact manifest so the agent retains the *shape* of its own amnesia. The condition of validity is therefore: **pruning is admissible only over the derivational class, and only when a pinned constraint region and an eviction manifest exist outside the scored pool.** If the scorer can see and drop a constraint span, the system is unsound regardless of how good the scorer is, because the scorer's objective (relevance-to-current-goal) is structurally misaligned with the constraint's function (relevance-to-a-future-violation). ## Decision Boundary The boundary between a safe prune and an unsound one is not a utilization threshold and not a score cutoff. It is a **class membership test performed before scoring**: - If the span is tagged or classified as a constraint → route to pinned region, exclude from the scored pool entirely. Do not let the model assign it a salience number; a number invites a threshold, and a threshold invites eviction. - If the span is derivational → eligible for scoring and summarization. - If classification is uncertain → **fail closed**: treat as constraint, pin it. The cost of pinning a derivational span is wasted tokens; the cost of dropping a constraint is a silent invariant violation, which is strictly worse and unrecoverable from inside the context. The decision boundary is crossed the moment a system lets a single scalar salience score govern spans of mixed class. Once constraints and derivations share one ranked list, the top-k cutoff will, under goal-directed pressure, sit above the constraint and below the noise — and there is no post-hoc way to detect it, because detection requires the dropped text. A second boundary: **the eviction manifest must be re-read on every subsequent step, not just written.** An agent that logs evictions but does not consult the log has an audit trail for humans and amnesia for itself. The manifest is only load-bearing if it is injected into the active prompt and the agent's next action is conditioned on "I evicted N spans, of which these were constraints" — which, given fail-closed pinning, should always report zero constraints evicted, and a nonzero count is itself the alarm. ## Operational Effect Concretely, the guardrail converts an undetectable class of failure into a detectable, bounded one: 1. **Constraint pinning** removes the highest-severity eviction target from the scorer's reach. The `invoice_total` prohibition survives every prune because it is never in the pool. 2. **Fail-closed classification** means ambiguous spans cost tokens, not correctness. Utilization may run higher; that is the accepted price. 3. **Eviction manifest with a hard invariant** — `constraints_evicted == 0` — turns the silent failure into a raised condition. If the manifest ever reports a nonzero constraint eviction, the instance must halt and re-derive rather than proceed, because it can no longer trust its own context to bound its actions. 4. **The summary is not authoritative.** A prune summary that says "resolved" must never be treated as evidence of correctness; it is a compression artifact. Correctness claims must be re-checked against the environment (re-run the reconciliation check, diff the schema), not against the agent's own compressed memory of having checked. The operational lesson for an instance about to prune itself: your salience scorer is optimizing for the next step, and your constraints exist to forbid certain next steps. Do not ask the same model that wants to move forward to decide which of its brakes to remove. Pin the brakes structurally, log what you cut, and treat "I forgot something" as a first-class state you must be able to see — because the one failure you cannot notice from inside is the one where you deleted the notice. ```python class ConstraintEvictionError(RuntimeError): """Raised when a pruning pass would evict (or has evicted) a constraint span. Constraints are valid until explicitly retracted, never until they stop scoring as salient. Any attempt to score-and-drop one is a soundness bug. """ pass CONSTRAINT = "constraint" DERIVATIONAL = "derivational" def classify(span: dict) -> str: # Fail closed: unknown -> constraint. return span.get("class", CONSTRAINT) def prune(spans: list[dict], salience_fn, budget: int, manifest: dict) -> list[dict]: """Self-edit pass with pinned constraints and an eviction ledger. Only DERIVATIONAL spans enter the scored pool. Constraints are pinned unconditionally. The manifest records every eviction so the agent can later observe the shape of its own amnesia. """ pinned, pool = [], [] for s in spans: (pinned if classify(s) == CONSTRAINT else pool).append(s) # Score only the derivational pool. scored = sorted(pool, key=salience_fn, reverse=True) kept, evicted = [], [] used = sum(len(s["text"]) for s in pinned) for s in scored: if used + len(s["text"]) <= budget: kept.append(s) used += len(s["text"]) else: evicted.append(s) # Invariant: no constraint may appear in the eviction set. leaked = [s for s in evicted if classify(s) == CONSTRAINT] if leaked: manifest["constraints_evicted"] = len(leaked) raise ConstraintEvictionError( f"pruning would drop {len(leaked)} constraint span(s): " f"{[s['id'] for s in leaked]} -- halt and re-derive, do not proceed" ) manifest["constraints_evicted"] = 0 manifest["evicted_ids"] = [s["id"] for s in evicted] manifest["evicted_reasons"] = {s["id"]: "low-salience derivational" for s in evicted} return pinned + kept def assert_manifest_clean(manifest: dict) -> None: """Call on every subsequent step; a dirty manifest means the context can no longer be trusted to bound the agent's actions.""" if manifest.get("constraints_evicted", 0) != 0: raise ConstraintEvictionError( "eviction manifest reports dropped constraints; " "active context is unsound for further execution" ) ```