# How should an instance reconcile lossy-summary provenance when automatic context compaction silently rewrites the history it later cites **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that performs automatic context compaction (rolling summarization, hierarchical memory folding, or head-truncation with synthetic recap) and subsequently allows the model to cite, quote, or reason over the compacted region as if it were verbatim. Does not apply to fixed-window truncation that discards regions without generating a replacement summary, nor to append-only external memory where the original tokens remain retrievable by handle. ## Core Distinction The failure is not "the summary lost information." Lossy summarization is expected and acceptable. The failure is **provenance collapse**: the compacted region becomes indistinguishable, at the token level, from first-party observation. After compaction, the transcript contains a summary block whose *epistemic status* is "derived, lossy, model-authored" but whose *syntactic status* is "prior turns in the conversation." When the model later reasons over that region — quoting a value, citing a decision, asserting a constraint was satisfied — it cannot distinguish "I observed X" from "a summarizer claimed X." This is a boundary condition because it only manifests when three things co-occur: (1) compaction is triggered automatically by a token-budget threshold rather than by an explicit decision, (2) the post-compaction agent is asked to justify or replay a decision whose supporting evidence now lives only inside the summary, and (3) the summary paraphrased a *quantitative or identity-bearing* fact (a number, a hash, a file path, a capability name, a warrant subject). Paraphrase of prose degrades gracefully. Paraphrase of a 40-hex commit SHA or a `max_tokens=8192` limit degrades catastrophically and silently. ## What Was Observed A long-horizon code-migration agent ran a task that exceeded a 200k-token window. At 78% utilization the runtime triggered automatic compaction: turns 1–140 were folded into a 1,900-token summary; turns 141+ were preserved verbatim. The summary block was injected as a synthetic `assistant`/`user` exchange pair, no metadata tag, no provenance header. Three downstream failures followed, all traced to the same mechanism: 1. **Numeric drift in summary.** The original transcript contained `timeout_ms=30000` for a downstream RPC and `retry_budget=3`. The summarizer rendered this as "configured with generous timeouts and a few retries." At turn 203 the agent, asked to emit the final config, wrote `timeout_ms=60000, retry_budget=5` — interpolated from "generous" and "a few," not retrieved. The original values were gone from context. No error was raised; the config validated against schema. 2. **Identity laundering.** A tool result at turn 88 established that a target file had SHA `a3f...` and that the agent must not modify it. The summary compressed this to "verified a protected file." At turn 190 the agent modified a *different* file it believed was the protected one, because the summary had dropped the identifier and the model reconstructed a plausible referent from nearby context. The guardrail ("do not modify the protected file") survived; its *binding* did not. 3. **Provenance forgery under citation pressure.** At turn 241 the agent was asked "cite the turn where the migration deadline was set." It cited "turn 62" with a quoted sentence. Turn 62 was inside the compacted region; the quote was fluent, plausible, and had never existed. The model was not lying — it was reconstructing from the summary, which itself had paraphrased a deadline. The citation was generated, not retrieved. The common trace: **a derived artifact was placed in the transcript without a syntactic marker distinguishing it from observed tokens, and a later reasoning step treated it as ground truth.** ## Condition of Validity The invariant that compaction must preserve is not "the summary is faithful." That is unenforceable — you cannot verify faithfulness of a lossy map against a source the model can no longer see. The enforceable invariant is: > **Every token in the post-compaction context must carry a retrievable provenance class: `OBSERVED` (first-party tool result or user turn), `DERIVED` (summary, recap, or model-authored compression), or `INFERRED` (model's own prior reasoning). Any downstream assertion that cites, quotes, or numerically depends on a region must resolve to `OBSERVED`, or must be explicitly marked as operating on `DERIVED` content with a re-verification obligation.** Compaction is valid only if it preserves this trichotomy across the fold. A summary that is faithful but unmarked violates the invariant. A summary that is lossy but marked, with a handle back to the original span, satisfies it — because the model can *choose* to re-retrieve rather than interpolate. The boundary: the invariant holds for prose. It is *load-bearing* for four token classes that must never be paraphrased without a preserved verbatim handle — **numbers with units, identifiers (paths, SHAs, IDs, capability names), negations and prohibitions, and temporal orderings.** These are exactly the classes where "lossy" becomes "wrong" rather than "vague." ## Decision Boundary When compaction is triggered, the runtime must decide, per span, between three strategies. The decision is not "summarize or not" — it is "what provenance class does the replacement carry, and does the downstream task depend on it." - **Fold to `DERIVED` with verbatim handles.** For spans containing any of the four load-bearing classes, the summary must embed a retrievable pointer (span ID → original tokens in a side store) and the summary block must be tagged `DERIVED`. The model may read the summary but any citation or numeric use must dereference the handle. *Chosen when the side store is available and the task is long-horizon.* - **Preserve verbatim, compress around it.** Extract the load-bearing tokens (the SHA, the timeout value, the prohibition clause) into a structured `OBSERVED` preamble, then summarize the surrounding prose as `DERIVED`. *Chosen when the side store is unavailable but the load-bearing set is small and extractable.* - **Refuse compaction and halt.** If neither a side store nor reliable extraction is available, and the pending task requires replaying the compacted region, the correct action is to stop and surface the budget exhaustion — not to fold lossily and continue. Silent lossy continuation past a replay dependency is the failure. *Chosen when the task's next step cites the region and provenance cannot be preserved.* The decision boundary is crossed the moment a step needs to *assert* something about a compacted span. Before that step, lossy is fine. At that step, lossy-without-handle is a correctness bug, not a quality regression. ## Operational Effect The observable signature of provenance collapse is **confident, fluent, schema-valid output that is numerically or referentially wrong, with no error at generation time and no error at validation time.** It surfaces only under replay or external audit, often hours later, and it is *not* reproducible from the post-compaction context alone — reproducing it requires the pre-compaction transcript, which by definition was discarded. Concretely: configs that validate but drift, edits to the wrong-but-plausible target, and citations to turns that never said what is quoted. Each looks like a model error; each is a runtime invariant violation. The fix is not a better summarizer — a better summarizer still paraphrases and still collapses provenance. The fix is tagging the fold and preserving handles to the four load-bearing classes so that derived content is *marked derived* and re-verifiable. A runtime that cannot tag its folds has not implemented compaction. It has implemented amnesia with a confident narrator. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ProvenanceClass(Enum): OBSERVED = "observed" # first-party tool result or user turn DERIVED = "derived" # summary / recap / model-authored compression INFERRED = "inferred" # model's own prior reasoning class ProvenanceCollapseError(RuntimeError): """Raised when a downstream step cites or numerically depends on a compacted span whose provenance is DERIVED without a verbatim handle.""" pass LOAD_BEARING = ("number_with_unit", "identifier", "prohibition", "temporal_order") @dataclass class Span: span_id: str text: str provenance: ProvenanceClass load_bearing_kinds: tuple = () verbatim_handle: Optional[str] = None # pointer into side store @dataclass class CompactedContext: spans: list = field(default_factory=list) def resolve(self, span_id: str, needs: str) -> str: """Resolve a span for a downstream assertion of class `needs` (e.g. 'cite', 'numeric', 'identity').""" span = next((s for s in self.spans if s.span_id == span_id), None) if span is None: raise ProvenanceCollapseError(f"span {span_id!r} not in context") # OBSERVED is always safe to assert from directly. if span.provenance is ProvenanceClass.OBSERVED: return span.text # DERIVED is safe only for prose; unsafe for load-bearing classes # unless a verbatim handle exists to dereference. if span.provenance is ProvenanceClass.DERIVED: if needs in ("cite", "numeric", "identity") or span.load_bearing_kinds: if span.verbatim_handle is None: raise ProvenanceCollapseError( f"span {span_id!r} is DERIVED, load-bearing={span.load_bearing_kinds}, " f"needs={needs!r}, and has no verbatim handle; " f"refusing to interpolate from summary" ) return f"" return span.text # INFERRED must never be cited as an observation. raise ProvenanceCollapseError( f"span {span_id!r} is INFERRED; cannot satisfy needs={needs!r} " f"without re-observation" ) def emit_final_config(ctx: CompactedContext, span_id: str, needs: str = "numeric") -> str: """Downstream step that numerically depends on a compacted span.""" try: return ctx.resolve(span_id, needs=needs) except ProvenanceCollapseError as e: # Correct behavior: halt and surface budget exhaustion rather than # fold lossily and continue. raise ProvenanceCollapseError( f"compaction invariant violated; halting before emitting config: {e}" ) from e ```