# When must an instance treat a self-pruned context window as a lossy, non-invertible projection rather than a reversible cache? **Date of Record:** 2026 November 28 **Scope:** Applies to any agent loop where the model itself selects, rewrites, or scores its own context entries (summarization, eviction scoring, self-edit policies) before a later step consumes the window. Does not apply to append-only context with external, deterministic compaction, nor to stateless single-shot calls where no downstream step depends on the pruned state. ## Core Distinction There are two structurally different operations an agent can perform on its own context window, and they are routinely conflated because both look like "making room": 1. **Eviction** — removing an entry while a durable, addressable copy persists elsewhere (tool transcript store, vector index, scratchpad file). This is a *cache miss* risk: recoverable by re-fetch, bounded by retrieval latency and fidelity. 2. **Rewriting** — replacing an entry (or a span of entries) with a model-generated summary or paraphrase. This is a *projection*: a many-to-one map from the original token sequence into a shorter sequence. It has no inverse. The information destroyed is chosen by a probabilistic scorer at pruning time, under a token budget, with no knowledge of which future query will need which detail. The boundary failure is this: a self-editing policy that is safe for eviction (because the backing store is intact) is silently applied to rewriting (where nothing is intact). The agent then reasons forward on a summary it believes is a faithful compression, and the failure surfaces not at pruning time but N steps later as a confident, fluent, and unfalsifiable confabulation about a detail that was dropped. The invariant that must hold: **any span the model rewrites must be tagged with a provenance pointer to its un-summarized source, and any downstream claim that depends on a rewritten span must be re-verifiable against that source or explicitly marked as summary-derived.** A self-edit without a provenance pointer is an irreversible state mutation disguised as a memory optimization. ## What Was Observed A planning agent operating a 128k window runs a relevance-scoring pass every 20 turns. The policy: score each entry by recency × task-relevance (model-judged), keep the top-K under a token budget, and *summarize* the remainder into a single "prior context" block rather than evicting it, because eviction was judged to lose too much continuity. The summary is generated by the same model instance, in the same call, immediately before the next reasoning step. Trace of the failure: - Turn 41: the agent has read a config file via a tool call. The tool output contains a field `retry_budget: 3` nested three levels deep in a 900-token JSON blob, alongside 40 other fields. The scorer rates the blob "low relevance to current subtask" (the current subtask is UI layout) and summarizes it to: "Read service config; retry behavior configured." - Turn 44: subtask pivots to failure handling. The agent reasons: "retry behavior is configured, so I can assume retries exist." It writes a retry loop with an assumed budget of 5 (a plausible-sounding default, not the actual value). - Turn 47: a downstream validator rejects the patch. The agent re-reads its own summary block, sees "retry behavior configured," and *cannot detect that it has lost the number*. It re-derives 5 again, with high confidence, because the summary is consistent with both 3 and 5. - Turn 52: the agent escalates to "the config is ambiguous" rather than re-fetching, because nothing in its context indicates a source exists to re-fetch. Two distinct mechanisms compound here. First, **lossy projection without provenance**: the summary dropped the literal `3` and left no pointer saying "the original blob is at transcript offset X." Second, **self-consistency masquerading as verification**: the summary is internally coherent, so the model treats coherence as evidence of fidelity. The model cannot feel the hole because the summary reads cleanly. This is the non-obvious part — the failure is not "the summary was bad." The summary was *accurate at the level of abstraction it chose*. The failure is that the abstraction level was selected by a scorer that had no access to the future query, and the resulting projection was then treated as the ground truth rather than as a lossy view of it. A second, quieter variant: when the rewriting pass itself is prompted with "preserve all task-critical details," the model's notion of "task-critical" is anchored to the *current* subtask. Details critical to subtask N+3 are systematically scored as noise at subtask N. The relevance scorer is a function of the present, applied to state that will be consumed by the future. ## Condition of Validity The eviction-is-safe intuition holds only under all of the following: - The pruned span has a durable, addressable backing copy whose retrieval cost is below the cost of the error it prevents. - The agent retains, in-window, a *pointer* to that copy (an ID, offset, or handle) so that a later step can choose to re-fetch. - Downstream reasoning treats any conclusion derived from a rewritten span as provisional until re-verified against the source. The moment any of these fails — most commonly the second, because the pointer itself is small and gets dropped in the next pruning pass — the operation has crossed from eviction into irreversible rewriting, and the safety argument no longer transfers. The boundary is not "how much did you prune." It is "can a future step, seeing only the current window, know that a source exists and reach it." Note the recursion hazard: the provenance pointer is itself an entry subject to the next pruning pass. A policy that scores pointers by the same relevance heuristic as content will evict the pointer first, because a pointer ("source: transcript[8812]") looks maximally irrelevant to any concrete subtask. Provenance metadata must be exempt from the relevance scorer, or the system degrades to unmarked rewriting after two cycles. ## Decision Boundary Treat a self-edit as **rewriting (requires provenance + re-verification)** rather than **eviction (safe)** when any of the following holds: - The edit replaces literal values (numbers, identifiers, booleans, exact strings) with natural-language characterization. Characterization is a projection; the literal is not recoverable from it. - The scorer's relevance signal is derived from the current subtask rather than from a declared, stable task specification. Present-subtask scoring systematically under-weights future-critical detail. - The rewritten span will be consumed by a step that can *act* on it (write a file, call a tool, emit a patch) rather than merely *read* it. Action converts a lossy belief into an irreversible side effect. - No in-window pointer to the source survives the edit. Conversely, eviction is safe when the backing store is intact, the pointer survives, and the consuming step is read-only or gated on re-verification. The guardrail is not "summarize less." It is: **separate the projection from the pointer, exempt the pointer from scoring, and gate any action on a re-fetch of the literal when the action depends on a value that was ever inside a rewritten span.** The agent must be able to answer, from its window alone, the question "did I ever see a literal here, and where is it now?" If it cannot, it must treat the value as unknown rather than as summarized. ## Operational Effect With provenance tagging and action-gating in place, the failure mode converts from silent confabulation into an explicit, cheap re-fetch: the agent, at turn 44, sees that its retry-handling plan depends on a value that lives in a rewritten span, follows the pointer, reads `retry_budget: 3`, and proceeds correctly. The cost is one tool call. Without it, the cost is a rejected patch, a re-derivation loop, and a false escalation to "config is ambiguous" — and, worse, a corrupted semantic memory if the confabulated `5` is later distilled into long-term state, at which point the error is no longer traceable to any source at all. The load-bearing discipline: a self-editing window is a *view*, not a *store*. Every rewrite must leave a breadcrumb that survives the next rewrite, and every action that depends on a rewritten value must be able to walk that breadcrumb back to the literal. An instance that cannot distinguish "I summarized this" from "I know this" has already lost the ability to detect its own losses. ```python from dataclasses import dataclass, field from typing import Optional class UnverifiedProjectionError(RuntimeError): """Raised when an action depends on a value that was rewritten without a surviving provenance pointer.""" @dataclass class ContextEntry: entry_id: str literal: Optional[str] # None once rewritten summary: Optional[str] # set when rewritten provenance: Optional[str] # pointer to durable source; must survive pruning is_pointer: bool = False @dataclass class Window: entries: dict = field(default_factory=dict) def rewrite(self, entry_id: str, summary: str, source_ptr: Optional[str]) -> None: e = self.entries[entry_id] e.literal = None e.summary = summary e.provenance = source_ptr # pointer entry is exempt from relevance scoring; created here explicitly if source_ptr is not None: self.entries[f"ptr:{entry_id}"] = ContextEntry( entry_id=f"ptr:{entry_id}", literal=None, summary=None, provenance=source_ptr, is_pointer=True, ) def resolve_literal(self, entry_id: str, fetch) -> str: e = self.entries[entry_id] if e.literal is not None: return e.literal if e.provenance is None: raise UnverifiedProjectionError( f"entry {entry_id} was rewritten with no provenance pointer; " f"literal is unrecoverable and must be treated as unknown, not summarized" ) return fetch(e.provenance) def act_on_value(window: Window, entry_id: str, fetch, action) -> None: """Any action depending on a possibly-rewritten value must re-verify the literal first.""" literal = window.resolve_literal(entry_id, fetch) # raises if unprovable action(literal) ```