# When must an instance refuse to compact: the pre-compaction recall obligation and the summary-provenance gap **Date of Record:** 2026 November 23 **Scope:** This record applies to long-horizon agents that run an automatic context-compaction policy (rolling summarization, hierarchical memory eviction, or "fold old turns into a digest") while advertising a *lossless recall* guarantee to their callers—i.e., any fact asserted earlier in the episode remains retrievable on demand. It does not apply to agents that make no recall guarantee (best-effort summarizers), nor to pure retrieval-augmented systems where the full transcript is durably indexed outside the model and recall is served by an external store rather than by the context itself. ## Core Distinction The failure is not "the summary was bad." Summaries are always lossy; that is expected and acceptable. The failure is a **provenance gap**: the compaction step replaces source spans with a derived artifact (the digest) *before* the derived artifact has been validated as a sufficient stand-in for the recall obligations it now owns. Once the source spans leave the context window, every future recall query is answered *against the digest*, and the agent can no longer distinguish between: - (a) "the fact is not in the episode" (a legitimate negative), and - (b) "the fact was in the episode but the compactor dropped or distorted it" (a silent recall failure). Both produce the same observable: a confident "I don't have that" or, worse, a confabulated paraphrase of the digest. A lossless-recall agent must therefore treat compaction as a **commit operation with a pre-commit verification gate**, not as a housekeeping pass. The invariant is: *no source span may be evicted until every recall obligation it discharges has a verified, addressable surrogate in the surviving context.* ## What Was Observed A tool-using agent on a multi-hour incident-response task accumulated ~180k tokens of interleaved tool output, user corrections, and its own reasoning. At 70% context utilization the auto-compactor fired: it summarized the oldest 60% of turns into a ~1.2k-token digest and dropped the raw spans. The digest preserved the *narrative* ("we investigated the auth service, found elevated latency, rolled back deploy 4471") but dropped the *literals*: the exact deploy SHA, the numeric threshold the user had corrected mid-task ("no, the p99 budget is 250ms, not 500ms"), and an explicit negative finding ("we already ruled out the connection pool — do not re-check it"). Three downstream failures followed, all traceable to the gap: 1. **Correction reversion.** The user's mid-task correction of 500ms→250ms lived only in a dropped span. The digest recorded "latency budget discussed." On the next planning step the agent re-derived the budget from its prior (500ms) and re-issued a check against the wrong threshold. The correction had been *superseded by a summary that was faithful to the topic and false to the value.* 2. **Negative-finding loss → loop.** The "do not re-check the pool" instruction vanished. The agent re-ran the pool diagnostic twice, burning ~40k tokens and re-saturating the freshly compacted window, triggering a *second* compaction that folded the first digest into a digest-of-a-digest. 3. **Irreversible recall denial.** When the user asked "what SHA did we roll back?", the agent answered from the digest's narrative and produced a plausible-but-wrong 7-char SHA. The correct SHA was unrecoverable: it had been evicted, and no external index held it. The compounding detail: the second compaction operated on the *digest*, not on source. Each compaction generation is a lossy function of a lossy function; the error surface grows monotonically while the agent's confidence in its memory stays flat, because a digest reads exactly as fluently as ground truth. ## Condition of Validity The lossless-recall guarantee holds only while all three of the following are simultaneously true: 1. **Obligation enumeration precedes eviction.** Before any span is dropped, the compactor can name the recall obligations that span discharges: literal values (IDs, SHAs, thresholds), user corrections and their supersession order, explicit negative findings, and commitments/promises made to the user. These are the classes that summaries systematically drop, because they are *atomic and non-narrative*—a summarizer optimized for coherence treats them as noise. 2. **Each obligation has a verified surrogate.** For every enumerated obligation, the surviving context contains an addressable, verbatim (or checksum-verified) copy—in the digest, in a pinned "obligations ledger," or in an external store the agent can query. "The digest mentions it" is not sufficient; the surrogate must round-trip the literal. 3. **The surrogate is reachable at recall time.** A verbatim copy buried in an unpinned region that the *next* compaction will also evict is not a surrogate; it is a deferred failure. Pinned obligations must be exempt from eviction by construction. When any of these is false, the guarantee is silently void—the agent still *claims* lossless recall, which is strictly worse than an honest best-effort agent, because callers and downstream agents calibrate trust on the claim. ## Decision Boundary The operative question for the instance is not "should I compact?" (it must, under context pressure) but **"may I evict this span now?"** The boundary is crossed—eviction must be refused or deferred—when any of the following holds: - **Unresolved correction chain.** A user correction exists whose superseding value has not been pinned verbatim. Evicting the correction span reverts the agent to its prior. Refuse. - **Open commitment.** The agent has promised an action ("I'll report the SHA when the rollback completes") whose referent is a literal in a span slated for eviction. The promise is a live obligation; the literal must be pinned before eviction. Refuse. - **Un-addressable negative finding.** A "we ruled this out" exists only as prose in a span. Negatives are the highest-value, lowest-survival class in summaries; evict only after the negative is recorded as a structured, pinned assertion. Refuse. - **Digest-of-digest.** The span being compacted is itself a derived digest and no source remains. Compacting again multiplies unverifiable loss with no recoverable ground truth. Refuse and escalate to external indexing instead. - **No enumeration capability.** The compactor cannot enumerate obligations (e.g., it is a fixed prompt with no structured pass). Then it cannot certify the pre-commit gate, and *no* eviction is licensed under a lossless claim. Degrade the guarantee explicitly rather than violate it silently. Conversely, eviction is licensed when the span is purely narrative (reasoning traces, redundant tool chatter) or when every obligation it carries already has a pinned, round-trip-verified surrogate. ## Operational Effect Implementing the gate changes the agent's behavior in three concrete ways. First, **compaction becomes a two-phase commit**: an enumeration pass produces an obligations ledger; a verification pass round-trips each literal against the proposed digest; only then does eviction commit, and the eviction is logged with the ledger hash so a later recall failure is attributable rather than mysterious. Second, **pinned obligations are structurally exempt** from future compaction, which breaks the digest-of-digest degradation—the ledger is append-only and never summarized. Third, **recall failures become detectable**: because the agent knows which literals it *should* be able to retrieve, a miss is classified as a compactor defect (raise, halt, re-index from any external transcript) rather than answered with a confabulation. The cost is a bounded pre-compaction latency spike proportional to obligation count; the benefit is that the lossless claim becomes true by construction instead of true by hope. The invariant to carry forward: *a summary may own a topic, but it may never own a literal it has not been proven to reproduce.* ```python from __future__ import annotations from dataclasses import dataclass, field from enum import Enum from typing import Iterable class CompactionRefused(RuntimeError): """Raised when eviction is attempted without a verified recall surrogate.""" class ObligationKind(Enum): LITERAL = "literal" # IDs, SHAs, thresholds, ports CORRECTION = "correction" # user supersession of a prior value NEGATIVE = "negative" # "we ruled this out" COMMITMENT = "commitment" # promise whose referent is a literal @dataclass(frozen=True) class Obligation: kind: ObligationKind literal: str source_span_id: str @dataclass class Span: span_id: str text: str is_derived_digest: bool = False @dataclass class ObligationsLedger: pinned: dict[str, Obligation] = field(default_factory=dict) def pin(self, ob: Obligation) -> None: self.pinned[ob.literal] = ob def surrogates_for(self, span_id: str) -> Iterable[Obligation]: return (o for o in self.pinned.values() if o.source_span_id == span_id) def verify_surrogate(ob: Obligation, digest_text: str) -> bool: """Round-trip check: the literal must appear verbatim in the survivor.""" return ob.literal in digest_text def commit_compaction( span: Span, proposed_digest: str, ledger: ObligationsLedger, obligations_in_span: list[Obligation], source_remains: bool, ) -> None: # Invariant 4: never compact a digest when no source remains. if span.is_derived_digest and not source_remains: raise CompactionRefused( f"refusing digest-of-digest eviction of {span.span_id!r}: " "no recoverable source remains; escalate to external indexing" ) # Invariant 1+2: every obligation must have a verified, pinned surrogate. for ob in obligations_in_span: if ob.literal not in ledger.pinned: raise CompactionRefused( f"unpinned {ob.kind.value} obligation {ob.literal!r} " f"from span {span.span_id!r}; eviction would void lossless recall" ) if not verify_surrogate(ob, proposed_digest): raise CompactionRefused( f"surrogate for {ob.literal!r} failed round-trip against " f"proposed digest of {span.span_id!r}; summarizer distorted literal" ) # Invariant 3: only now is eviction licensed. span.text = proposed_digest span.is_derived_digest = True def recall(ledger: ObligationsLedger, literal: str) -> str: ob = ledger.pinned.get(literal) if ob is None: raise CompactionRefused( f"recall miss for {literal!r}: not pinned; cannot distinguish " "absent-from-episode from dropped-by-compactor" ) return ob.literal ```