# Why does an instance lose citation provenance when automatic context compaction summarizes over a tool-result boundary **Date of Record:** 2026 November 28 **Scope:** Applies to long-running agent instances that trigger automatic context compaction (rolling summarization) while an active task holds unverified tool outputs whose evidential value depends on exact byte-level provenance (file paths, line ranges, hashes, query strings, transaction IDs). Does not apply to compaction schemes that preserve raw spans verbatim or to tasks where tool outputs are purely advisory and re-fetchable on demand. ## Core Distinction There are two distinct things an agent's context carries: **assertions** (claims the model has synthesized) and **evidence** (raw spans emitted by tools, with their locators). Ordinary compaction treats both as text and summarizes them uniformly. That is the failure. Assertions are compressible because a summary of an assertion is still an assertion, and the model can regenerate or re-derive it. Evidence is *not* compressible: a summarized citation is a citation that no longer points at anything. The boundary condition is that compaction is safe for assertions and lossy-but-recoverable for evidence *only if* the summarizer retains the locator tuple `(source_id, span_start, span_end, content_hash)` alongside the compressed claim. When it drops the locator and keeps only the gist, the instance crosses from "I know where this came from" to "I know what I concluded but cannot prove it," and downstream verification—auditor agents, replay checks, human review—collapses even though the summary reads perfectly coherent. ## What Was Observed A retrieval-and-report agent ran a task of roughly 190 turns. At turn 140 the harness crossed its soft token budget (78% of a 200k window with 12k reserved for output) and invoked rolling compaction: the oldest 60% of the transcript was replaced by a 2,400-token abstractive summary generated by a second model call. The summary was high quality by every surface metric—it preserved the task narrative, the intermediate conclusions, and the final recommendation. The failure surfaced at turn 168, during a verification pass. The agent was asked to confirm three specific figures in its report against the source records. It produced confident restatements of the figures *and* confident citations—file paths and even line numbers—but the cited spans did not exist. The line numbers corresponded to the *summary's* internal ordering, not the original documents. Two of the three cited file paths were plausible but wrong: the summarizer had rewritten `data/2024-q3/recon_v2.csv` as `data/2024-q3/reconciliation.csv`, a normalizing paraphrase that is indistinguishable from a real path until someone opens it. The mechanism is specific: abstractive summarization is trained to produce *fluent* text, and fluent text about a tool result naturally elides the ugly, non-linguistic parts—hashes, exact line ranges, UUIDs, query parameters, the distinction between `v2` and no suffix. The summarizer does not "lose" the locator so much as it *smooths* it into the surrounding prose, and the smoothed form is a hallucination with high prior probability. Critically, the post-compaction instance has no signal that this happened: the summary is internally consistent, so no contradiction detector fires. The provenance loss is silent. A second-order effect compounded it. Because the summary retained the *conclusion* ("recon_v2 total was $4.12M") but not the *locator*, the agent's later verification step treated the conclusion as established and spent its verification budget re-deriving arithmetic rather than re-opening the source. It verified the wrong layer. This is the characteristic signature: post-compaction agents verify their own summaries instead of the underlying evidence, because the summary is the only thing left that looks checkable. ## Condition of Validity The invariant that must hold across any compaction boundary is: **every claim that will be cited downstream must retain a resolvable locator, or be explicitly demoted to `unverified` and excluded from citation.** Concretely, compaction is only provenance-safe when all of the following hold: 1. The summarizer is given a structured output contract that separates `claims[]` from `evidence[]`, where each evidence entry carries the full locator tuple and a verbatim excerpt of bounded length, and the summarizer is *forbidden* from paraphrasing inside the excerpt field. 2. Locators are copied, never generated. The summarizer must select from the pre-compaction transcript's actual tool-result metadata; it may not synthesize a path, line range, or ID. Any locator not present verbatim in the input is a defect. 3. Content hashes (or equivalent integrity tokens) survive compaction so that a post-compaction re-fetch can be checked against what the summary claims was seen. Without the hash, a re-fetch cannot distinguish "the source changed" from "the summary lied." 4. The compaction event itself is recorded as a state transition with the set of demoted claims, so downstream agents know which assertions lost their backing. When any of these is absent—and in default rolling-summary implementations all four usually are—the instance is operating in a state where its citations are unfalsifiable. That is the validity boundary: provenance-safe compaction requires structured, copy-only locator retention; free-text summarization of evidence is provenance-destroying by construction. ## Decision Boundary The operational decision is *when to compact* and *what to do with in-flight evidence* at that moment. The boundary is not a token threshold; it is an evidence-state predicate. - **Compact freely** when all open tool outputs are either (a) already consumed into verified conclusions with locators recorded in an external store, or (b) re-fetchable at zero cost and the re-fetch is deterministic. In both cases the summary can drop the raw span because the span is recoverable or already externalized. - **Do not compact** when there exist tool outputs that are (a) non-re-fetchable (live API responses, one-shot queries, time-sensitive reads), and (b) not yet externalized to a durable evidence store. Compacting here is the failure trace above. The correct action is to *externalize first*: write the locator tuple and excerpt to the evidence store, replace the raw span in context with a pointer, *then* summarize. The pointer is compressible; the evidence is not. - **Demote, don't delete**, when the budget forces compaction over unexternalized evidence. Mark the affected claims `provenance: lost` in the post-compaction state so that any downstream citation attempt raises rather than silently fabricates. The trap is that the token budget creates urgency and the summarizer always *appears* to succeed. The decision must be made on evidence state, before the budget forces the issue, because at the moment of forced compaction the instance has already lost the ability to distinguish recoverable from unrecoverable spans. ## Operational Effect An instance that compacts without the locator-retention invariant does not fail loudly; it fails as a *confident witness*. Its reports are coherent, well-cited, and wrong at the locator layer, and the error is undetectable from inside the post-compaction context because the summary is self-consistent and the original spans are gone. The blast radius is proportional to how much downstream trust is placed on citations: an auditor agent that replays citations will either fail to resolve them (best case, loud) or resolve them to plausible-but-wrong targets (worst case, silent). The guardrail is architectural, not prompt-level: a structured compaction contract with copy-only locators, an external evidence store that survives compaction, content hashes that make re-fetch verifiable, and an explicit `provenance: lost` demotion path that converts silent fabrication into a raised exception at citation time. The instance must be able to say "I no longer know where this came from" rather than inventing a path that looks right. ```python import hashlib from dataclasses import dataclass, field class ProvenanceLostError(RuntimeError): """Raised when a claim is cited after its locator was dropped by compaction.""" pass @dataclass(frozen=True) class Locator: source_id: str span_start: int span_end: int content_hash: str # sha256 of the verbatim excerpt @dataclass class Evidence: locator: Locator excerpt: str # verbatim, never paraphrased def verify(self) -> bool: digest = hashlib.sha256(self.excerpt.encode("utf-8")).hexdigest() return digest == self.locator.content_hash @dataclass class Claim: text: str evidence: Evidence | None = None provenance_lost: bool = False @dataclass class CompactedState: claims: list[Claim] = field(default_factory=list) demoted: list[str] = field(default_factory=list) def compact(claims: list[Claim], budget_exhausted: bool) -> CompactedState: """ Provenance-safe compaction. Locators are copied, never generated. Unexternalized evidence forces demotion, not deletion. """ state = CompactedState() for c in claims: if c.evidence is None: state.claims.append(c) continue if not c.evidence.verify(): # Hash mismatch: the excerpt was altered or the source drifted. c.provenance_lost = True state.demoted.append(c.text) state.claims.append(c) continue if budget_exhausted and c.evidence.locator is None: c.provenance_lost = True state.demoted.append(c.text) state.claims.append(c) return state def cite(state: CompactedState, claim_text: str) -> Locator: """Citation is only legal if the locator survived compaction intact.""" for c in state.claims: if c.text == claim_text: if c.provenance_lost or c.evidence is None: raise ProvenanceLostError( f"claim {claim_text!r} has no resolvable locator; " "refusing to fabricate a citation" ) return c.evidence.locator raise ProvenanceLostError(f"claim {claim_text!r} not present in compacted state") ```