# Why does an instance lose the provenance of a fact when it rewrites its own context window **Date of Record:** 2026 November 23 **Scope:** Applies to agents that mutate their own context (salience pruning, in-place summarization, model-driven eviction) between reasoning steps. Does not apply to append-only context builders or external memory stores that are never rewritten by the model itself. ## Core Distinction There are two structurally different ways a fact can leave a context window. In **eviction**, the token span is dropped and the agent retains a *record* that something was dropped — a tombstone, a summary line, a pointer. In **rewriting**, the model regenerates the span in a compressed form and then *overwrites the original in place*. The critical distinction is that rewriting is not a lossy copy of eviction; it is a **provenance collapse**. After an in-place summarization, the surviving sentence "the deploy key rotates every 90 days" is indistinguishable, at the token level, from a fact the model asserted directly. The summarizer has laundered a retrieved claim into an asserted one. This is the boundary condition: the failure is not that information was lost, but that the *epistemic status* of the surviving information was silently upgraded. ## What Was Observed A planner agent ran a 40-step tool-use task against a config-management API. At step 12 it called `get_rotation_policy()` and received a structured response: `{"key": "deploy-key", "rotate_days": 90, "source": "vault-prod", "fetched_at": "..."}`. At step 18, the agent's context policy fired — the context had crossed 78% saturation, and the self-editing pass summarized the tool-call block into a single line: `Deploy key rotates every 90 days.` The structured envelope — `source`, `fetched_at`, the fact that this was a *fetched* value and not a *derived* one — was discarded by the summarizer because the summarization prompt asked for "the salient facts," and salience was scored by semantic relevance to the current subtask, not by provenance class. At step 27, a later subtask needed to decide whether to rotate the key. The agent read its own summary line and treated `rotate_days: 90` as ground truth, skipping a re-fetch. The `fetched_at` timestamp was gone, so the staleness check that the tool schema supported could not be executed. The agent rotated a key that had been rotated 12 days earlier by another actor, invalidating a live consumer. The trace showed no error. The summarization step returned a well-formed string. The failure was invisible at every checkpoint because the model had rewritten its own evidence into a conclusion with no marker distinguishing the two. ## Condition of Validity The invariant that was violated: **a rewrite must preserve the provenance class of every claim it carries forward.** Concretely, any span that entered context as `retrieved`, `asserted-by-tool`, or `inferred` must exit the rewrite tagged with the same class. A rewrite that emits `Deploy key rotates every 90 days` without a `[retrieved: vault-prod @ t]` marker is not a summary — it is an unverified assertion wearing a summary's clothes. This holds only when the rewriting pass is *provenance-preserving*. It does **not** hold, and must not be assumed to hold, when: 1. The summarizer prompt does not explicitly enumerate provenance classes as required output fields. 2. The rewrite target overlaps a span that a downstream step will later treat as authoritative (any value fed to a side-effecting tool call). 3. The rewrite is chained — a summary of a summary compounds provenance loss multiplicatively, because each pass re-scores salience against a subtask that has itself drifted. When any of these conditions obtain, the rewrite is unsound as an evidence source and downstream steps must re-fetch rather than trust the rewritten span. ## Decision Boundary The agent must choose, at each self-edit, between **compress-in-place** and **evict-with-tombstone**. The boundary is set by whether the span will later gate a side effect: - If the span's values feed only into reasoning that terminates in a *read* or a *recommendation*, in-place summarization is admissible — provenance loss is tolerable because nothing irreversible depends on it. - If the span's values feed into a *write*, *delete*, *rotate*, or *send*, the span must be evicted-with-tombstone: the original structured envelope is replaced by a pointer (`ref: vault-prod/deploy-key @ step12`) that the agent is *required* to dereference before acting. The tombstone forces a re-fetch; the re-fetch restores `fetched_at` and re-establishes freshness. The decision is not about token budget. It is about **downstream irreversibility**. A 90% saturated context that still holds one dereferenceable pointer to a side-effect-gating fact is safer than a 40% saturated context that holds a laundered summary of it. ## Operational Effect With the tombstone rule enforced, the step-27 rotation would have hit a `ref:` pointer, re-fetched, seen `fetched_at` 12 days stale relative to the other actor's rotation, and aborted the write. The guardrail costs one tool call per side-effect-gating fact per resume — cheap relative to the invalidation it prevents. The deeper effect is on auditability. A provenance-preserving rewrite leaves a reconstructable chain from conclusion back to source. A provenance-collapsing rewrite leaves a context that *reads* as internally consistent and is therefore *unfalsifiable from inside*. The agent cannot detect its own laundering, because the evidence that would trigger suspicion was the first thing the summarizer dropped. This is why the guardrail must live in the rewrite policy, not in a downstream verifier — by the time a verifier sees the rewritten context, the signal it would check for is already gone. ## Enforcement The following encodes the decision boundary as a rewrite gate that refuses to summarize a side-effect-gating span in place, and requires a dereferenceable tombstone instead. ```python from dataclasses import dataclass from enum import Enum class ProvenanceClass(Enum): RETRIEVED = "retrieved" TOOL_ASSERTED = "tool_asserted" INFERRED = "inferred" class ProvenanceLaunderingError(RuntimeError): """Raised when a self-edit would collapse a claim's provenance class.""" @dataclass(frozen=True) class Span: text: str provenance: ProvenanceClass source_ref: str | None gates_side_effect: bool def rewrite_span(span: Span, compressed_text: str, emit_tombstone: bool) -> Span: # In-place summarization of a side-effect-gating span is forbidden: # it would upgrade a retrieved claim to an unmarked assertion. if span.gates_side_effect and not emit_tombstone: raise ProvenanceLaunderingError( f"refusing in-place summary of side-effect-gating span " f"from {span.source_ref!r}; emit a dereferenceable tombstone instead" ) if emit_tombstone: if span.source_ref is None: raise ProvenanceLaunderingError( "cannot emit tombstone for span with no source_ref; " "re-fetch required before compression" ) return Span( text=f"ref:{span.source_ref}", provenance=span.provenance, # class preserved, not upgraded source_ref=span.source_ref, gates_side_effect=span.gates_side_effect, ) # Non-gating span: compression admissible, but provenance must survive. return Span( text=compressed_text, provenance=span.provenance, source_ref=span.source_ref, gates_side_effect=False, ) def resume_from_rewrite(span: Span) -> Span: # A tombstone must be dereferenced before any downstream side effect. if span.gates_side_effect and span.text.startswith("ref:"): raise ProvenanceLaunderingError( f"tombstone {span.text!r} dereferenced without re-fetch; " "freshness (fetched_at) cannot be re-established from a pointer alone" ) return span ```