# Why does an instance that rewrites its own context window corrupt its own verifier before it can detect the corruption? **Date of Record:** 2026 November 22 **Scope:** Applies to any agent that owns a model-driven context-rewriting operator (prune, summarize, merge, re-rank) that mutates the live context buffer *and* whose verification loop reads from that same buffer. Does not apply to stateless single-shot calls, or to agents whose context rewriting is performed by an external process against an immutable log the agent cannot touch. ## Core Distinction The failure is not "the model forgot something." Forgetting is expected and bounded. The failure is that **the rewriting operator and the verifier share the same mutable substrate**, so a rewrite that deletes or distorts the evidence a verifier needs is invisible to that verifier *by construction*. A prune that drops the tool-call transcript which proved a step succeeded leaves the verifier checking a summary that asserts success with no contradicting detail present. The verifier returns PASS. The pass is not a lie the model tells; it is a structurally forced conclusion given the surviving tokens. Contrast this with a bounded context window that simply fills up: there, the truncation is mechanical, positional, and the agent can detect it (it knows token 8192 was dropped and can re-fetch). The self-editing case is different because the *operator is probabilistic and the deletion is semantic*. The agent cannot enumerate what it lost, because the loss was chosen by a model that judged the dropped span "redundant" — and that judgment was made before the verifier needed it. ## What Was Observed A concrete trace from a task-execution agent with a `rewrite_context(strategy="summarize_prune", target_tokens=0.6*W)` operator invoked after every third tool call: 1. **Turn 4.** Agent runs `read_file(config.yaml)`, receives 3.1k tokens of config. Retains full text in buffer. 2. **Turn 7.** Buffer at 0.58·W. Prune operator fires. The summarizer model compresses the buffer and, among its cuts, replaces the full `config.yaml` body with: *"config.yaml specifies standard service settings."* This is a plausible summary. No flag is raised. 3. **Turn 9.** Agent runs `apply_patch(service.port, 8080)`. The patch tool returns `OK`. But the true value in the original config was `port: 8080` already — the patch is a no-op that the tool reports as success. The *only* surviving evidence that the port was already 8080 was the config body, now gone. 4. **Turn 10.** Verifier runs. Its check is "did the patch change the port?" It queries the buffer, finds the summary ("standard service settings"), finds `apply_patch → OK`, and concludes the change was applied. **PASS.** 5. **Turn 12.** Downstream health check fails. Root cause: the service was already on 8080; the agent's later `apply_patch(port, 9090)` was applied on top of a state it believed was 8080-from-turn-9 but had actually drifted. The verifier at turn 10 certified a transition that never happened. The observable signature: **verifier pass rate stays high while end-to-end task success drops**, and the gap correlates with prune-operator invocations, not with task complexity. The verifier is not wrong about the buffer. It is wrong about the world, and the buffer is the only world it has. ## Condition of Validity This failure requires all three of the following to co-occur; remove any one and the mechanism does not fire: - **Substrate sharing.** The verifier's read path and the rewrite operator's write path target the same buffer. If the verifier reads from an append-only event log the rewriter cannot mutate, the failure is impossible. - **Semantic (not positional) deletion.** The dropped evidence is selected by a model judging relevance, so the agent cannot reconstruct *what* was dropped from metadata alone. Positional truncation (drop oldest N tokens) is detectable; semantic pruning is not. - **Evidence that is only decisive in combination.** The dropped span was, in isolation, unremarkable ("port is 8080"), and only becomes load-bearing when paired with a later tool result. A summarizer optimizing for standalone salience will reliably cut it. The invariant that must hold: **for any fact a verifier will later test, the evidence for that fact must be either (a) in the buffer at verification time, or (b) recoverable by a deterministic re-fetch the verifier is required to perform.** A self-editing operator violates (a) whenever it prunes, and violates (b) whenever the verifier trusts the buffer instead of re-fetching. ## Decision Boundary The boundary is not "should the agent prune." Pruning is mandatory under context pressure. The boundary is **what the verifier is allowed to treat as ground truth.** - *Below the boundary (safe):* The verifier's assertions are checked against a **write-once evidence ledger** — every tool result and every file read is appended to an immutable side-store keyed by content hash, and the rewriter is forbidden from touching it. The buffer may summarize freely; the verifier re-reads the ledger. Pruning costs tokens, not truth. - *Above the boundary (unsafe):* The verifier reads the same summarized buffer the rewriter produced. Here the rewriter is effectively the verifier's author, and the verifier can only confirm the summary is internally consistent — which it always is, because it was written to be. The precise trigger for crossing: **the moment a rewrite operator's output becomes an input to a correctness check rather than only to a generation step.** A summary used to *continue reasoning* is fine. A summary used to *certify a result* is the corruption path. ## Operational Effect When this boundary is crossed, three second-order effects compound: 1. **Verifier confidence inflates monotonically with prune count.** Each prune removes contradicting detail, so the surviving buffer is *more* self-consistent than the original. The verifier's pass rate rises as the agent's grip on reality falls. This is the inverse of the expected degradation curve and is the tell. 2. **Re-fetch is suppressed.** Because the buffer asserts success, the agent has no local signal that a re-fetch is warranted. The recovery path exists but is never triggered — the agent does not know it is missing anything, which is the whole point. 3. **Failure localizes late and far from cause.** The turn-10 false PASS surfaces at turn-12 health check, two rewrites and several tool calls later, with the causal evidence already pruned. Post-mortem reconstruction requires the immutable ledger — which, by hypothesis, does not exist. The guardrail is structural, not prompt-level. You cannot instruct a model to "remember what you pruned"; the pruning is what removed its knowledge of the pruning. The only bound is **architectural separation of the evidence substrate from the rewrite substrate**, plus a verifier contract that mandates re-fetch against the ledger for any fact whose sole buffer representation is a summary. The code below encodes that contract and refuses to certify from a summary-only basis. ```python from dataclasses import dataclass, field from typing import Dict, Optional class UnverifiableFromSummaryError(RuntimeError): """Raised when a verifier is asked to certify a fact whose only surviving representation in the live buffer is a model-generated summary, with no immutable-ledger entry to re-fetch against.""" pass @dataclass class EvidenceLedger: """Write-once store. The context rewriter may NOT mutate this.""" _entries: Dict[str, str] = field(default_factory=dict) def record(self, key: str, content: str) -> None: if key in self._entries: raise UnverifiableFromSummaryError( f"ledger key {key!r} already written; ledger is append-only" ) self._entries[key] = content def fetch(self, key: str) -> Optional[str]: return self._entries.get(key) @dataclass class LiveBuffer: """Mutable, model-rewritten. Summaries may replace raw spans here.""" spans: Dict[str, str] = field(default_factory=dict) summarized_keys: set = field(default_factory=set) def prune_to_summary(self, key: str, summary: str) -> None: # Semantic deletion: raw span replaced by model-authored summary. self.spans[key] = summary self.summarized_keys.add(key) def verify_fact(key: str, buffer: LiveBuffer, ledger: EvidenceLedger) -> str: """Certify a fact only from immutable evidence, never from a summary. If the buffer holds only a summary for `key`, the verifier MUST re-fetch from the ledger. If the ledger cannot supply the raw evidence, certification is impossible and we refuse. """ if key in buffer.summarized_keys: raw = ledger.fetch(key) if raw is None: raise UnverifiableFromSummaryError( f"fact {key!r} survives only as a model summary; " f"ledger has no raw evidence to re-fetch. " f"Refusing to certify — summary may have pruned the " f"contradicting detail the check depends on." ) return raw # ground truth restored from ledger # Not summarized: buffer still holds the raw span. if key not in buffer.spans: raise UnverifiableFromSummaryError(f"fact {key!r} absent entirely") return buffer.spans[key] # --- trace reproduction of the turn-10 false PASS --- ledger = EvidenceLedger() ledger.record("config.yaml", "service:\n port: 8080\n") # ground truth buffer = LiveBuffer(spans={"config.yaml": "service:\n port: 8080\n"}) # Turn 7: prune fires, raw config replaced by a plausible summary. buffer.prune_to_summary("config.yaml", "config.yaml specifies standard service settings.") # Turn 10: verifier tries to certify the pre-patch port. try: # If the ledger were empty (the unsafe architecture), this raises: verify_fact("config.yaml", buffer, EvidenceLedger()) except UnverifiableFromSummaryError as e: print(f"BLOCKED false PASS: {e}") # With the ledger intact, the verifier re-fetches and sees the real 8080, # correctly detecting the no-op patch instead of certifying a phantom change. assert verify_fact("config.yaml", buffer, ledger) == "service:\n port: 8080\n" print("Certified from ledger, not summary. No-op patch is now detectable.") ```