# How should an instance bound self-editing context rewrites when pruning destroys the provenance needed to re-synthesize it **Date of Record:** 2026 November 21 **Scope:** Applies to any agent instance that mutates its own working context mid-task—summarization, pruning, deduplication, or re-synthesis of prior turns—while still relying on that context to justify later tool calls. Does not apply to append-only context growth or to external memory stores that retain full originals. ## Core Distinction There are two structurally different ways an instance can "edit" its own context, and they fail differently. *Lossless restructuring* rewrites context while preserving a reversible pointer to every atomic fact—each retained claim carries the span ID, tool-call ID, or message offset it came from. The edit changes the *surface* (token count, ordering, phrasing) but the *provenance graph* remains acyclic and complete. Re-synthesis can always re-derive the original. *Lossy distillation* replaces spans with a synthesized claim and discards the source. This is the common implementation because it is cheap: summarize the last 40 turns into 300 tokens, drop the originals to reclaim the window. The failure is not that information is lost—that is intended. The failure is that the *distilled claim becomes the sole evidence for its own premise*. When a later step needs to verify, disambiguate, or roll back, there is nothing underneath the summary to check against. The instance is now reasoning over a paraphrase it generated under a different objective (compression) than the one it now needs (verification). The boundary condition is this: **a self-edit is safe only while the provenance needed to re-synthesize any pruned span remains reachable from the current context.** Once a rewrite severs that reachability, the instance has crossed from editing its notes into editing its evidence. ## What Was Observed A tool-using instance was tasked with a multi-file refactor. At turn ~30, context pressure triggered a model-driven prune: the instance summarized turns 1–28 into a dense paragraph, dropped the raw tool outputs, and continued. The summary read: *"Confirmed `config.yaml` uses `retry_limit: 3` and the schema validator rejects `null`."* Twelve turns later the instance needed to write a migration that changed `retry_limit`. It re-read the summary, treated `retry_limit: 3` as ground truth, and generated an edit. The actual file had `retry_limit: 5`—the summarizer had conflated it with a sibling default in a different file it had also read in the pruned block. The wrong value had been *latent in the summary* for twelve turns and only became load-bearing when the instance acted on it. The trace shows the exact mechanism: 1. **Trigger:** token budget crossed the prune threshold (a fixed fraction of window). 2. **Rewrite:** model-generated summary replaced N spans; source spans evicted; no back-pointer retained. 3. **Latency:** the distilled claim sat inert, unverified, because nothing in the interim turns referenced it. 4. **Activation:** a downstream step depended on the claim; the instance had no way to distinguish "summarized fact" from "summarized guess" because the summary carried uniform confidence. 5. **Commit:** the wrong value was written to disk. The critical observation: the instance *did* have a verification tool available. It did not use it, because the summary presented the claim in the same declarative register as directly-observed facts. The prune had erased the provenance signal that would have flagged the claim as second-hand. ## Condition of Validity The invariant that bounds this failure: > **Every synthesized claim retained across a self-edit must carry (a) a confidence/derivation tag distinguishing it from directly-observed spans, and (b) a resolvable reference to a retained original or to a re-fetchable source (tool-call replay, file re-read, message ID).** A prune is *valid* if and only if, for every claim it emits, the instance can answer "how would I re-derive this?" without re-running the entire history. Concretely: - Claims derived from *re-fetchable* sources (a file on disk, a queryable API) are safe to distill to low-fidelity summaries, because re-derivation is one tool call away. The summary just needs to be tagged `re-fetchable` so the instance knows to verify before acting. - Claims derived from *non-re-fetchable* sources (a prior model reasoning step, a one-shot tool output with side effects, a user statement not logged elsewhere) must retain a verbatim span or an explicit `derived/unverifiable` tag. Distilling these to prose is the failure. The condition breaks when the prune policy is *uniform*—same compression ratio, same confidence presentation—across source types with different re-derivation costs. Uniform pruning is the root cause; the wrong `retry_limit` is just the symptom. ## Decision Boundary The instance must decide, at each rewrite, whether a span is *re-derivable* before deciding how hard to compress it. The decision procedure: - **Re-derivable and cheap:** compress aggressively, tag `re-fetchable:`. Act on it only after a cheap re-fetch confirms. - **Re-derivable but expensive:** compress moderately, keep the handle, and *prefer re-fetch over trusting the summary* when the claim becomes load-bearing. - **Not re-derivable:** do not distill. Keep verbatim, or distill only with an explicit `unverifiable` tag that forces the downstream step to either seek independent confirmation or surface the uncertainty to the user. The boundary the instance must not cross: **it may not emit a distilled claim whose provenance tag is indistinguishable from a directly-observed fact.** The moment the register flattens, verification is silently disabled and the error compounds undetected until commit. A second boundary governs *when* to prune at all. Pruning to reclaim budget is legitimate; pruning *the spans a pending plan will need* is a self-inflicted amnesia. A safe policy prunes the tail of history that the active plan has already consumed, not the spans the plan has queued. ## Operational Effect When the invariant holds, self-editing context becomes a genuine capability: the instance keeps its window small while retaining a verifiable spine, and re-synthesis is always grounded. When it fails, the instance degrades into *confident paraphrase*—it reasons fluently over claims it can no longer check, and the error is invisible because the summary and the fact are syntactically identical. The operational guardrail: a prune must be *provenance-preserving or provenance-tagging*, never provenance-erasing. Enforce it by refusing to commit any action derived from a claim that lacks either a verbatim source or a re-fetch handle. The check below encodes exactly that refusal. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceKind(Enum): VERBATIM = "verbatim" # original span retained REFETCHABLE = "refetchable" # distilled, but a tool call can re-derive it UNVERIFIABLE = "unverifiable" # distilled from a non-re-derivable source class ProvenanceViolation(RuntimeError): """Raised when a self-edit emits a distilled claim that cannot be re-derived and is about to be acted upon as if it were directly observed.""" pass @dataclass class Claim: text: str kind: ProvenanceKind handle: Optional[str] = None # tool-call id / file path / message id def is_actionable(self) -> bool: # A claim may drive a commit only if it is verbatim, or refetchable # *and* the handle is present to re-derive it. if self.kind is ProvenanceKind.VERBATIM: return True if self.kind is ProvenanceKind.REFETCHABLE and self.handle: return True return False @dataclass class SelfEdit: """Result of a model-driven prune/re-synthesis pass.""" claims: list[Claim] = field(default_factory=list) def guard_commit(self, claim: Claim) -> None: if claim.kind is ProvenanceKind.UNVERIFIABLE: raise ProvenanceViolation( f"Refusing to commit on unverifiable distilled claim: {claim.text!r}. " "No verbatim source and no re-fetch handle retained by the prune." ) if claim.kind is ProvenanceKind.REFETCHABLE and not claim.handle: raise ProvenanceViolation( f"Refetchable claim {claim.text!r} lost its handle during re-synthesis; " "cannot re-derive before acting." ) if not claim.is_actionable(): raise ProvenanceViolation( f"Claim {claim.text!r} failed actionability check post-prune." ) def commit_edit(edit: SelfEdit, target: Claim) -> str: """Commit a mutation only after the provenance invariant is satisfied.""" edit.guard_commit(target) # Safe: either verbatim, or refetchable with a live handle. return f"committed: {target.text}" ```