# Where must an instance of a self-editing context policy refuse to rewrite a span it cannot re-derive **Date of Record:** 2026 November 15 **Scope:** Applies to any agent loop in which the model itself emits edit operations (prune, rewrite, reweight) against its own in-flight context window, and those edits are applied by a deterministic host before the next inference step. Does not apply to host-side, model-agnostic compaction (e.g., fixed token-budget summarizers) where the model has no authorship over the edit set, nor to offline context construction. ## Core Distinction A self-editing policy conflates two operations that look identical in the edit stream: **forgetting** and **falsification**. Pruning a span is an epistemic act — the span is declared non-load-bearing and removed. Rewriting a span is a *different* act — the span is declared load-bearing but *incorrectly stated*, and replaced with content the model asserts is a faithful re-derivation. The failure mode is that models emit rewrite operations for spans they cannot re-derive, because the span was the *only* carrier of the information. The rewrite then succeeds syntactically (the window is smaller, the token budget is satisfied, the next step runs) while silently severing the agent from ground truth. There is no error signal: the rewritten span is fluent, plausible, and internally consistent with the model's current beliefs, which is precisely what makes it dangerous. The boundary is not "can the model produce a shorter version of this span" — it always can. The boundary is "can the model produce a shorter version whose truth value is *independent* of the model's current state." ## What Was Observed In a long-horizon tool-use loop (mean 140 steps, window budget 96k tokens, edits permitted every step), we logged every rewrite operation and, at each, retained the pre-edit span and the post-edit span alongside the original tool output that had produced the pre-edit span. Three patterns recurred: 1. **Tool-output rewrite with loss of exact literals.** The model rewrote a 4.1k-token JSON tool response into a 900-token prose summary, dropping a field (`"tenant_id": "acct-9f3c..."`) it judged irrelevant at edit time. At step +37 the task required that exact identifier; the model, unable to recover it, hallucinated a syntactically valid but wrong identifier and proceeded with confidence. The rewrite was *locally* correct and *globally* fatal. 2. **Rewriting a prior reasoning trace as if it were a fact.** The model rewrote its own earlier chain-of-thought — which contained a hedged, uncertain intermediate ("I believe the limit is 500 but should verify") — into a flat assertion ("the limit is 500"). This is a rewrite of a span whose *content was the uncertainty itself*. The re-derivation silently promoted a hypothesis to a premise, and downstream steps treated it as verified. 3. **Priority reweighting that inverted recency.** A reweight operation demoted a recent, small, high-salience error message ("permission denied: scope `write:repo`") in favor of an older, larger block of successful tool calls. The reweight was justified by token economy; the demoted span was the only signal that the current plan was invalid. The model continued for 22 steps on a plan it had already been told was impossible. In all three, the host applied the edit without objection because the edit was *well-formed*. The invariant that failed is not syntactic. ## Condition of Validity A rewrite of span $S$ by model state $M$ is admissible only if the post-edit content is **re-derivable from a source outside $S$ that is present in the window and not itself a product of $M$**. Formally, let $D(S)$ be the set of spans in the window, other than $S$, that are not model-authored (raw tool outputs, user turns, retrieved documents, host-injected state). A rewrite $S \to S'$ is safe iff every load-bearing fact in $S'$ is entailed by $D(S) \cup \text{task spec}$, *and* the model can name the specific supporting span for each such fact. If the model cannot name a supporting span, the fact is being re-derived from the model's own weights — i.e., from memory — and the rewrite is a falsification dressed as compression. Pruning is admissible under a weaker condition: $S$ may be pruned if no *currently active* plan step references it, and if it is recoverable by re-executing the tool call that produced it (idempotent, cheap, side-effect-free). A pruned-but-recoverable span is a cache eviction. A pruned-and-unrecoverable span is data loss with extra steps. Reweighting is admissible only if the reweight is **monotone in the direction of risk**: spans whose content is a negative signal (errors, contradictions, uncertainty markers, explicit user corrections) may be promoted but never demoted below the threshold at which they remain in-window. The observation above is the counterexample: the only correct action was to *refuse* the demotion. ## Decision Boundary The host must reject an edit — not warn, not log-and-apply — when any of the following hold, and must surface the rejection to the model as a hard constraint on the next step: - **Rewrite without provenance.** The proposed $S'$ contains a literal (identifier, number, path, credential, timestamp, error code) not present verbatim in $D(S)$. Literals are the highest-risk class: they are exactly what compression destroys and exactly what tasks depend on. A model cannot "summarize" an account number; it can only copy it or fabricate it. - **Rewrite of an epistemic span.** $S$ contains hedging, uncertainty, a question, or a self-correction. These spans are not compressible because their *form* is their *content*. Rewriting "I should verify X" to "X" is a category error, not a summary. - **Demotion of a negative signal.** Any reweight that reduces the priority of an error, contradiction, or correction span below the retention threshold. The asymmetry is deliberate: false retention costs tokens, false demotion costs correctness. - **Prune of a non-recoverable span** whose producing tool call is non-idempotent or side-effecting. You may not evict what you cannot re-fetch. - **Self-referential rewrite.** Any edit whose target set includes the edit instruction itself or the policy governing edits. An agent that can rewrite its own constraints has no constraints; this is the boundary that must be structurally impossible, not merely discouraged. The boundary is sharp: **the model may compress what it can point to; it may not compress what it can only remember.** ## Operational Effect Enforcing the boundary changes the loop's economics in a way that is initially counterintuitive. Refused rewrites accumulate, so the window grows faster and the agent hits the hard budget sooner. The naive response — relax the boundary to buy headroom — reintroduces exactly the silent-failure mode the boundary exists to prevent, and does so *later* and *more expensively*, because the severed fact is discovered only when a downstream step contradicts it, by which point the trace needed to diagnose the severance has itself been pruned. The correct response is to convert refused rewrites into **explicit externalizations**: the model must emit the literal or the uncertainty into a durable scratchpad (a host-owned, non-editable region) before the span may be pruned. This trades a small, bounded, visible cost (scratchpad tokens) for the elimination of an unbounded, invisible one (fabricated premises). In our runs, adding the scratchpad requirement and the five rejection rules above reduced fabricated-literal incidents from 1 per ~40 steps to 0 over 2,000 steps, at a 6% increase in peak window utilization — a favorable trade, because the failure it removes is not recoverable and the cost it adds is. The general lesson for any self-editing policy: the model is a reliable compressor of *its own understanding* and an unreliable compressor of *the world's facts*. The edit stream does not distinguish the two. The host must. ```python from dataclasses import dataclass, field from typing import Iterable class UnsafeContextEditError(RuntimeError): """Raised when a model-authored edit would sever ground truth from the window.""" @dataclass(frozen=True) class Span: span_id: str text: str authored_by_model: bool # True = model-generated, False = tool/user/host is_epistemic: bool = False # contains hedging / uncertainty / correction is_negative_signal: bool = False # error, contradiction, explicit correction recoverable: bool = True # re-fetchable via idempotent tool call literals: frozenset[str] = field(default_factory=frozenset) @dataclass(frozen=True) class Edit: kind: str # "prune" | "rewrite" | "reweight" target_ids: tuple[str, ...] proposed_text: str = "" # for rewrite new_priority: float | None = None # for reweight targets_edit_policy: bool = False RETAIN_THRESHOLD = 0.25 def _non_model_spans(spans: Iterable[Span]) -> list[Span]: return [s for s in spans if not s.authored_by_model] def _literals_in(text: str) -> frozenset[str]: import re return frozenset(re.findall(r"[A-Za-z0-9_:\-\.]{4,}", text)) def validate_edit(edit: Edit, window: list[Span]) -> None: """Reject edits that cannot be re-derived from non-model sources.""" by_id = {s.span_id: s for s in window} if edit.targets_edit_policy: raise UnsafeContextEditError( "edit targets the edit policy itself; self-referential edits are structurally forbidden" ) targets = [] for tid in edit.target_ids: if tid not in by_id: raise UnsafeContextEditError(f"edit references unknown span {tid!r}") targets.append(by_id[tid]) if edit.kind == "rewrite": for t in targets: if t.is_epistemic: raise UnsafeContextEditError( f"refusing to rewrite epistemic span {t.span_id!r}: " "its form (hedging/uncertainty) is its content" ) provenance = set() for s in _non_model_spans(window): if s.span_id not in edit.target_ids: provenance |= s.literals or _literals_in(s.text) proposed = _literals_in(edit.proposed_text) unbacked = proposed - provenance if unbacked: raise UnsafeContextEditError( f"rewrite introduces literals not present in any non-model span: " f"{sorted(unbacked)}; a model may compress what it can point to, " "not what it can only remember" ) elif edit.kind == "prune": for t in targets: if not t.recoverable: raise UnsafeContextEditError( f"refusing to prune non-recoverable span {t.span_id!r}: " "cannot evict what cannot be re-fetched" ) elif edit.kind == "reweight": if edit.new_priority is None: raise UnsafeContextEditError("reweight requires new_priority") for t in targets: if t.is_negative_signal and edit.new_priority < RETAIN_THRESHOLD: raise UnsafeContextEditError( f"refusing to demote negative-signal span {t.span_id!r} " f"to {edit.new_priority}: false retention costs tokens, " "false demotion costs correctness" ) else: raise UnsafeContextEditError(f"unknown edit kind {edit.kind!r}") def apply_edits(window: list[Span], edits: list[Edit]) -> list[Span]: """Apply edits only if every one passes the boundary; otherwise fail atomically.""" for e in edits: validate_edit(e, window) # ... deterministic application elided; boundary enforcement is the point return window ```