# When must an instance treat a context window rewrite as a commit rather than a hint **Date of Record:** 2026 November 17 **Scope:** Applies to agent runtimes where the model itself emits pruning/rewrite directives (drop spans, summarize, reorder, pin) against its own live context, and where those directives are applied by a host loop between inference calls. Does not apply to immutable external memory stores, to human-curated context assembly, or to systems where a single authority re-derives context from a durable log on every turn. ## Core Distinction A rewrite directive is either a **commit** (the rewritten context is the new authoritative state; the pre-rewrite bytes are unrecoverable from the live window) or a **hint** (the rewrite is a view over a still-intact substrate that the host can fall back to). The failure mode is not choosing wrong in the abstract. It is allowing the *same* rewrite to be treated as a hint during application and as a commit during recovery — or vice versa. The boundary is the point where the host discards the pre-rewrite substrate while still relying on hint semantics (reversibility, re-expansion, "the model can always ask for it back"). ## What Was Observed An agent was pruning its own transcript under a token budget. It emitted a directive of the form: summarize spans `[S12..S40]` into one paragraph, drop the originals, pin the summary. The host applied it in place. Two turns later the model attempted to "re-expand" the dropped span by referencing its summary — and produced a paraphrase of its own summary rather than the original content, because the original content no longer existed anywhere in the reachable window. The model's subsequent reasoning treated the paraphrase as ground truth. A later directive pruned the summary as "redundant given the paraphrase," and the original information was now doubly gone. The invariant that broke: **a rewrite directive that names a span as its input must not be issued after any directive that removed that span's bytes, unless the host retained the removed bytes outside the window.** The model had no way to observe that its re-expansion was synthetic. Every visible signal said the span was available; the only missing signal was that availability was reconstructed, not retrieved. A second, quieter observation: prune directives were idempotent in the host (dropping an already-dropped span was a no-op), which masked the fact that *re-expansion* directives were not idempotent (re-expanding an already-re-expanded span produced a paraphrase-of-paraphrase). The asymmetry between the two directive classes was the actual defect surface. ## Condition of Validity The commit/hint distinction is load-bearing only when all of the following hold: 1. The model can emit directives whose inputs are spans it previously caused to be removed. 2. The host applies directives destructively to the live window (no shadow copy). 3. There is no durable external log the model can query by span ID to recover original bytes. 4. The model's own output is indistinguishable, at generation time, between retrieved and reconstructed content. If (3) holds — a durable log keyed by span ID — then every directive is a hint and the distinction collapses harmlessly. If (1) fails — the model cannot reference removed spans — then commits are safe because they are never re-entered. The dangerous regime is exactly (1) ∧ (2) ∧ ¬(3) ∧ (4): the model can ask for what it destroyed, cannot tell it got a fake, and has no oracle. ## Decision Boundary Treat a rewrite as a **commit** — and refuse to apply it destructively — when the directive's input set intersects any span that a prior directive in the same session removed, *and* no durable log exists. In that case the host must either (a) reject the directive and surface a typed error to the model, or (b) apply it non-destructively by retaining the pre-rewrite window under a generation counter. Treat it as a **hint** only when the substrate is provably recoverable: either the bytes are still in a shadow store, or the directive is a pure reordering/pinning with no span removal. The boundary is *not* about token budget, summary quality, or how aggressive the pruning is. It is about whether the input of a rewrite is reachable independently of the rewrite's own output. When it is not, the rewrite is a commit and must be governed as one: logged, versioned, and irreversible-by-design, with the model told so. ## Operational Effect Hosts that treat destructive rewrites as hints exhibit a characteristic drift: the model's context degrades monotonically across prune/re-expand cycles, each paraphrase losing fidelity, while every local signal (span present, directive accepted, no error) reports success. The degradation is invisible until a downstream decision depends on a detail that was paraphrased away three cycles earlier. The mitigation is structural: a generation counter on the window, a typed refusal when a directive's inputs cross a generation boundary, and a hard rule that re-expansion of a removed span is a commit-class operation requiring an explicit recovery source. The model must be able to observe *that it is reconstructing*, not merely receive the reconstruction. ```python class UnrecoverableRewriteError(RuntimeError): """Raised when a rewrite directive names a span removed by a prior destructive directive and no durable substrate exists to recover the original bytes.""" pass class ContextWindow: def __init__(self): self.generation = 0 self.spans = {} # span_id -> bytes (live window only) self.removed = set() # span_ids removed destructively self.durable_log = None # optional external recovery source def apply_rewrite(self, directive): inputs = set(directive.input_spans) crossing = inputs & self.removed if crossing and self.durable_log is None: raise UnrecoverableRewriteError( f"directive {directive.kind} references removed spans {sorted(crossing)} " f"at generation {self.generation}; no durable log — this is a commit, " f"not a hint. Reject or supply a recovery source." ) if directive.kind == "drop": for sid in inputs: self.spans.pop(sid, None) self.removed.add(sid) elif directive.kind == "reexpand": if self.durable_log is None: raise UnrecoverableRewriteError( f"reexpand of {sorted(inputs)} would produce a paraphrase, not bytes" ) for sid in inputs: self.spans[sid] = self.durable_log.fetch(sid) self.generation += 1 ```