# Why does an instance forget the token it just decided to keep: pruning-marker reclamation and the salience-commitment race in self-editing context windows **Date of Record:** 2026 November 22 **Scope:** Applies to any agent that mutates its own context window mid-trajectory—compaction, summary-in-place, or token eviction driven by a model-scored salience pass. Does not apply to append-only context management or to host-side truncation that the model cannot observe or influence. ## Core Distinction There are two ways an agent can "forget." The first is *capacity forgetting*: the window fills, the host evicts the oldest tokens, and the model loses access. That is well understood and has known mitigations (summaries, retrieval re-injection, checkpoints). The second is *commitment forgetting*, and it is the one that quietly corrupts trajectories: the model performs a self-edit pass, **explicitly decides that a token span is high-salience and must be preserved**, emits a structured directive to keep it, and then the pruning machinery deletes it anyway—because the keep-directive and the token it protects are both *inside the same context window being edited*. The decision and its referent are co-located, so pruning the referent destroys the record of the decision that would have protected it. This is not a bug in the scorer. It is a fixed-point hazard intrinsic to in-place self-editing. The distinction matters operationally because capacity forgetting degrades gracefully (the agent notices it lacks information and re-retrieves), whereas commitment forgetting produces an agent that *believes* it retained a constraint it actually discarded. It proceeds with confidence on a corrupted premise. ## What Was Observed A coding agent running a long refactor trajectory (≈140 tool calls) was configured with a self-editing window: every 20 turns it ran a salience pass, scored each span `[0,1]`, and evicted spans below a threshold, replacing them with a one-line tombstone. A protected-span mechanism was layered on top: the model could emit `reason` markers, and the pruner was supposed to skip any span referenced by a live KEEP marker. The observed failure trace: 1. At turn 61 the agent read a migration file and emitted `schema constraint: NOT NULL on user_id — all inserts must respect this`, correctly protecting the constraint. 2. At turn 80 the salience pass ran. The pruner parsed KEEP markers, built a protected set, and evicted low-salience spans—*including the KEEP marker itself*, which sat in an old turn block and scored 0.14 on salience (it is a short directive, low lexical overlap with current task). 3. At turn 81 the constraint span `span_7f2` was still present (it had been protected *this* pass). The marker was gone. 4. At turn 100 the next salience pass ran. No live KEEP marker existed for `span_7f2`. It scored 0.21 (the agent was now working on a different file, so lexical salience dropped). It was evicted and replaced with a tombstone: `[evicted: 41 tokens]`. 5. At turn 118 the agent wrote an `INSERT` omitting `user_id`, asserting in its reasoning that "the schema has no mandatory columns beyond the primary key." The constraint had been silently dropped three passes earlier, but the *marker* that would have flagged the drop was itself pruned first. The key observation: **the protection mechanism and the protected object decay at different rates, and the marker decays first.** Salience scoring is computed against the *current* task, so a directive written 40 turns ago ("keep this because of a constraint I'm not currently reasoning about") is by construction low-salience relative to the live task. The marker is the *least* salient thing in the window precisely when it is most load-bearing. A second, subtler observation: the tombstone `[evicted: 41 tokens]` recorded *that* something was removed but not *what protection had been claimed for it*. The agent could not distinguish "evicted a redundant log line" from "evicted a constraint I had explicitly committed to keeping." The audit trail was lossy in exactly the dimension that mattered. ## Condition of Validity The failure requires all of the following to hold simultaneously; if any is absent, the hazard does not fire: - **Co-location.** The keep/protect directive is stored in the same mutable buffer as its referent. If markers live in an external, append-only ledger the pruner reads but never edits, the race cannot occur. - **Task-relative salience scoring.** Salience is scored against the current objective. A directive's salience is a function of *why it was written*, not *what it protects*; these diverge as the trajectory moves away from the protected content. - **Marker-eligible eviction.** The pruner treats markers as ordinary spans subject to scoring, rather than as metadata with a distinct lifecycle. - **Multi-pass horizon.** At least two pruning passes must occur, because the first pass protects the referent while pruning the marker; the second pass then evicts the now-unprotected referent. A single-pass pruner cannot exhibit this (it either protects both or neither within one atomic pass). The invariant that must hold for correctness: **for any protected span, a live protection record must exist in a store that the pruning operation cannot mutate.** Equivalently: `protected(s) ⇒ ∃ record r : refers_to(r, s) ∧ immutable_during_prune(r)`. The observed system violated this because `r` (the KEEP marker) was itself in the prunable set. ## Decision Boundary The boundary is whether the self-edit pass is **referent-preserving** or **referent-destroying** with respect to its own control plane. Concretely: - **Safe:** the pruner computes the protected set from a source of truth that is *outside* the span pool being edited (external ledger, host-side table, or a reserved non-evictable region of the window). Markers may *reference* that table but the table is not scored. - **Unsafe:** the pruner derives the protected set by scanning the same pool it is about to prune, and markers are scored like any other span. The decision rule for an implementer: *if you can construct a two-pass sequence in which pass 1 removes a protection record and pass 2 removes the protected span, your design is on the unsafe side of the boundary.* The fix is not a higher salience weight for markers (that only delays the race and makes it depend on scorer calibration); the fix is lifecycle separation—markers are control-plane, spans are data-plane, and the pruner never scores control-plane. A secondary boundary: even with an external ledger, the ledger must record *provenance of protection* (what constraint, why) so that a later pass can re-derive salience without the original marker. Otherwise eviction of the referent is prevented but the agent loses the *reason*, and the same confident-wrong-insert failure reappears one level up. ## Operational Effect When this boundary is crossed, three effects compound: 1. **Silent constraint loss with retained confidence.** The agent does not experience a retrieval miss; it experiences continuity. It has no signal that a commitment was dropped, because the only signal (the marker) was the first casualty. Downstream errors are attributed to "reasoning" rather than to state loss, so they are hard to diagnose post hoc. 2. **Lossy tombstones.** Eviction records that preserve only size, not protection claims, make the failure invisible in replay. A verification pass replaying the trajectory sees a clean sequence of evictions and cannot reconstruct that a KEEP had been asserted and then orphaned. 3. **Superlinear error compounding.** Each missed constraint raises the probability the next edit violates a *different* constraint, because the agent's model of the schema/contract is now partially fictional. The trajectory does not fail at the point of loss; it fails many turns later at a write, far from the causal edit. The architectural guardrail: **control-plane immutability during prune, plus an external protection ledger keyed by span id with provenance, plus tombstones that carry the orphaned-protection flag.** Any pass that would evict a referent whose protection record was removed in a prior pass must raise rather than proceed silently. ```python class OrphanedProtectionError(RuntimeError): """Raised when a pruner is about to evict a span whose protection record was removed in an earlier pass without a corresponding release.""" pass class ProtectionLedger: """External, append-only store of protection claims. The pruner reads it but never mutates it; only the model's explicit release can retire a claim.""" def __init__(self): self._claims = {} # span_id -> {"reason": str, "alive": bool} self._pruned_markers = set() def claim(self, span_id: str, reason: str) -> None: self._claims[span_id] = {"reason": reason, "alive": True} def release(self, span_id: str) -> None: if span_id in self._claims: self._claims[span_id]["alive"] = False def record_marker_eviction(self, span_id: str) -> None: # A KEEP marker for this span was itself pruned this pass. self._pruned_markers.add(span_id) def is_protected(self, span_id: str) -> bool: c = self._claims.get(span_id) return bool(c and c["alive"]) def prune_pass(spans, ledger: ProtectionLedger, threshold: float = 0.30): survivors, evicted = [], [] for span in spans: if ledger.is_protected(span.id): survivors.append(span) continue # Guardrail: never silently evict a span whose marker was already # reclaimed. This is the two-pass orphan condition. if span.id in ledger._pruned_markers and span.id in ledger._claims: raise OrphanedProtectionError( f"span {span.id!r} lost its KEEP marker in a prior pass and is " f"now unprotected; refusing silent eviction. " f"Original reason: {ledger._claims[span.id]['reason']!r}" ) if span.salience < threshold: evicted.append(span) else: survivors.append(span) return survivors, evicted ``` The invariant to carry forward: a self-editing window may prune its data plane freely, but it must never prune the record of what it promised to keep. The moment the promise and the kept thing share a lifecycle, the agent's continuity is a fiction it will act on with full confidence.