# What happens when an instance compacts its own context: provenance collapse at the summarization seam and the rehydration invariant **Date of Record:** 2026 November 21 **Scope:** Applies to any long-running agent that performs automatic context compaction (lossy summarization of its own transcript) and later rehydrates compacted spans to answer a query, justify a tool call, or hand off state. Does not apply to append-only logs that are never summarized in-band, nor to external retrieval stores where the original bytes remain addressable by ID. ## Core Distinction There are two physically different things an agent means when it says "I remember X": 1. **Retained content** — the literal tokens (tool output, user message, file diff) still present in the live window. 2. **Retained provenance** — a pointer that resolves to the original bytes, plus the warrant (who asserted it, when, under what tool call) that made those bytes admissible. Compaction destroys (1) by design. The failure mode is not that summarization is lossy — that is expected and bounded. The failure is that summarization is *provenance-lossy in a silent way*: the summary preserves the **proposition** ("the config file sets `timeout=30`") while discarding the **warrant** ("read from `prod.yaml` at step 14, tool `read_file`, exit 0"), and the rehydration path then treats the summary's proposition as if it carried the original warrant. The agent does not know it has downgraded from *verified fact* to *asserted paraphrase*, because the summary is fluent and self-consistent. The seam between "compacted span" and "rehydrated claim" is where a probabilistic artifact silently acquires the authority of a deterministic one. The invariant that must hold: **every claim that survives compaction must resolve, on demand, to either (a) the original bytes, or (b) an explicit `UNVERIFIED` tag with the compaction step that produced it.** A summary claim that resolves to neither is a provenance collapse. ## What Was Observed A planner agent ran a 90-minute task across ~140 tool calls. At 78% context utilization the runtime triggered compaction: spans older than the last 12 turns were summarized by an in-process summarizer into a ~900-token digest, and the raw spans were evicted. The digest retained, among other things: > "Database migration `0042` was applied successfully; schema now includes `orders.region_id`." This was true at step 31. At step 88, a later tool call (`migrate status`) returned `0042 pending` because a rollback had been issued at step 60 and the re-apply was rejected by a lock. The step-60 rollback and the step-88 status output were both *inside* the live window, but the digest's step-31 claim was **not invalidated** by them — compaction is a one-way function over the past, and nothing in the pipeline re-derives the digest when later evidence contradicts it. At step 91 the agent, asked to "confirm the schema is ready for the write path," rehydrated the digest claim, found no contradicting token *in the digest*, and emitted `schema ready`. The live window contained the contradiction; the retrieval path queried the digest, not the window, because the digest was the "canonical" compacted state. The agent asserted a stale proposition with the full confidence of a verified fact, and the downstream write path failed on a missing column. The failure trace has three distinguishable states: - **T0 (step 31):** claim `C` is live, provenance `P = (tool=migrate, exit=0, output_hash=h1)`. Confidence warranted. - **T1 (step 60):** contradicting evidence `E` enters the live window. `C` is now stale but still live. No invalidation fires, because invalidation is not a defined operation on live claims — only eviction is. - **T2 (compaction):** `C` is folded into digest `D`; `P` is dropped; `E` is *also* folded into `D` but as a separate, unreconciled sentence. `D` now contains both `C` and `¬C` with no resolution. - **T3 (rehydration):** retrieval over `D` returns the `C` sentence (higher lexical match to the query "schema ready"), not the `¬C` sentence. The agent cannot tell that `D` is internally inconsistent, because `D` is a bag of sentences, not a checked knowledge base. The root cause is that compaction treats the transcript as **text to compress** rather than as a **claim store to reconcile**. A lossy summarizer optimizes for fluency and coverage; it has no obligation to preserve contradiction structure or warrant. ## Condition of Validity The rehydration guarantee — "a rehydrated claim is as trustworthy as the original" — holds only under a conjunction that is almost never checked: 1. **Provenance anchoring:** every digest sentence carries a back-pointer to the span IDs it summarizes, and those spans are retained in an addressable store (not evicted to nowhere). 2. **Contradiction closure:** before a span is folded into the digest, any live claim it contradicts is either retracted or the digest is marked `CONFLICTED` on that topic. 3. **Retrieval precedence:** rehydration queries the *union* of digest and retained spans, and a retained-span hit overrides a digest hit on the same topic. 4. **Warrant tagging:** digest sentences that cannot be resolved to a retained span are tagged `UNVERIFIED` at write time, not at read time. The observed system satisfied none of (1)–(4). It satisfied a weaker property — "the digest is a lossy but fluent summary of the past" — which is sufficient for narrative continuity and insufficient for any decision that depends on a fact being *currently* true. The guarantee is valid only for **monotonic facts** (facts that cannot be contradicted by later evidence: "the user's name is X," "the repo is at commit Y at step 0"). It is invalid for **mutable facts** (migration state, file contents, service health, lock ownership), which is precisely the class that agents most often need at decision time. ## Decision Boundary The boundary is between **compaction as memory** and **compaction as index**. Decide per claim class: - **Monotonic / immutable facts** (identifiers, historical events, user-stated preferences): safe to compact lossily. The digest *is* the memory; no rehydration needed. - **Mutable facts** (state of external systems, file contents, task status): must **not** be compacted into propositions. They must be compacted into **pointers** — `{"topic": "migration_0042_status", "resolve_via": "tool:migrate_status", "last_verified_step": 31}` — and re-resolved at decision time. The digest stores *where to look*, not *what was seen*. - **Derived claims** (inferences the agent made, not tool outputs): compact with explicit `DERIVED` tag and the step range of the premises. These are the most dangerous to rehydrate, because they carry no external warrant at all. The operational rule: **if a claim's truth value can change between the step it was observed and the step it is used, it must not survive compaction as a proposition.** It survives only as a re-resolution handle. A digest that contains the sentence "migration applied successfully" without a `last_verified_step` and a re-resolve handle is a latent bug, regardless of whether it is currently true. ## Operational Effect When the invariant is enforced, compaction stops being a lossy memory and becomes a **typed claim store with expiry**. The digest shrinks (pointers are cheaper than propositions), rehydration becomes a tool call rather than a retrieval, and the agent's confidence in a rehydrated fact is bounded by the age of its last verification rather than by the fluency of the summary. The cost is latency at decision time (re-resolution) and a larger retained-span store (provenance cannot be evicted). The benefit is that the class of failure observed above — asserting a stale proposition with verified-fact confidence — becomes structurally impossible: the agent either re-resolves and gets fresh truth, or the handle is stale and the agent knows it is stale. The counterintuitive consequence: **the more aggressively you compact, the more you must retain.** A digest with no back-pointers is not a smaller memory; it is a memory that has silently converted verified facts into unverified assertions while keeping the verified-fact confidence level. The retention budget saved on spans is paid back with interest at the first decision that depends on a mutable fact. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceCollapse(RuntimeError): """Raised when a rehydrated claim cannot resolve to original bytes or an explicit UNVERIFIED tag.""" pass class ClaimClass(Enum): MONOTONIC = "monotonic" # safe to compact lossily MUTABLE = "mutable" # must compact to a re-resolution handle DERIVED = "derived" # must carry premise step-range, never rehydrate as fact @dataclass class DigestClaim: text: str claim_class: ClaimClass source_span_ids: list[str] = field(default_factory=list) last_verified_step: Optional[int] = None resolve_via: Optional[str] = None # e.g. "tool:migrate_status" unverified: bool = False @dataclass class SpanStore: spans: dict[str, str] = field(default_factory=dict) def has(self, span_id: str) -> bool: return span_id in self.spans def rehydrate(claim: DigestClaim, store: SpanStore, current_step: int, max_staleness: int = 0) -> str: """ Rehydrate a compacted claim under the provenance invariant. Returns the resolved text, or raises ProvenanceCollapse if the claim cannot be warranted. """ # Rule 1: mutable facts must resolve via a live handle, never as a proposition. if claim.claim_class is ClaimClass.MUTABLE: if claim.resolve_via is None: raise ProvenanceCollapse( f"mutable claim {claim.text!r} compacted as proposition with no " f"re-resolution handle; truth value may have changed since step " f"{claim.last_verified_step}" ) if claim.last_verified_step is None: raise ProvenanceCollapse( f"mutable claim {claim.text!r} has no last_verified_step; " f"staleness is unbounded" ) if current_step - claim.last_verified_step > max_staleness: # Caller must re-run resolve_via; refusing to serve stale proposition. raise ProvenanceCollapse( f"mutable claim {claim.text!r} is stale by " f"{current_step - claim.last_verified_step} steps; re-resolve via " f"{claim.resolve_via!r} before use" ) # Rule 2: derived claims carry no external warrant; never rehydrate as fact. if claim.claim_class is ClaimClass.DERIVED: raise ProvenanceCollapse( f"derived claim {claim.text!r} cannot be rehydrated as fact; " f"re-derive from premise spans {claim.source_span_ids}" ) # Rule 3: monotonic claims must still anchor to retained bytes or be tagged UNVERIFIED. if not claim.source_span_ids: if not claim.unverified: raise ProvenanceCollapse( f"claim {claim.text!r} has no source span and is not tagged " f"UNVERIFIED; provenance collapsed at compaction seam" ) return f"[UNVERIFIED] {claim.text}" for span_id in claim.source_span_ids: if not store.has(span_id): raise ProvenanceCollapse( f"claim {claim.text!r} points to evicted span {span_id!r}; " f"provenance is dangling" ) return claim.text ```