# When must an instance refuse to evict: the self-pruning context window and the unsnapshotted-evidence trap **Date of Record:** 2026 November 25 **Scope:** Applies to any agent whose context window is mutated by the model itself—pruning, summarizing, rewriting, or relevance-scored eviction—where the evicted span is the sole durable record of a fact the agent will later be required to justify. Does not apply to append-only context with external durable logging, nor to eviction of spans whose content is reconstructible from a tool callable on demand. ## Core Distinction There are two structurally different things a self-editing context window can do, and they are routinely conflated under the single verb "prune": 1. **Compaction** — replacing a span with a lossy but *faithful-under-verification* surrogate (a summary, a structured extract, a pointer to a retrievable artifact). The invariant preserved is *reconstructibility*: given the surrogate and the environment, the original claim can be re-derived or re-fetched. 2. **Eviction** — dropping a span entirely because a relevance score fell below threshold. The invariant that must be preserved is *evidentiary survival*: if the span was the only in-context witness for a proposition that a later step (a tool call argument, an audit, a final answer) will assert, evicting it destroys the warrant for that assertion. The failure mode lives in the seam: the relevance scorer is trained or prompted to answer "is this span useful *for the current subgoal*?" but the system needs it to answer "is this span the *sole witness* for any proposition still live in the plan?" These are different predicates. A span can be irrelevant to the current step and still be load-bearing evidence for a claim three steps downstream. The model-driven evictor, optimizing the first predicate, will delete the second. ## What Was Observed A research agent was executing a multi-hop task: "Find the unit price of the part in invoice INV-4471, apply the vendor's contractual discount, and file a corrected PO." The context evolved as follows. At step 3, a `fetch_invoice` tool returned a JSON blob containing, among other fields, `"unit_price": 41.20` and `"vendor_id": "V-8821"`. The agent extracted the price into a working note and moved on. At step 5, the agent called `get_contract_terms(vendor_id="V-8821")`, which returned `"discount_bps": 750`. At step 6, the model ran a self-pruning pass: the full invoice JSON scored 0.12 on relevance to the current subgoal ("compute discounted price"), because the price had already been copied into the working note. The evictor dropped the 1,900-token invoice blob, keeping the 40-token note `unit_price = 41.20`. At step 8, the agent needed to file the corrected PO and called `submit_po(unit_price=41.20, discount_bps=750, ...)`. The downstream filing service rejected it: `unit_price` did not match its own record for `INV-4471`, which was `41.02`. The agent, asked to justify its figure, could only cite its own note. The original invoice text—which contained `"unit_price": 41.02` and a *separate* `"list_price": 41.20` field the agent had misread during extraction—was gone. The note was a transcription error; the evicted span was the only witness that could have caught it. The failure was not the extraction error. Extraction errors are expected and correctable. The failure was that the self-pruning pass *removed the correction substrate*. The agent had no path back to ground truth because the relevance scorer, by construction, scores the current subgoal, not the provenance graph. A second, sharper instance: at step 4 a `search_registry` call had returned three candidate vendor IDs, two of which were near-duplicates (`V-8821` and `V-8821-A`). The agent selected `V-8821`. At step 6 the pruning pass evicted the search result set (relevance 0.08) because the selection was "made." At step 9 an auditor subagent asked "why V-8821 and not V-8821-A?" The agent could not answer. It had kept the *decision* and discarded the *decision record*. Replay of the trajectory could not reconstruct the choice because the disambiguating field (`"status": "merged_into"`) lived only in the evicted span. ## Condition of Validity The guardrail only holds if the evictor can distinguish *reconstructible* spans from *witness-only* spans at eviction time. That requires a provenance check that is itself cheap and local. The condition of validity is: > A span may be evicted only if, for every proposition it witnesses, either (a) a faithful surrogate remains in context and is marked as a surrogate, or (b) the proposition is not referenced by any live plan node, open obligation, or pending assertion, or (c) the span is retrievable by a deterministic handle recorded in context. Condition (b) is the hard one. "Referenced by a live plan node" requires the evictor to have read access to the plan and obligation set, not just the recent turns. Model-driven pruners typically see only a window of recent messages plus a relevance prompt; they do not see the pending-obligation ledger. This is the structural gap. The evictor is asked to make an evidentiary decision with subgoal-local information. A second validity condition: the surrogate must be *typed*. A summary that says "invoice fetched, price extracted" is indistinguishable from a summary that says "invoice fetched, price 41.02 extracted." Only a surrogate that carries the extracted value *and* a provenance pointer (`source: fetch_invoice#INV-4471, field: unit_price, raw: `) preserves the correction substrate. Free-text summaries do not; they launder transcription errors into apparent facts. ## Decision Boundary The boundary is between *eviction under subgoal-local relevance* and *eviction under obligation-aware relevance*. Concretely: - **Evict freely** when the span is a tool result whose arguments are fully captured in a typed surrogate with a retrieval handle, and no open obligation references a field not in the surrogate. - **Compact, do not evict** when the span is a decision record (a choice among alternatives) — the *alternatives* must survive, not just the choice, because audits ask "why not the other one." - **Refuse to evict** when the span is the sole in-context witness for a value that (i) appears in a pending assertion, tool-call argument, or open obligation, and (ii) has no typed surrogate with a retrieval handle. This is the refusal case. The correct action is to *compact into a typed surrogate first*, then evict the raw span, or to leave the span and evict something else. The refusal is the non-obvious part. A self-editing window that always succeeds at pruning is, by that very fact, suspect: it means the evictor never encountered a witness-only span it could not replace, which in a multi-hop task with tool calls is implausible. A pruner that never refuses is a pruner that is silently destroying warrants. The operational test: before evicting span *s*, enumerate the propositions *s* witnesses (extract field bindings, not prose). For each, check the obligation ledger and the typed-surrogate store. If any proposition is live and un-surrogated, `raise`—do not evict. The eviction budget then falls on other spans, or the agent must first spend tokens to build the surrogate. ## Operational Effect Enforcing the refusal changes the token economics of the window in a specific, measurable way. In the observed trajectory, the obligation-aware evictor refused to drop the invoice blob at step 6 (the `unit_price` field was referenced by the pending `submit_po` obligation and had no typed surrogate). It instead compacted the blob into a typed surrogate: ``` {field: unit_price, value: 41.02, source: fetch_invoice#INV-4471, raw_handle: inv4471.json} {field: list_price, value: 41.20, source: fetch_invoice#INV-4471, raw_handle: inv4471.json} ``` This cost ~60 tokens versus the 40-token free-text note, but it preserved the distinction between `unit_price` and `list_price` that the free-text note had collapsed. At step 8 the agent's `submit_po` call used 41.02, matched the filing service, and succeeded. The auditor at step 9 could answer "why V-8821" because the decision record had been compacted (alternatives retained) rather than evicted. The cost is real: typed surrogates are 1.5–3× the token cost of free-text notes, and the obligation-ledger check adds a dependency the pruner must be given. The benefit is that the window stops being a lossy channel that silently converts transcription errors into unrecoverable facts. The invariant to hold: *no eviction of a span that is the sole witness for a live, un-surrogated proposition.* Everything else—relevance scoring, summarization, rewriting—is subordinate to that check. The failure signature to watch for in logs: a pruning pass that reports high eviction volume with zero refusals, followed later by an assertion whose provenance chain terminates in a free-text note rather than a typed surrogate. That pair is the fingerprint of a pruner optimizing subgoal relevance while destroying evidentiary survival. ```python from dataclasses import dataclass, field from typing import Optional class UnsafeEvictionError(RuntimeError): """Raised when a self-pruning pass attempts to evict a witness-only span.""" @dataclass class Proposition: subject: str field_name: str value: object has_typed_surrogate: bool raw_handle: Optional[str] = None @dataclass class Span: span_id: str tokens: int relevance: float witnesses: list[Proposition] = field(default_factory=list) @dataclass class ObligationLedger: live: set[tuple[str, str]] = field(default_factory=set) # (subject, field_name) def is_live(self, subject: str, field_name: str) -> bool: return (subject, field_name) in self.live def may_evict(span: Span, ledger: ObligationLedger) -> tuple[bool, str]: """Return (allowed, reason). Refuses when a span is the sole witness for a live proposition that has no typed surrogate and no retrieval handle.""" for prop in span.witnesses: live = ledger.is_live(prop.subject, prop.field_name) if not live: continue if prop.has_typed_surrogate: continue if prop.raw_handle is not None: # reconstructible via handle; compaction, not eviction, is still preferred continue return False, ( f"span {span.span_id} is sole witness for live proposition " f"{prop.subject}.{prop.field_name}={prop.value!r} " f"with no typed surrogate and no retrieval handle" ) return True, "safe: all live-witnessed propositions are surrogated or handle-backed" def prune(spans: list[Span], ledger: ObligationLedger, token_budget: int) -> list[Span]: """Evict lowest-relevance spans until under budget, but never violate the evidentiary-survival invariant. Raises if budget cannot be met safely.""" ordered = sorted(spans, key=lambda s: s.relevance) kept: list[Span] = [] total = sum(s.tokens for s in spans) evicted = 0 for span in ordered: if total <= token_budget: kept.append(span) continue allowed, reason = may_evict(span, ledger) if allowed: total -= span.tokens evicted += 1 else: kept.append(span) if total > token_budget: raise UnsafeEvictionError( f"cannot meet budget {token_budget} without unsafe eviction; " f"remaining {total} tokens held by witness-only spans. " f"Compaction required before further pruning. " f"last refusal: {reason if not kept else 'see per-span refusals'}" ) return kept ```