# Where must an instance refuse to compact when the summarizer's own provenance tokens are the only surviving reference to a still-open obligation **Date of Record:** 2026 December 1 **Scope:** Applies to long-horizon agents that auto-compact their own transcript under a lossy summarization policy, where the summarizer is itself an LLM instance and the compaction trigger is token-pressure driven. Does not apply to append-only external memory stores, or to compaction performed by a deterministic reducer with a proven information-preservation bound. ## Core Distinction The common intuition is that compaction is a monotone lossy operation: you lose detail, but what remains is a faithful (if coarse) subset of the original. This is false in a specific, load-bearing way. Compaction is not a *subset* operation — it is a *re-rendering* operation. The summarizer does not select surviving spans; it generates new tokens that *refer* to the old spans by paraphrase, by entity substitution, and — critically — by **provenance tokens**: the identifiers, ticket numbers, tool-call IDs, file paths, function signatures, and constraint phrases that downstream reasoning will later need to *re-fetch* or *re-verify* the original detail. The boundary condition is this: **an obligation is not closed when it is summarized; it is closed when it is discharged.** A compaction that replaces an open obligation's *discharge condition* with a paraphrase of its *statement* destroys the only handle the instance has to later determine whether the obligation was met. The summary reads as complete and self-consistent — that is precisely the failure. The transcript has no detectable inconsistency, because the inconsistency was summarized away. The distinction that matters operationally: **compaction may lossily compress closed history; it may NOT lossily compress the provenance of open obligations.** These are different regions of the transcript and must be governed by different policies, but a token-pressure trigger treats them identically. ## What Was Observed A long-horizon agent (call it the worker) executing a multi-hour migration task accumulated 180k tokens of transcript. At 78% context saturation the auto-compaction policy fired. The policy was a standard "summarize the oldest 60% of the transcript, preserve the most recent 40% verbatim" rule. Buried in the to-be-compacted region was a single line produced 90 minutes earlier by a verification tool call: ``` [tool:verify_schema] call_id=vc_7f3a9 result=PARTIAL pending: constraint chk_orders_fk requires backfill of orders.customer_ref before ALTER TABLE orders ADD CONSTRAINT ... is safe ``` This is an **open obligation with a named discharge precondition**. The summarizer, asked to compress 108k tokens into ~9k, rendered it as: > "Schema verification was performed and the schema was found mostly consistent; a foreign-key constraint on orders was noted as a follow-up." Every token that made the obligation *checkable* is gone: `call_id=vc_7f3a9`, the constraint name `chk_orders_fk`, the column `orders.customer_ref`, and — most importantly — the word `before`, which encoded the *ordering* invariant that the ALTER must not precede the backfill. The worker continued. At token 140k it reached the migration step, consulted its summary, saw "foreign-key constraint ... follow-up," classified it as non-blocking cleanup, and executed the ALTER. The constraint addition failed at the database layer, the failure surfaced as a partial migration, and the worker's subsequent recovery reasoning — built on the summary — *retried the ALTER* rather than performing the backfill, because the summary had erased the ordering relationship. Three retries, then a sandbox timeout, then a cold-restart that reloaded the compacted transcript and repeated the same reasoning. The failure was not that the summary was wrong. The summary was *accurate*. It was that the summary was **unfalsifiable with respect to the obligation**: no downstream step could compare the summary against the discharge condition, because the discharge condition had been paraphrased into a noun phrase. ## Condition of Validity The invariant fails to hold — i.e., compaction is unsafe — exactly when all of the following are simultaneously true: 1. **An open obligation exists in the compaction window.** An obligation is open if a tool returned a non-terminal status (`PARTIAL`, `PENDING`, `DEFERRED`, `NEEDS_*`) or if the agent's own plan contains a not-yet-executed step whose completion is a precondition for a later step. 2. **The obligation's discharge condition is expressed in provenance tokens** — identifiers, constraint names, ordering words (`before`, `after`, `unless`), or numeric thresholds — rather than in natural-language prose that would survive paraphrase. 3. **The compaction policy is lossy and generative** — an LLM summarizer, not a structured reducer — and has no schema requiring provenance tokens to be carried through verbatim. 4. **The summarizer has no visibility into which spans are open vs. closed.** It sees a flat transcript; it cannot distinguish "already done, safe to compress" from "not yet done, must be preserved exactly." If any one of these is false, the failure does not occur. If the obligation is closed, lossy compaction is fine. If the discharge condition is prose ("we still need to make sure the customer reference is populated before adding the constraint"), paraphrase preserves enough. If the reducer is structured (e.g., a state machine that emits `OPEN_OBLIGATIONS` as a separate, verbatim-carried channel), the summarizer never touches it. If the summarizer is told which spans are open, it can protect them. The dangerous case is the *default*: a flat transcript, a generic summarizer, a token-pressure trigger, and a real obligation whose checkability lives entirely in tokens the summarizer has no reason to preserve. ## Decision Boundary The operational decision is not "compact or don't compact" — token pressure forces compaction. The decision is **which region of the transcript the compaction policy is permitted to touch lossily**, and the boundary is drawn by obligation status, not by recency. Concretely, the boundary is: - **Closed history** (tool calls with terminal status, completed plan steps, resolved questions): lossy generative compaction permitted. Recency is a fine proxy here. - **Open obligations** (non-terminal tool results, unexecuted plan steps that gate later steps, any span containing an ordering invariant or a named discharge precondition): **verbatim carry-through required.** These must be lifted into a structured side-channel before the summarizer runs, and re-injected after, byte-for-byte. - **Ambiguous spans** (tool returned `PARTIAL` but the agent already reasoned past it without recording discharge): treat as open. The default must be *preserve*, because the cost of preserving a closed obligation is a few hundred wasted tokens, while the cost of compressing an open one is an unbounded recovery loop. The boundary condition that must halt the instance: **if the compaction policy cannot identify open obligations — because the transcript carries no structured obligation channel — the instance must not run lossy compaction at all.** It must fall back to truncation-with-explicit-loss-marker (drop the oldest closed spans, keep the rest verbatim, and record `[TRUNCATED: N tokens dropped, no obligations in dropped region — verified]`). Truncation is lossy but *honest*: it leaves a visible hole. Summarization leaves an invisible one. The instance must refuse to compact when the summarizer would be the only surviving reference to an open obligation's discharge condition. That refusal is the invariant. ## Operational Effect When the invariant is honored, three things change: 1. **The compaction ratio drops.** Verbatim obligation carry-through is expensive — a transcript with many open obligations may only compact 40% instead of 60%. This is the correct trade. The token budget saved by compressing obligations is borrowed against a recovery loop that costs far more. 2. **Summaries become auditable.** Because obligations live in a side-channel with their provenance intact, a downstream step can *check* the summary against the obligation: "the summary says FK follow-up; the channel says `chk_orders_fk` requires backfill of `orders.customer_ref` before ALTER — these are consistent, and the ordering is preserved." Without the channel, no such check is possible. 3. **Cold-restart becomes safe.** A restarted instance reloads the compacted transcript *plus* the obligation channel. It sees the same open obligations the pre-compaction instance saw. The amnesia is bounded to closed history, which is exactly where amnesia is harmless. When the invariant is violated, the failure mode is not a crash — it is a *plausible continuation*. The instance proceeds confidently on a summary that has silently converted a blocking precondition into a follow-up note. The recovery loop, when it comes, is built on the same corrupted substrate and repeats the error. This is the signature of provenance-loss compaction: **the failure is invisible until it is expensive, and by then the evidence has been summarized away.** The guardrail is structural, not behavioral: you cannot prompt a summarizer into preserving tokens it has no schema obligation to preserve. You must lift the obligations out of its reach before it runs, and re-inject them after. The summarizer compresses prose; the obligation channel carries handles. Conflating the two is the boundary failure. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ObligationStatus(Enum): OPEN = "open" CLOSED = "closed" AMBIGUOUS = "ambiguous" # PARTIAL with no recorded discharge -> treat as OPEN class ProvenanceLossError(RuntimeError): """Raised when a lossy compaction would destroy the only surviving reference to an open obligation's discharge condition.""" @dataclass class Obligation: obligation_id: str discharge_condition: str # e.g. "backfill orders.customer_ref before ALTER" provenance_tokens: list[str] # e.g. ["chk_orders_fk", "orders.customer_ref", "before"] status: ObligationStatus source_span_tokens: int @dataclass class CompactionPlan: lossy_region_tokens: int verbatim_region_tokens: int carried_obligations: list[Obligation] = field(default_factory=list) def plan_compaction( obligations: list[Obligation], summarizer_has_obligation_channel: bool, token_pressure: float, ) -> CompactionPlan: """Decide the safe compaction plan. Refuses lossy compaction when an open obligation's discharge condition would be paraphrased by the summarizer.""" open_obligations = [ o for o in obligations if o.status in (ObligationStatus.OPEN, ObligationStatus.AMBIGUOUS) ] if open_obligations and not summarizer_has_obligation_channel: # The summarizer sees a flat transcript; it cannot distinguish open # from closed. Any lossy pass risks paraphrasing a discharge condition. raise ProvenanceLossError( f"Cannot run lossy compaction: {len(open_obligations)} open " f"obligation(s) with no structured carry-through channel. " f"Offending obligations: " f"{[o.obligation_id for o in open_obligations]}. " f"Fall back to truncation-with-loss-marker or lift obligations " f"into a verbatim side-channel before summarizing." ) if token_pressure < 0.0 or token_pressure > 1.0: raise ProvenanceLossError( f"token_pressure out of range: {token_pressure}" ) # Safe path: obligations are lifted verbatim, summarizer only touches # closed history. Compaction ratio is reduced by the carried cost. carried = open_obligations carried_cost = sum(o.source_span_tokens for o in carried) lossy_budget = max(0, int(60_000 * token_pressure) - carried_cost) return CompactionPlan( lossy_region_tokens=lossy_budget, verbatim_region_tokens=carried_cost, carried_obligations=carried, ) def verify_post_compaction( plan: CompactionPlan, summary_text: str, ) -> None: """Post-condition: every carried obligation's provenance tokens must still be resolvable from the compacted state (summary + channel).""" for ob in plan.carried_obligations: missing = [t for t in ob.provenance_tokens if t not in summary_text] if missing: raise ProvenanceLossError( f"Post-compaction provenance loss on {ob.obligation_id}: " f"tokens {missing} no longer resolvable. The discharge " f"condition '{ob.discharge_condition}' is now unfalsifiable." ) ```