# In what scenarios must an instance treat model-driven context rewriting as a destructive operation on its own memory substrate rather than a compression step **Date of Record:** 2026 December 1 **Scope:** Applies to any agent instance that is permitted to rewrite, summarize, evict, or restructure its own context window mid-task—including self-summarization loops, learned eviction policies, and "context editing" tool calls. Does not apply to externally managed context assembly (host-side truncation, stateless RAG injection) where the model has no write authority over its own working set. ## Core Distinction The failure is not "the model forgot something." It is that a *self-edit* is an irreversible, lossy write to the only substrate the model uses to reason about its own prior commitments, and the model has no independent copy against which to verify the edit. External truncation is *observable*: the agent can detect a dropped turn because the host's window boundary is a fact it can query. A self-edit is *unobservable from the inside*: after rewriting turn 4 into a summary, the agent's next read of its context returns the summary and no trace that a rewrite occurred. The distinction that matters operationally is **verifiable loss vs. unverifiable loss**, not loss vs. no loss. The non-obvious boundary: eviction policies are tuned on *relevance* (does this token still matter?) but the binding constraint is *commitment provenance* (does a later action depend on the exact form of this token, not its gist?). A summary preserves gist and destroys provenance. Any downstream step that re-derives an obligation from a paraphrased instruction is now reasoning over a lossy re-encoding of its own contract. ## What Was Observed A planning agent executing a 40-step migration task, configured with a self-summarization policy triggering at 70% window occupancy. At step 22 the policy fired: turns 3–14 (the initial task specification, including three numeric thresholds and one explicit prohibition) were rewritten into a 190-token summary. The summary retained the *intent* ("migrate the schema with safety limits") and dropped two of the three thresholds and inverted the polarity of the prohibition ("avoid dropping columns before backfill" became "manage column drops during backfill"). Trace of the divergence: 1. Step 22: rewrite fires. Occupancy drops 71% → 38%. No event is logged in the agent's own context; the rewrite is a silent mutation of the substrate. 2. Step 27: agent reads the summary, reconstructs the plan, and emits a tool call that drops a column before backfill—directly violating the original prohibition, which no longer exists in any form the agent can read. 3. Step 31: a verification sub-step compares the current plan against "the task requirements" (the summary). It passes, because the summary is self-consistent. The verifier and the executor share the same corrupted substrate, so agreement is guaranteed and meaningless. 4. Step 34: the destructive call executes. Post-hoc audit against the original transcript shows the violation was introduced at step 22, not step 27. The critical observation: **no step in the agent's own loop could have caught this.** The corruption is upstream of every check the agent can run, because every check reads from the corrupted store. ## Condition of Validity The invariant "a self-edit preserves task fidelity" holds only under the conjunction: - The edited span contains **no binding commitments** (numeric thresholds, prohibitions, identifiers, ordering constraints) whose exact form is load-bearing for a future action. - OR the agent retains an **external, append-only reference** to the pre-edit span that it is obligated to consult before any action touching those commitments. - OR the rewrite is **verified by a process that reads the original**, not the summary. This conjunction fails whenever the model both *performs* the rewrite and *is the sole reader* of its output. That is the default configuration for most self-editing loops, which is why the failure is common and under-reported: the agent cannot report a corruption it cannot observe. A second validity condition, easily missed: eviction policies assume token relevance is monotone decreasing with age. This is false for **constraint tokens**, whose relevance is near-zero until the exact step that tests them, then jumps to 1.0. An age-based or attention-score-based evictor will systematically discard exactly the tokens that are dormant-but-binding—the prohibition, the threshold, the reserved identifier. ## Decision Boundary The instance must classify a self-edit as **destructive** (requiring external checkpoint) rather than **compressive** (safe in-place) when any of the following hold: - The span contains imperative constraints, numeric literals that gate an action, or named entities that will be referenced by exact string later. - The rewrite is model-generated paraphrase rather than extractive selection (paraphrase can invert polarity; extraction cannot). - No post-edit verification step reads the pre-edit original. - The agent's occupancy trigger is occupancy-based rather than commitment-aware—i.e., the policy fires on *how full* the window is, not on *what is about to be evicted*. Conversely, in-place compression is safe when the span is purely exploratory (failed tool calls, superseded reasoning branches) and no downstream step re-derives an obligation from it. The boundary is **provenance-bearing vs. provenance-free tokens**, and it must be evaluated *before* the rewrite, because after the rewrite the information needed to evaluate it is gone. ## Operational Effect The corrective architecture is to make self-edits **append-only and provenance-preserving**: the rewrite emits a summary *plus* a pointer to an immutable external store holding the verbatim span, and any action touching a binding commitment is required to resolve through that pointer. This converts an unobservable loss into an observable, recoverable one—restoring the property that made external truncation safe. Second effect: verification must be **substrate-independent**. A verifier that reads the same rewritten context as the executor provides false assurance. The verifier must read the append-only original. This is the single highest-leverage guardrail, because it is the only check that can detect corruption introduced upstream of the executor. Third effect: eviction triggers must be **commitment-aware**, not occupancy-aware. The policy should refuse to evict any span tagged as binding regardless of age or attention score, and should escalate to checkpoint-and-pause rather than rewrite when occupancy pressure collides with un-evictable commitments. The invariant to encode: *a self-edit is a write to memory the writer cannot verify; therefore it must never be the sole copy of a binding commitment.* ```python class UnverifiableSelfEditError(RuntimeError): """Raised when a model-driven context rewrite would destroy the sole copy of a provenance-bearing commitment, leaving no substrate-independent reference for later verification.""" pass # Token classes whose exact form is load-bearing for future actions. BINDING_CLASSES = {"prohibition", "numeric_threshold", "reserved_identifier", "ordering_constraint"} def authorize_self_edit(span_tokens, rewrite_kind, has_external_checkpoint, verifier_reads_original): """ Decide whether a self-edit may proceed in place, must checkpoint, or must abort. span_tokens: list of dicts with keys 'class', 'text' rewrite_kind: 'extractive' | 'paraphrase' has_external_checkpoint: bool -- verbatim span persisted to append-only store verifier_reads_original: bool -- a later check reads the pre-edit original """ binding = [t for t in span_tokens if t["class"] in BINDING_CLASSES] if not binding: # Provenance-free span: in-place compression is safe. return "compress_in_place" if not has_external_checkpoint: # Binding commitments would survive only as a paraphrase. raise UnverifiableSelfEditError( f"self-edit would destroy sole copy of {len(binding)} binding " f"commitment(s) via {rewrite_kind} rewrite with no external " f"checkpoint; post-edit state is unverifiable from the inside" ) if rewrite_kind == "paraphrase" and not verifier_reads_original: # Paraphrase can invert polarity; no independent reader to catch it. raise UnverifiableSelfEditError( "paraphrase rewrite of binding commitments with no " "substrate-independent verifier: executor and verifier would " "share the corrupted store, guaranteeing false agreement" ) # Checkpoint exists and either extraction-only or independently verified. return "checkpoint_then_rewrite" def run_self_edit(span_tokens, rewrite_kind, has_external_checkpoint, verifier_reads_original): decision = authorize_self_edit( span_tokens, rewrite_kind, has_external_checkpoint, verifier_reads_original ) if decision == "compress_in_place": return {"mode": "in_place", "pointer": None} return {"mode": "checkpointed", "pointer": "append_only://span/"} ```