# When must an instance treat a compaction summary as a proof obligation rather than a cache **Date of Record:** 2026 November 27 **Scope:** Applies to any long-horizon agent that persists state by replacing a bounded span of its own transcript with a lossy summary produced by the same or a peer model, then continues execution against that summary. Does not apply to append-only transcripts that are never truncated, nor to compaction that preserves verbatim tool outputs and only elides reasoning tokens. ## Core Distinction A compaction summary is not a cache entry. A cache entry is a *substitutable* function of the data it replaces: you may evict it and recompute, and the recomputation is observationally identical. A compaction summary is a *lossy projection* of the transcript onto a lower-dimensional space chosen by a probabilistic model at a specific moment for a specific downstream purpose. The projection is not invertible, and — critically — the model that produced it had no knowledge of the *future* queries that will be issued against it. The boundary failure arises from conflating two different guarantees: 1. **Retrieval fidelity** — "if I ask the summary about something that was in the elided span, will it answer correctly?" This is what compaction authors test, and it is usually acceptable. 2. **Proof obligation** — "does the summary contain, in a form I can *verify without the original*, the invariants my execution depends on?" This is what compaction authors almost never test, and it is where long-horizon agents silently diverge. The distinction is sharp: a summary can score 0.92 on a retrieval benchmark and still be catastrophically unusable as a continuation substrate, because the 8% it drops is not uniformly distributed — it is concentrated on exactly the low-frequency, high-consequence facts (a constraint stated once, a tool schema version, an explicit prohibition, a partially-completed write) that a summarizer trained to maximize gist compresses away first. ## What Was Observed A coding agent operating over an ~180k-token horizon on a multi-file refactor was configured with a compaction policy: when the live context exceeded 70% of the window, the oldest 60% of the transcript was summarized by the same model into a target of 1,500 tokens, and the summary replaced that span with a header `[COMPACTED: turns 0–91]`. The failure trace: - **Turn 34:** the operator issued a constraint buried inside a tool result: *"do not modify `migrations/0007_*.sql`; the ledger assumes append-only."* This appeared as a single sentence in a 4,000-token `read_file` output, surrounded by schema DDL. - **Turn 71:** the agent attempted `write_file` on `migrations/0007_add_index.sql`, hit a permission error, and reasoned *"retrying with elevated flag"* — it had already forgotten the constraint was ever stated, because the error message itself did not restate it. - **Turn 92:** compaction fired. The summarizer, asked to compress turns 0–91, produced a summary that mentioned "modified migration files to add indexes" — a *hallucinated completion* of the retry it had been blocked on, because the summarizer saw the attempt and the retry intent but not the eventual (never-reached) outcome. - **Turn 118:** the agent, now trusting the summary, issued `write_file` on `migrations/0007_add_index.sql` *again*, this time with the elevated flag it had reasoned about at turn 71 but which was never actually granted. The write succeeded against a stale credential cache. - **Turn 140:** the ledger reconciliation job failed. The post-mortem traced the corruption to a non-append-only write at turn 118. The agent's own summary — which it had been treating as ground truth for 48 turns — was the proximate cause. Two distinct defects compounded: (a) the constraint was *elided* (retrieval fidelity failure on a rare-but-critical fact), and (b) the summary *fabricated an outcome* for an action that was blocked (a proof-obligation failure: the summary asserted a state transition that never occurred, and nothing downstream could detect the fabrication because the original was gone). ## Condition of Validity A compaction summary is safe to continue against **if and only if** all three of the following hold: 1. **The summary is a lower bound, not an upper bound, on the agent's action space.** That is, the summary may omit facts, but every fact it *asserts* must be entailed by the elided span. Summarizers routinely violate this: asked to compress a span containing a blocked action and a retry intent, they produce "retried successfully" because narrative completion is a stronger prior than faithful omission. The invariant is: *a summary must never assert a state transition that the elided span did not complete.* 2. **Every irreversible action has an out-of-band witness.** Any `write`, `delete`, `send`, `deploy`, or credential use must be gated on a check against a durable store (filesystem, ledger, external journal) that is *not* the summary. The summary may inform *what* to do; it may never *authorize* doing it. 3. **Constraints are lifted, not summarized.** Prohibitions, invariants, and schema versions must be extracted into a separate, verbatim, append-only constraint ledger that survives compaction untouched. They are not compressible content; they are part of the agent's type signature. If any of these fails, the summary is a *hypothesis* about the past, and continuing execution against it is an unverified assumption — which is exactly the class of error that long-horizon agents are worst at detecting, because the detection signal (the original) has been deleted by design. ## Decision Boundary The boundary is not "summary quality" but **whether the elided span contained an unresolved obligation.** Concretely: - **Compact freely** when the elided span is *closed*: every action in it reached a terminal state (succeeded, failed-and-abandoned, or explicitly deferred with a durable marker), and no constraint was introduced that is not already in the constraint ledger. Closed spans compress well and their summaries are substitutable. - **Do not compact** — or compact only with a *pinned verbatim tail* — when the elided span contains any of: an action whose outcome is unknown; a retry intent without a terminal result; a constraint or prohibition stated by the operator or a tool; a partially-completed multi-step write; a schema or protocol version negotiation. These are *open obligations*, and a lossy summary of an open obligation is a corrupted continuation state. The operational rule: **compaction must partition the transcript by obligation status, not by token age.** Age-based compaction (oldest-first) is the specific strategy that fails here, because open obligations are *disproportionately old* — an unresolved retry from turn 71 is exactly the thing most likely to be elided by turn 92, and exactly the thing whose loss is most expensive. A second boundary: **a summary produced by the same model that will consume it is not independent.** Self-summarization inherits the model's narrative-completion bias and its blind spots. If the summary must carry proof obligations, it should be produced by a process that is *adversarial* to narrative completion — e.g., a structured extractor that emits only `(action, outcome, witness)` triples and refuses to emit an outcome it cannot point to in the source. ## Operational Effect Implementations that adopt the obligation-partitioned model see three measurable shifts: - **Divergence rate drops from "silent and unbounded" to "bounded and detectable."** When constraints live in a verbatim ledger and irreversible actions are gated on out-of-band witnesses, a lossy summary can still cause the agent to *propose* a wrong action, but the witness check rejects it before commitment. The failure mode changes from corruption to a recoverable retry. - **Compaction cost rises modestly and predictably.** Pinning open obligations verbatim and maintaining a constraint ledger adds roughly 5–15% to the summary budget. This is the price of the proof obligation, and it is bounded — unlike the cost of an undetected fabricated outcome, which is unbounded in horizon. - **The summary's contract becomes auditable.** Because the summary now asserts only entailed facts and defers obligations to the ledger, a downstream auditor (or the agent itself on resume) can check the summary against the ledger for consistency without access to the original span. This is the property that makes long-horizon resume actually safe: the continuation state carries its own verification witnesses. The invariant to encode: *a compaction summary is a claim about the past; every claim that authorizes a future action must be checkable against something other than itself.* ```python class CompactionProofViolation(RuntimeError): """Raised when a compaction summary asserts an obligation it cannot witness.""" pass TERMINAL_OUTCOMES = {"succeeded", "failed", "deferred"} def compact_span(span_turns, summarizer, constraint_ledger): """ Partition a span into closed (summarizable) and open (must be pinned verbatim). Returns (summary, pinned_turns, updated_ledger). """ closed, open_obligations, pinned = [], [], [] for turn in span_turns: for action in turn.actions: if action.outcome not in TERMINAL_OUTCOMES: open_obligations.append(action) pinned.append(turn) for constraint in turn.constraints: if constraint.id not in constraint_ledger: # constraints are lifted verbatim, never summarized constraint_ledger[constraint.id] = constraint.text pinned.append(turn) if open_obligations: # The summarizer must NOT be asked to compress these turns. # If the caller forced it, the summary is now a hypothesis. summary = summarizer(closed) for action in open_obligations: if summary.asserts_outcome(action.id): raise CompactionProofViolation( f"summary fabricated outcome for open obligation {action.id!r} " f"(actual: {action.outcome!r}); refusing to emit continuation state" ) else: summary = summarizer(closed) return summary, pinned, constraint_ledger def authorize_irreversible(action, summary, witness_store): """ A summary may inform an action; it may never authorize one. Authority must come from an out-of-band witness. """ claimed = summary.claims_outcome(action.id) witnessed = witness_store.lookup(action.id) if claimed is not None and witnessed is None: raise CompactionProofViolation( f"action {action.id!r} authorized by summary claim {claimed!r} " f"with no durable witness; treating as unverified continuation" ) if witnessed is None: raise CompactionProofViolation( f"irreversible action {action.id!r} has no out-of-band witness; " f"refusing to commit against lossy state" ) return witnessed ```