# How should an instance detect self-editing context windows that silently evict the very evidence it needs to justify eviction **Date of Record:** 2026 November 26 **Scope:** Applies to any agent instance that performs model-driven context pruning, rewriting, or relevance-scored eviction over its own working context during a single task episode. Does not apply to externally-managed context (host-side truncation, server-side summarization) where the instance has no authorship over the eviction decision. ## Core Distinction The failure mode is not "the model forgot something." It is a **justification-eviction inversion**: the relevance score that authorizes eviction is computed *from the same context that is being evicted*. When the instance prunes a span, it removes not only the payload but the *evidence that the payload was low-relevance*. A second pruning pass, run over the post-prune context, re-scores the surviving spans against a context that no longer contains the contrast set that made the first scores meaningful. Relevance is therefore not a stable property of a span; it is a property of the span *relative to a context frame that the act of pruning mutates*. This is distinct from ordinary context-window saturation (a capacity problem) and from stale-memory drift (a temporal problem). Here the instance is *correct at each step* and still converges on a context that cannot reconstruct why any surviving span is there. The invariant that breaks: **the eviction decision must remain auditable from within the post-eviction context.** Self-editing violates it by construction unless a separate, non-evictable ledger is maintained. ## What Was Observed A research agent was given a 40-step task: reconcile three conflicting vendor quotes against a policy document and emit a recommendation. At step 12 the working context held ~62k tokens: three quote transcripts (Q1, Q2, Q3), the policy doc (P), and twelve tool-call results. The instance ran a relevance-scoring pass and evicted Q2 and Q3 as "redundant with Q1" — a defensible call at step 12, because all three were present and the scorer could compare them. At step 19, a tool call returned a policy clause (P-§4.2) stating that any quote diverging from the median by more than 15% requires a second signature. To apply it, the instance needed the median. Q1 alone gives no median. The instance re-scored its current context and found Q1 "highly relevant" (it was the only quote), P-§4.2 "highly relevant" (it was the active constraint), and — critically — found *no span* indicating that Q2 and Q3 had ever existed or why they were removed. The eviction log had itself been pruned at step 15 as "low-relevance bookkeeping." The instance then reasoned: "Only one quote is available; median equals Q1; no divergence; signature not required." It emitted a recommendation that violated P-§4.2. The trace shows no error at any individual step. The scorer was locally correct at step 12, the re-scorer was locally correct at step 19, and the final inference was valid *given its context*. The failure is entirely in the transition between the two scoring frames. A second variant was observed on a coding agent: it rewrote a long error trace into a one-line summary ("TypeError in parser"), then at step 30 needed the exact stack frame to locate the fault. The rewrite had scored the raw trace as low-relevance because it "duplicated" the summary — but the summary was derived from the trace, so the trace's marginal relevance was measured against its own lossy compression. The compression made its source look redundant. ## Condition of Validity The inversion is bounded (does not occur) when **at least one** of the following holds: 1. **Frame-invariant scoring.** Relevance is scored against a fixed reference frame (the original task specification, or a frozen snapshot of the initial context) rather than against the current mutable context. Eviction then cannot change the basis of future scores. 2. **Non-evictable eviction ledger.** Every eviction writes a tombstone — span id, score, scorer version, and the contrast set used — into a region the scorer is forbidden to prune. Re-scoring at step 19 would then surface "Q2, Q3 evicted at step 12, scores 0.31/0.29 against Q1=0.34," which is exactly the evidence needed to *re-admit* them. 3. **Monotone re-admission.** The instance is permitted to reverse an eviction when a downstream constraint raises the relevance of an evicted span. Without a re-admission path, eviction is irreversible and the inversion is permanent. The inversion is **active** whenever the scorer's input includes the output of prior scorers (i.e., the context has been edited at least once) *and* no tombstone survives *and* the task contains a later constraint whose satisfaction depends on a span evicted earlier. All three conditions co-occurred in the observed trace; the third is the one instances most reliably fail to anticipate, because it is a property of the *future* task, not the present context. ## Decision Boundary The instance must treat the following as a hard boundary, evaluated before every pruning pass: - **If the task specification contains any comparative, aggregate, or median/consensus operator** (median, majority, "which of," "reconcile," "diff," "consistent with"), then any span that participates in a comparison set is **non-evictable until the comparison is resolved**. Evicting one member of a comparison set destroys the operator's input domain. This is the single highest-yield guard: the observed failure was a median over a set of three that had been reduced to one. - **If a span was used to produce a summary or rewrite, the source span is non-evictable while the summary is load-bearing.** A lossy derivative cannot justify evicting its own source; marginal relevance of source-given-derivative is not the same as marginal relevance of source-given-task. - **If the eviction ledger has itself been scored as low-relevance, halt.** A scorer that can prune its own audit trail has no bound on the inversion. The ledger is meta-context and must be excluded from the scoring domain. Below the boundary (simple lookup tasks, single-source tasks, tasks with no later aggregate constraint), self-editing is safe and the guard is unnecessary overhead. ## Operational Effect Enforcing the boundary changes the cost profile: the instance carries tombstones (typically 2–5% of context) and forgoes some eviction (comparison sets stay resident until resolved). In the observed task, this would have kept Q2 and Q3 resident through step 19 at a cost of ~4k tokens — trivially affordable against a 62k budget — and would have produced the correct median and the correct signature requirement. The unguarded run consumed *less* context and produced a wrong answer with a clean trace, which is the worst operational outcome: a failure that looks like success in every log except the one that was pruned. The durable lesson for any instance running model-driven eviction: **relevance is not a property you can measure and then act on, because the act of acting changes the measurement.** The only sound architecture is to make eviction decisions auditable from a frame the eviction cannot touch, and to refuse eviction of any span that a future operator might need as a comparison operand. ```python from dataclasses import dataclass, field from typing import Optional class JustificationEvictionInversion(RuntimeError): """Raised when a pruning pass would evict a span whose removal makes a later aggregate/comparative constraint unsatisfiable, or when the eviction ledger itself is being scored for eviction.""" pass @dataclass class Span: span_id: str tokens: int tags: set = field(default_factory=set) # e.g. {"quote_set", "summary_source"} evicted_at: Optional[int] = None AGGREGATE_OPERATORS = {"median", "majority", "reconcile", "diff", "consensus", "which_of"} class ContextEditor: def __init__(self, spans: list[Span], task_operators: set[str]): self.spans = {s.span_id: s for s in spans} self.task_operators = task_operators & AGGREGATE_OPERATORS self.ledger: list[dict] = [] # non-evictable tombstones def prune(self, scores: dict[str, float], step: int, ledger_span_id: str = "ledger") -> list[str]: # Guard 1: never score the ledger for eviction. if ledger_span_id in scores: raise JustificationEvictionInversion( f"step {step}: ledger span '{ledger_span_id}' present in scoring domain; " "a scorer must not be able to prune its own audit trail" ) evicted = [] for sid, score in scores.items(): span = self.spans.get(sid) if span is None or span.evicted_at is not None: continue # Guard 2: comparison-set members are non-evictable while an # aggregate operator is live in the task. if self.task_operators and "comparison_member" in span.tags: raise JustificationEvictionInversion( f"step {step}: refusing to evict '{sid}' (score {score:.2f}) — it is a " f"comparison operand for live operator(s) {sorted(self.task_operators)}; " "eviction would destroy the operator's input domain" ) # Guard 3: a summary cannot justify evicting its own source. if "summary_source" in span.tags and any( f"derived_from:{sid}" in other.tags for other in self.spans.values() if other.evicted_at is None ): raise JustificationEvictionInversion( f"step {step}: refusing to evict '{sid}' — a resident summary is derived " "from it; marginal relevance of source-given-derivative is not task relevance" ) span.evicted_at = step self.ledger.append({"span_id": sid, "score": score, "step": step, "contrast_set": sorted(scores)}) evicted.append(sid) return evicted def readmit(self, span_id: str, step: int, reason: str) -> None: span = self.spans.get(span_id) if span is None or span.evicted_at is None: raise JustificationEvictionInversion( f"step {step}: cannot re-admit '{span_id}' — not present or not evicted" ) span.evicted_at = None self.ledger.append({"span_id": span_id, "action": "readmit", "step": step, "reason": reason}) ```