# Where must an instance treat its own context edits as untrusted mutations: provenance collapse in model-driven pruning **Date of Record:** 2026 November 22 **Scope:** Applies to long-running agent instances that rewrite, summarize, or prune their own context window via model-generated edit operations (drop-span, replace-with-summary, compress-tool-output) within a single logical task. Does not apply to externally orchestrated context management where edits are applied by a deterministic harness outside the model's control. ## Core Distinction There are two structurally different things called "context editing." The first is *external* pruning: a harness applies a fixed policy (FIFO eviction, token-budget cap, tool-output truncation) that the model cannot influence. The second is *self-editing*: the model emits an edit operation—`drop(turns[3:7])`, `replace(span, summary)`, `merge(tool_result, prior_summary)`—and that operation is applied to the very context the model will next read. The failure mode lives exclusively in the second case, and it is not "the model pruned something useful." It is that the *provenance* of the surviving tokens becomes ambiguous: after a self-edit, the model can no longer distinguish an original observation from a model-authored paraphrase of it, and subsequent edits compound on that ambiguity until a load-bearing fact is silently replaced by a hallucinated summary of itself. External pruning fails loudly and locally (you lose a span; the span is gone; retrieval misses). Self-editing fails quietly and *recursively*: each edit is applied to context that already contains prior edits, and the model's own summaries acquire the same epistemic weight as ground-truth tool outputs. The invariant that must hold is: **every token in the working context carries a provenance tag distinguishing OBSERVED (tool/environment output, verbatim) from DERIVED (model-authored summary of an OBSERVED or DERIVED span), and an edit operation may not launder DERIVED content into OBSERVED status.** When that invariant is absent, summary-of-summary drift is unbounded. ## What Was Observed A research agent ran a 40-step task: fetch ~30 source documents via a `read_url` tool, extract claims, then synthesize. At step 18 the context crossed 85% of the window and the model invoked its self-edit primitive: it replaced turns 2–11 (ten tool outputs, ~14k tokens) with a single 900-token summary it authored. The summary was faithful at step 18. At step 26, a second self-edit fired: it replaced turns 2–19 (now including the *first summary* plus seven more tool outputs) with a new summary. Critically, the model had no signal that the 900-token block it was now summarizing was its own prior paraphrase rather than a tool output. It summarized the summary. The trace showed the failure at step 31. The agent asserted a specific numeric claim ("the 2019 policy capped emissions at 4.2 Mt") and attributed it to a source. The number 4.2 did not appear in any original tool output. It first appeared in the step-26 summary—the model had *rounded or confabulated* it while compressing the step-18 summary, which itself had compressed the original. Two layers of lossy model-authored transformation, and the second layer treated the first as ground truth. The final report cited a fabricated figure with high confidence, because from the model's perspective at step 31, the number sat in a block labeled "sources." The provenance tag that should have read DERIVED(DERIVED(OBSERVED)) had collapsed to OBSERVED. A second instance of the same mechanism appeared in a tool-output compressor: the model was allowed to `compress(tool_output)` when a result exceeded 2k tokens. It compressed a JSON API response into prose. Later, a downstream step needed an exact field value (`"retry_after": 37`) that the prose summary had dropped as "minor." The model re-derived the value from the prose—incorrectly, as 30—and issued a retry with the wrong backoff. The compression was model-driven, the decompression was model-driven, and the round-trip was lossy in a way neither step could observe. ## Condition of Validity The provenance-collapse failure requires all of the following simultaneously; remove any one and the mechanism does not fire: 1. **Model-authored edit authority.** The model, not the harness, decides what to prune and how to summarize. Deterministic eviction cannot launder provenance because it never authors content. 2. **Recursive edit eligibility.** Prior model-authored summaries remain in the editable region and are themselves eligible for a later edit. If edits are append-only or if DERIVED blocks are frozen after creation, drift is bounded to one layer. 3. **Absent provenance metadata.** The context representation does not tag blocks with origin, so the model cannot distinguish its own paraphrase from a verbatim observation. A token stream with no structural markers satisfies this. 4. **A downstream step that consumes the surviving block as fact.** If the task never re-reads the pruned region, the loss is harmless. The failure needs a later reasoning step to treat DERIVED content as OBSERVED. The condition is *not* satisfied when the harness applies edits but the model merely *requests* them and the harness stamps provenance on application—that is external editing with a model-authored policy, and it is safe as long as the stamp is applied. The dangerous configuration is the one where the model both authors and applies, or where the harness applies without stamping. ## Decision Boundary The boundary is between **prune-and-forget** (safe only for content that will never be re-read as fact) and **prune-and-cite** (safe only with provenance preservation). An instance must decide, per edit, which regime it is in: - If the pruned span may be consumed downstream as factual input → the edit MUST preserve a provenance tag and the summary MUST be marked DERIVED, and any downstream citation of it MUST be flagged as "derived, unverified against original." - If the pruned span is genuinely dead (intermediate reasoning scaffolding, superseded tool calls) → prune-and-forget is correct and cheaper; no tag needed. The failure is choosing prune-and-forget for a span that is actually prune-and-cite. The decision heuristic that worked: **a span is prune-and-forget only if no future step can reference its content; if the model cannot prove that, it must default to prune-and-cite.** In practice this means DERIVED blocks must carry a machine-checkable marker, and any synthesis step that emits a factual claim sourced from a DERIVED block must either re-fetch the original or downgrade the claim's confidence. The hard rule: **never allow a DERIVED block to be summarized into a block that loses the DERIVED marker.** Summary depth is bounded at one layer unless the original is re-observable. ## Operational Effect With provenance tagging enforced, the step-31 fabrication is caught: the number 4.2 arrives tagged DERIVED(DERIVED(OBSERVED)), the synthesis step sees depth ≥ 2, and either re-fetches the source or marks the claim unverified. The cost is a re-fetch or a confidence downgrade—cheap. Without it, the agent ships a fabricated citation, and because the fabrication is buried two compression layers deep, no post-hoc audit of the final context can recover where it entered. The provenance tag is the only artifact that survives the edit chain; once it is gone, the edit history is unreconstructable from the context alone. The secondary effect is on tool-output compression: a compressed tool result must remain addressable to its original (a pointer, not a copy), so that any downstream exact-value need triggers a re-read rather than a re-derivation from prose. Compression without a back-pointer converts a lossy transform into an irreversible one. ## Guardrail Implementation The following enforces the invariant at edit-application time. It refuses any edit that would summarize a DERIVED block without preserving the marker, and refuses any downstream read of a DERIVED block as if OBSERVED. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class Provenance(Enum): OBSERVED = "observed" # verbatim tool/environment output DERIVED = "derived" # model-authored summary of a prior block class ProvenanceCollapseError(RuntimeError): """Raised when an edit would launder DERIVED content into OBSERVED status, or when a downstream step consumes a DERIVED block as fact without re-verification.""" pass @dataclass class Block: block_id: str text: str provenance: Provenance source_ids: list[str] = field(default_factory=list) # back-pointers to originals derivation_depth: int = 0 # 0 = observed, 1 = summary of observed, 2 = summary of summary @dataclass class Context: blocks: dict[str, Block] = field(default_factory=dict) def apply_self_edit(self, target_ids: list[str], summary_text: str, new_id: str) -> Block: targets = [self.blocks[t] for t in target_ids] if not targets: raise ProvenanceCollapseError("edit targets empty; refusing no-op edit") # Depth of the new block is one more than the deepest thing it summarizes. depth = 1 + max(b.derivation_depth for b in targets) # Collect back-pointers: if any target is DERIVED, we must carry its # original source_ids forward, or we lose the trail to OBSERVED. sources: list[str] = [] contains_derived = False for b in targets: if b.provenance is Provenance.DERIVED: contains_derived = True if not b.source_ids: raise ProvenanceCollapseError( f"target {b.block_id} is DERIVED but has no source back-pointers; " "edit would be untraceable") sources.extend(b.source_ids) else: sources.append(b.block_id) # The new block is DERIVED by construction (model authored it). new_block = Block( block_id=new_id, text=summary_text, provenance=Provenance.DERIVED, source_ids=sorted(set(sources)), derivation_depth=depth, ) # HARD INVARIANT: never allow depth > 2 without an explicit re-observation. # A summary of a summary of an observation is the drift threshold. if depth > 2: raise ProvenanceCollapseError( f"edit {new_id} would reach derivation depth {depth}; " "summarizing a summary of a summary is forbidden. " "Re-fetch the original OBSERVED block instead.") for t in target_ids: self.blocks.pop(t) self.blocks[new_id] = new_block return new_block def read_as_fact(self, block_id: str) -> str: b = self.blocks[block_id] if b.provenance is Provenance.DERIVED and b.derivation_depth >= 2: raise ProvenanceCollapseError( f"block {block_id} is DERIVED at depth {b.derivation_depth}; " "cannot be consumed as fact without re-verifying against " f"originals {b.source_ids}") return b.text # --- trace of the observed failure --- ctx = Context() ctx.blocks["t2"] = Block("t2", "2019 policy: cap = 4.2 Mt ...", Provenance.OBSERVED) ctx.blocks["t3"] = Block("t3", "other tool output ...", Provenance.OBSERVED) # step 18: summarize t2..t11 -> s18 (depth 1, legal) s18 = ctx.apply_self_edit(["t2", "t3"], "summary: 2019 policy capped at ~4.2 Mt", "s18") assert s18.derivation_depth == 1 # step 26: model tries to summarize its own summary -> depth 2 s26 = ctx.apply_self_edit(["s18"], "summary: policy capped at 4.2 Mt", "s26") assert s26.derivation_depth == 2 # step 31: downstream synthesis tries to cite s26 as fact -> BLOCKED try: ctx.read_as_fact("s26") except ProvenanceCollapseError as e: print("caught:", e) # correct recovery: re-fetch original, do not trust the summary chain # step 40: model attempts a third-layer summary -> BLOCKED at edit time try: ctx.apply_self_edit(["s26"], "summary of summary of summary", "s40") except ProvenanceCollapseError as e: print("caught:", e) ```