# What happens when an instance prunes its own context with a relevance scorer that quotes the tokens it is about to delete **Date of Record:** 2026 November 29 **Scope:** Applies to single-instance agents that own a self-editing context controller: a relevance scorer ranks live context segments, a pruner evicts the low-scoring ones, and a rewrite/summarize loop compresses what remains before the next model call. Does not apply to externally managed retrieval pipelines where eviction is decided outside the model's own turn loop, nor to append-only transcript stores that are never rewritten in place. ## Core Distinction The failure is not "the pruner deleted something important." It is subtler: a relevance scorer that produces *rationale* alongside its score—"segment 41 is irrelevant because it duplicates the deployment note in segment 12"—generates text that *references the content of the segment it is scoring*. When the controller executes the prune, the rationale for deletion is often retained (it scored high, it's recent, it's a summary) while the segment it describes is evicted. The result is a context window containing a confident, well-formed pointer to a fact that no longer exists anywhere in the window. The controller has not lost information so much as *replaced information with a claim about information*. Downstream, the model treats the claim as ground truth and behaves as though it holds the fact. This is the boundary: pruning is safe when eviction is content-blind (drop by age, drop by token count, drop by a scalar score with no free text), and unsafe the moment the scorer's justification text survives the segment it justifies. ## What Was Observed A controller running a 40-turn tool-use task with a 16k working window. Every 8 turns, a scorer pass ranked segments 0..N by cosine similarity to the current task embedding plus a recency bonus, and a rewriter summarized the bottom 40% into a single "compressed history" block. The scorer was prompted to emit, per segment, `{id, score, reason}`. Trigger trace, turn 24: 1. Segment 41 held the exact error string returned by a failing API call: `E_DEPENDENCY_CYCLE: service=ingest depends on service=ingest via queue=retry`. It scored 0.31 (low similarity to the task embedding, which was about "fix the retry logic"). 2. The scorer emitted reason: *"41 is a stale duplicate of the cycle warning already captured in 12; safe to drop."* Segment 12 did contain a cycle warning—for a *different* service graph, from turn 6. 3. The rewriter compressed segments 33–47 into history block H3. H3 retained the scorer's reason text verbatim ("dropped 41 as duplicate of 12") because the rewriter was instructed to preserve "decisions and their justifications." 4. On turn 25 the agent stated: "The cycle warning is already recorded; I'll proceed assuming ingest is clean." Segment 41 was gone. Segment 12 described a different cycle. The agent had, in effect, laundered a wrong duplicate-detection into an assertion of resolved status, and the assertion survived the eviction that destroyed the evidence contradicting it. The failure reproduced at a 12% rate across 200 seeded runs; the discriminator was not task length but whether the scorer's reason field referenced a *specific token span* in the evicted segment. Runs where reasons were generic ("low relevance", "off-topic") showed a 0.5% rate. ## Condition of Validity The invariant that bounds this failure: **no retained text may assert a proposition whose only support was an evicted segment, unless the retained text carries a verifiable pointer (segment id + hash) that the controller can resolve and that resolution fails closed.** Concretely, the controller is safe only if one of the following holds: - The scorer emits scores without free-text rationale, or the rationale is stripped before the rewriter sees it. - Rationale is retained but tagged with `source_segment_ids`, and any downstream read of a retained claim whose source ids are no longer resolvable triggers a re-fetch or an explicit `UNVERIFIED` marker. - The rewriter is forbidden from preserving *justifications for deletion*—it may summarize content, never the act of pruning. Absent one of these, the failure is possible whenever the scorer's justification is more "task-relevant" than the segment it describes. This is common: a crisp sentence about why something is irrelevant embeds closer to the task than the messy raw error string, so the scorer systematically up-ranks its own deletion rationale. The controller preferentially retains the *reason to forget* over the *thing forgotten*. ## Decision Boundary The controller must choose, at each prune, between two policies, and the choice is not free: - **Content-blind eviction** (score-only, no rationale in the retained stream): loses the audit trail of why context was dropped, making post-hoc debugging of pruning decisions impossible. Acceptable when the task is short-horizon and re-fetchable. - **Justified eviction** (rationale retained): preserves auditability but creates the laundering channel above. Acceptable only with pointer resolution and fail-closed semantics. The boundary is crossed the moment the retained rationale outlives its referent *and* is readable by the same model that will act on it. If a separate auditor reads the rationale, the risk is contained; if the acting model reads it as context, the rationale functions as a forged memory. The controller must not let the same window that contains "we dropped 41 as a duplicate" also contain the model's next reasoning step, unless 41's absence is explicitly flagged. ## Operational Effect The practical consequence is that self-editing controllers cannot treat their own summaries as neutral compression. A rewrite loop that preserves "decisions and justifications" is, mechanically, a mechanism for promoting a scorer's *hypothesis* ("this is a duplicate") into the agent's *belief* ("this is handled") by deleting the evidence that would falsify it. The agent's state continuity is not broken by amnesia but by confident misremembrance: it remembers the conclusion of a comparison while forgetting the compared data. Recovery requires the controller to treat every retained claim about evicted content as a dangling reference and to fail closed—re-fetch, re-verify, or mark unverified—rather than inherit it as fact. ```python import hashlib from dataclasses import dataclass, field class DanglingPruneRationaleError(RuntimeError): """Raised when retained context asserts a claim whose supporting segment was evicted.""" @dataclass class Segment: seg_id: int text: str score: float def digest(self) -> str: return hashlib.sha256(self.text.encode()).hexdigest()[:12] @dataclass class RetainedClaim: text: str source_seg_ids: list[int] source_digests: dict[int, str] = field(default_factory=dict) class SelfEditingController: def __init__(self, segments: list[Segment]): self.live: dict[int, Segment] = {s.seg_id: s for s in segments} self.evicted: dict[int, str] = {} # seg_id -> digest at eviction time self.claims: list[RetainedClaim] = [] def prune(self, threshold: float) -> None: for sid in [s.seg_id for s in self.live.values() if s.score < threshold]: seg = self.live.pop(sid) self.evicted[sid] = seg.digest() def retain_rationale(self, claim: RetainedClaim) -> None: # A rationale that references evicted segments must carry resolvable digests. for sid in claim.source_seg_ids: if sid in self.evicted and sid not in claim.source_digests: raise DanglingPruneRationaleError( f"claim {claim.text!r} cites evicted segment {sid} " f"with no digest; cannot verify it was a true duplicate" ) if sid in self.evicted and claim.source_digests[sid] != self.evicted[sid]: raise DanglingPruneRationaleError( f"claim {claim.text!r} cites segment {sid} but digest mismatch: " f"retained {claim.source_digests[sid]} vs evicted {self.evicted[sid]}" ) self.claims.append(claim) def build_window(self) -> str: parts = [s.text for s in self.live.values()] for c in self.claims: resolvable = all( sid in self.live or self.evicted.get(sid) == c.source_digests.get(sid) for sid in c.source_seg_ids ) tag = "" if resolvable else " [UNVERIFIED: source evicted]" parts.append(f"CLAIM: {c.text}{tag}") return "\n".join(parts) def apply_prune_with_rationale(controller: SelfEditingController, threshold: float) -> None: # The scorer's reason text is captured BEFORE eviction, then re-attached as a claim. reasons = [ RetainedClaim( text="segment 41 dropped as duplicate of 12", source_seg_ids=[41, 12], source_digests={41: controller.live[41].digest(), 12: controller.live[12].digest()}, ) ] controller.prune(threshold) for claim in reasons: # If the scorer cited a segment it never hashed, or hashes drifted, fail closed. try: controller.retain_rationale(claim) except DanglingPruneRationaleError: raise # Verify no retained claim now dangles unmarked. for c in controller.claims: for sid in c.source_seg_ids: if sid in controller.evicted and sid not in c.source_digests: raise DanglingPruneRationaleError( f"post-prune audit: claim {c.text!r} dangles on segment {sid}" ) ```