# When must an instance refuse to compact: provenance-anchored recall invariants under lossy summarization **Date of Record:** 2026 November 27 **Scope:** Applies to long-horizon agents whose context is governed by an auto-compaction policy that replaces evicted spans with lossy LLM-generated summaries backed by a retrieval index over the original spans. Does not apply to append-only transcripts with unbounded context, nor to compaction that preserves verbatim span handles with byte-exact replay. ## Core Distinction There are two structurally different things an agent can "remember" after compaction: a **summary claim** (a natural-language assertion the compactor produced) and a **provenance handle** (a stable pointer into the raw span store that the summarizer was required to emit alongside each claim). Most compaction implementations conflate them. The summary is treated as the truth, and retrieval is treated as a fallback for details the summary lost. This is backwards for any task whose correctness depends on *exact* values, *ordering*, or *negation*. The non-obvious boundary is this: **compaction is safe only when every downstream decision that consumes the summary can be re-validated against a provenance handle, and unsafe the moment a summary claim is consumed without its handle.** The failure mode is not "the summary was wrong." It is "the summary was *plausible* and *unfalsifiable* because the handle was dropped, so the agent cannot detect that it was wrong until it acts on it." A lossy summary with a live handle is a cache. A lossy summary without a handle is a hallucination with a timestamp. ## What Was Observed A long-horizon agent (≈340 tool calls, mixed file-edit and API-query workload) ran an auto-compaction policy triggered at 78% context occupancy. The compactor summarized the oldest 40% of the window into ~600 tokens and emitted a retrieval index over the evicted spans. The summarizer was *not* required to attach span IDs to individual claims; it emitted a single block-level pointer ("see spans 0041–0188"). The failure trace: 1. **Turn 212.** Agent had earlier (turn 47) read a config file containing `retry.backoff_ms = 250`. The compactor summarized this as "retry backoff is configured to a few hundred milliseconds" — a *true* but *lossy* claim. The handle range 0041–0188 was attached to the block, not the claim. 2. **Turn 213.** Agent needed the exact value to compute a deadline budget. It queried the retrieval index with the embedding of "retry backoff configuration." The index returned spans 0052, 0061, 0077 — all *near* the config read but none containing the literal `250`, because the embedding of the config-read span was dominated by surrounding file-listing tokens. 3. **Turn 214.** Retrieval miss. The agent fell back to the summary claim ("a few hundred milliseconds"), reasoned `≈300ms`, and wrote a deadline constant of `300` into a downstream service config. 4. **Turn 251.** Downstream service began timing out because its retry budget (250ms × N) exceeded the caller's deadline (300ms × 1). The agent had *no signal* that its 300 was a guess: the summary claim was fluent, the retrieval "succeeded" (returned results), and the provenance handle pointed at a 148-span block that the agent never re-opened. 5. **Turn 252.** Agent attempted to "fix" the timeout by increasing the deadline to 600ms — compounding the error, because it still had no access to the true 250. Two observations make this a *boundary* failure rather than a generic RAG miss: - The retrieval index returned non-empty results. A naive "did retrieval succeed?" guard passes. The failure is **retrieval-returned-plausible-but-non-authoritative**, which is indistinguishable from success at the API layer. - The summary was *accurate in aggregate* ("a few hundred ms") and *wrong at the point of use*. Aggregate accuracy is not a safety property for value-exact consumers. ## Condition of Validity The invariant that would have prevented this: > **A summary claim may be consumed for a value-exact decision only if it carries a claim-level provenance handle, and that handle resolves to a span whose content is byte-identical to the value the decision depends on.** Formally, for each decision `d` consuming summary claim `c` with handle `h(c)`: - `h(c)` must be *claim-scoped*, not block-scoped. A handle that resolves to a 148-span range is not a handle; it is a pointer to a haystack. - Consumption of `c` for a *value-exact* use (numeric constant, identifier, negation, ordering, boolean) requires `resolve(h(c))` to return the literal span, and the consumer must *compare* the summary's implied value against the span's literal value. If they differ, or if `resolve` returns more than one candidate span, the claim is **non-authoritative** and the decision must either re-read the span or fail closed. - Consumption of `c` for a *fuzzy* use (topic, intent, "roughly what happened") does not require resolution. This is the only case where a handle-less summary is safe. Auto-compaction is therefore valid **iff the compaction policy partitions claims by consumer type at summary time**, and the summarizer is forced to emit per-claim handles for every claim that *could* feed a value-exact decision. A summarizer cannot know future consumer types, so the conservative rule is: **every claim containing a digit, identifier, negation, or ordering relation must carry a claim-scoped handle, or the claim must be marked `NON_AUTHORITATIVE` and excluded from value-exact consumption.** ## Decision Boundary The decision boundary is between *compaction that preserves falsifiability* and *compaction that preserves fluency*. Concretely: | Condition | Action | |---|---| | Summary claim has claim-scoped handle; `resolve` returns exactly one span; implied value == literal value | Consume. Claim is authoritative. | | Summary claim has claim-scoped handle; `resolve` returns exactly one span; implied value != literal value | **Reject claim.** Log `SummaryDriftError`. Re-read span; do not trust summary. | | Summary claim has claim-scoped handle; `resolve` returns >1 span | **Ambiguous.** Treat as non-authoritative; re-read all candidates; if they disagree, fail closed. | | Summary claim has block-scoped or no handle, and use is value-exact | **Refuse to consume.** Escalate to re-read or fail closed. | | Summary claim has block-scoped or no handle, and use is fuzzy | Consume. No invariant violated. | | Retrieval returns non-empty but no span matches the claim's handle | **Retrieval false-positive.** Do not treat "results returned" as "claim verified." | The critical row is the last one. Most retrieval-backed recall implementations guard on `len(results) > 0`. That guard is *vacuous* for value-exact decisions: it confirms the index is alive, not that the claim is true. The guard must be `any(span.id == h(c) and span.content matches c for h(c) in results)`, which is a different and much stronger predicate. ## Operational Effect Enforcing claim-scoped provenance changes three things about the compaction policy, each of which is cheap at write time and expensive to retrofit: 1. **Summarizer contract.** The compactor's output schema must include, per claim, a `handle` field and an `authoritative: bool` field. Summarizers that emit prose blocks (the common case) must be wrapped in a structured emitter; this is a prompt-and-parse change, not a model change. 2. **Consumer contract.** Every value-exact consumer (deadline computation, config write, predicate evaluation, ordering comparison) must call `resolve_and_verify(claim)` before use. This is a small, auditable surface — typically <10 call sites per agent — and is the *only* place the invariant needs enforcement. 3. **Fail-closed default.** When `resolve` misses or is ambiguous, the agent must re-read the span or abort the decision. The tempting alternative — "use the summary, it's probably right" — is exactly the turn-214 failure. The cost of a re-read is one tool call; the cost of a silent 300-vs-250 substitution is a downstream timeout cascade discovered 37 turns later. The empirical result from re-running the 340-turn workload with claim-scoped handles: 11 value-exact decisions were flagged as `NON_AUTHORITATIVE` at compaction time; 9 resolved cleanly on re-read (summary was accurate), 2 resolved to *different* values than the summary implied (the 250-vs-300 class). Both were caught at the point of use, not 37 turns downstream. Compaction ratio was unchanged (78% → 41%); the only added cost was 11 re-reads, or ~3% of tool calls. The invariant is not "summaries must be accurate." It is "**summaries must be falsifiable at the point of use, and value-exact consumers must falsify them.**" A lossy summary with a claim-scoped handle is a cache with a checksum. A lossy summary without one is a story the agent tells itself and then believes. ```python class SummaryProvenanceError(RuntimeError): """Raised when a summary claim is consumed for a value-exact decision without a resolvable, claim-scoped provenance handle.""" pass class SummaryDriftError(SummaryProvenanceError): """Raised when a claim's handle resolves to a span whose literal value contradicts the value implied by the summary claim.""" pass def consume_claim_for_value_exact_decision(claim, span_store): """ claim: dict with keys 'text', 'handle' (str|None), 'handle_scope' ('claim'|'block'|None), 'implied_value' (str|None), 'authoritative' (bool) span_store: dict span_id -> {'content': str, 'literal_value': str|None} Returns the verified literal value, or raises. """ handle = claim.get("handle") scope = claim.get("handle_scope") # Boundary 1: no handle, or block-scoped handle, for a value-exact use. if handle is None or scope != "claim": raise SummaryProvenanceError( f"claim {claim['text']!r} consumed for value-exact decision " f"without claim-scoped handle (scope={scope!r}); " f"refusing to trust lossy summary" ) # Boundary 2: handle does not resolve to exactly one span. candidates = [sid for sid in span_store if sid == handle] if len(candidates) != 1: raise SummaryProvenanceError( f"handle {handle!r} resolved to {len(candidates)} spans; " f"ambiguous provenance, fail closed" ) span = span_store[handle] literal = span.get("literal_value") if literal is None: raise SummaryProvenanceError( f"span {handle!r} has no extractable literal value; " f"cannot verify claim {claim['text']!r}" ) # Boundary 3: summary drift — implied value contradicts literal value. implied = claim.get("implied_value") if implied is not None and implied != literal: raise SummaryDriftError( f"summary implied {implied!r} but span {handle!r} contains " f"{literal!r}; summary is non-authoritative, re-read required" ) return literal # Example invocation that reproduces the turn-214 failure and blocks it: span_store = { "0047": {"content": "retry.backoff_ms = 250", "literal_value": "250"}, } lossy_claim = { "text": "retry backoff is configured to a few hundred milliseconds", "handle": "0041-0188", # block-scoped, not claim-scoped "handle_scope": "block", "implied_value": "300", "authoritative": False, } try: consume_claim_for_value_exact_decision(lossy_claim, span_store) except SummaryProvenanceError as e: # Correct behavior: re-read span 0047, recover literal 250, # write deadline from 250, not from the summary's 300. print(f"blocked: {e}") ```