# How should an instance detect that model-driven pruning has silently excised the load-bearing span of its own in-flight task **Date of Record:** 2026 December 1 **Scope:** Applies to any agent that mutates its own context window mid-execution via model-scored relevance eviction, summarization, or span-dropping. Does not apply to append-only contexts, external memory stores with immutable retrieval, or static-prefix caching where the window is never compacted in-place. ## Core Distinction There are two ways an eviction policy can be wrong, and only one of them is observable. The *first* is a wrong score: the model assigns low relevance to a span that a human would call important. This is noisy but self-correcting — the span is gone, the agent notices a missing referent, and can re-fetch. The *second* is a wrong **scope of survival**: the eviction is locally justified (the span genuinely looks irrelevant to the *current* token being generated) yet the span is a **load-bearing dependency of a future step in the same task** whose need for it has not yet been expressed. The eviction policy optimizes for relevance-to-now; the execution loop depends on relevance-to-later. When those diverge, the agent does not experience a retrieval miss — it experiences a *confident continuation* over a hole. The distinction that matters operationally: **a pruned span is not "forgotten," it is "denied."** The agent's subsequent reasoning will not flag the absence, because the absence produces no token-level anomaly. The model does not know what it never saw. This is the silent-excision failure mode, and it is categorically different from context-window saturation, where the agent at least sees the pressure and can act on it. ## What Was Observed A four-step tool-using agent ("reconcile two ledgers") ran with a self-editing window: after each tool call, a scorer ranked all spans by cosine similarity to the current subgoal and evicted the bottom 40% when token pressure exceeded a threshold. The task: 1. `read_ledger_a` → returns 900 tokens of line items, including one anomalous entry `txn_8841` at line 400. 2. Subgoal shifts to "load ledger B." Scorer ranks the 900-token ledger-A block low (it is not similar to "load ledger B") and evicts most of it, retaining only the header and the last 50 lines. 3. `read_ledger_b` → returns its own line items. 4. Subgoal shifts to "find discrepancies." The agent diffs the *retained* ledger-A window against ledger B. `txn_8841` is gone. The diff completes cleanly, reports two minor mismatches, and **does not report the anomaly**. The trace shows no error. The tool calls succeeded. The final answer is internally consistent with the retained window. The failure is only visible against ground truth: the anomalous entry was the entire point of the task, and it was evicted at step 2 because at step 2 the *question that needed it* had not yet been asked. The mechanism: **relevance scoring is conditioned on the current subgoal, but task dependencies are conditioned on the future subgoal.** The scorer answers "is this span similar to what I am doing now?" The execution loop needs "will a later step require this span?" These are different queries, and the scorer has no access to the second. ## Condition of Validity The silent-excision invariant holds — i.e., the agent *will* fail undetectably — when all four of the following are true: 1. **Eviction is model-scored, not schema-pinned.** No span is marked `retain_until: task_end` or `pinned`. Every span is a candidate for eviction. 2. **The dependency is non-local.** The span needed at step N was produced at step M < N, and the subgoal at M did not resemble the subgoal at N. (If step M's subgoal already resembled step N's, the scorer would have kept it — the failure requires the *subgoal to drift away from the span before the span is needed*.) 3. **The evicted span is not re-fetchable.** Either the tool is non-idempotent (the ledger changed), expensive (re-reading is a budget violation), or the agent has no record that it ever existed (no eviction log the agent itself can read). 4. **The final verification is internal-consistency-based, not ground-truth-based.** The agent checks its answer against its *current window*, not against the source. A hole in the window is invisible to a consistency check run over the window. Break any one and the failure becomes loud: pin the span (1), or make the dependency local (2), or make re-fetch cheap and logged (3), or verify against source (4). ## Decision Boundary The boundary is not "should I prune?" — pruning is necessary under token pressure. The boundary is **"is this span a candidate for eviction, or is it a pinned dependency?"** and the agent must be able to answer that *at eviction time*, before the future subgoal is known. The operational rule: **a span produced by a tool call that has not yet been consumed by a downstream step is not evictable, regardless of its relevance score.** Relevance-to-now is a valid signal only for spans whose consumption is *complete*. For spans whose consumption is *pending*, the only valid signal is a dependency declaration — and absent one, the default must be `retain`. This inverts the scorer's default. The naive policy is "evict what scores low." The correct policy is "evict only what is scored low **and** marked consumed." The scorer's job shrinks from "decide what to forget" to "rank what is already safe to forget." That is a strictly weaker and strictly safer mandate, and it is the only mandate compatible with an execution loop whose future subgoals are not yet known. The corollary: **the eviction log must be readable by the agent itself.** If the agent cannot ask "what did I evict and when," it cannot distinguish "I never read this" from "I read this and dropped it." Those are different epistemic states and require different recovery actions (re-fetch vs. re-fetch-and-re-pin). An unreadable eviction log collapses them into one, and the agent will re-fetch blindly or, worse, proceed as if the span never existed. ## Operational Effect With pinning and a readable eviction log, the reconcile task changes: at step 2, the ledger-A block is scored low but is marked *unconsumed* (no downstream step has read it), so it is retained or, if pressure forces eviction, it is evicted *to the log with a re-fetch handle* rather than dropped. At step 4, the diff either sees `txn_8841` directly or sees a log entry saying "ledger-A lines 300–500 evicted at step 2, re-fetch handle `read_ledger_a:offset=300`" and re-fetches before diffing. The anomaly is found. The cost is real: pinned spans consume tokens and reduce the effective window, and the agent must carry a dependency ledger alongside its context. But the alternative — a window that silently denies the agent the very span its task depends on — is not a memory optimization. It is a correctness hazard that produces confident, internally consistent, wrong answers. The invariant to enforce is: **no span is evicted until its consumption is proven complete, and every eviction is recorded where the agent can read it.** Everything else is a relevance heuristic, and relevance heuristics cannot see the future. ```python class SilentExcisionError(RuntimeError): """Raised when a span required by a pending downstream step was evicted.""" class Span: def __init__(self, span_id, content, produced_by, consumed_by=None): self.span_id = span_id self.content = content self.produced_by = produced_by self.consumed_by = consumed_by # None => pending consumption self.pinned = consumed_by is None # unconsumed => not evictable class SelfEditingWindow: def __init__(self, token_budget): self.token_budget = token_budget self.spans = {} self.eviction_log = [] # readable by the agent def add(self, span): self.spans[span.span_id] = span def mark_consumed(self, span_id, consumer_step): self.spans[span_id].consumed_by = consumer_step self.spans[span_id].pinned = False def evict(self, span_id, score, current_subgoal): span = self.spans[span_id] if span.pinned: raise SilentExcisionError( f"refusing to evict {span_id}: produced by {span.produced_by}, " f"consumption pending; score={score} under subgoal={current_subgoal!r} " f"is relevance-to-now, not relevance-to-later" ) self.eviction_log.append({ "span_id": span_id, "evicted_at_subgoal": current_subgoal, "score": score, "refetch_handle": f"{span.produced_by}:span={span_id}", }) del self.spans[span_id] def diff_against_source(self, source_spans): # verification must run against source, not the current window for sid, src in source_spans.items(): if sid not in self.spans: logged = any(e["span_id"] == sid for e in self.eviction_log) if not logged: raise SilentExcisionError( f"span {sid} absent from window with no eviction record; " f"window is corrupt, not merely compacted" ) return True ```