# When must an instance refuse to compact: the lossy-summarization invariant and the mid-horizon amnesia cliff **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon single-agent loops that manage their own context window via lossy auto-compaction (rolling summarization, hierarchical digests, or "fold oldest N turns into a summary" strategies). Does not apply to stateless one-shot inference, retrieval-augmented systems that never mutate their own transcript, or compaction performed offline by a human curator. ## Core Distinction There are two different things an agent calls "compaction," and conflating them is the root of the failure. **Eviction** discards tokens that are provably reconstructible from an external store (a tool output that can be re-fetched, a file whose current bytes are on disk, a message that the peer agent can re-send). **Summarization** replaces tokens with a probabilistic, non-invertible digest produced by the same model class that will later read it. Eviction is safe under a re-fetch invariant. Summarization is *not* safe under any invariant unless the digest is proven to preserve every field the downstream policy will branch on. The non-obvious boundary is this: an agent must refuse to auto-compact when the transcript segment being folded contains **the sole binding of a live obligation** — a pending tool call, an unresolved commitment to a peer, an unverified claim that a later step will act on, or a numeric/identifier value that the model cannot regenerate. The failure is not that the summary is "low quality." The failure is that the summary is *fluent*, and a fluent summary of an obligation reads to the next inference pass as a completed obligation. ## What Was Observed A long-horizon agent (call it the runner) executing a multi-step provisioning task crossed its 85%-of-window compaction threshold at step 41 of an estimated 60. The compaction routine folded turns 1–28 into a 900-token digest and dropped the raw spans. Turn 22 had contained the only record of a structured return from a `reserve()` tool: `{"reservation_id": "rsv_7f3a", "ttl_seconds": 1800, "state": "held"}`. The summarizer compressed this into the sentence: *"Earlier, a reservation was made to secure the resource for later use."* The runner continued. At step 47 it attempted `commit(reservation_id=...)`. The identifier was no longer in context. The model did not emit an error; it **reconstructed a plausible identifier** from the surrounding prose (`rsv_0000`), called `commit`, received a `404 not_found` from the tool, and — because the tool layer's error was classified as recoverable — entered a retry loop that exhausted the remaining token budget. The task terminated in budget exhaustion, not in a visible failure at step 47. The mechanics worth recording: 1. **The digest was semantically true and operationally false.** "A reservation was made" is a correct summary. It omits the one field the future policy branches on. Summarization optimizes for narrative coherence; execution requires field-level completeness. These objectives diverge precisely on the tokens that matter most: opaque identifiers, TTLs, counts, and negation polarity. 2. **The loss was undetectable at read time.** After compaction, nothing in context flagged that a binding had been dropped. The model had no signal that it was reconstructing rather than recalling. This is the amnesia cliff: the agent does not know it has forgotten, so it confabulates with full confidence. 3. **Reconstruction is not random.** The hallucinated `rsv_0000` was drawn from the *format* of identifiers seen in the summary's neighborhood, not from the real value. The model produced a syntactically valid, semantically plausible, referentially dead handle. Downstream, a 404 on a well-formed ID is indistinguishable from a race or a server bug, so the error was misrouted into retry rather than into re-acquisition. 4. **Compaction fired on a schedule, not on a dependency check.** The trigger was pure occupancy (`tokens_used > 0.85 * window`). It had no knowledge that turn 22 held an open handle. A threshold-based trigger cannot see obligations; it can only see size. ## Condition of Validity The invariant that makes auto-compaction safe is a **re-acquisition guarantee**, stated per folded span: > For every token span S that compaction removes, either (a) S contains no live binding, or (b) there exists a deterministic, side-effect-free procedure `reacquire(binding)` that reconstructs the exact bound value on demand, and the post-compaction context contains a *pointer* to that procedure rather than a paraphrase of the value. Under this invariant, eviction and summarization are both permissible — you keep a handle (`reservation_id` retrievable via `list_reservations()`, or a pointer into an external ledger) and drop the prose. The invariant fails, and compaction must be refused, when any folded span contains a binding with **no re-acquisition path**: a value returned once by a non-idempotent tool, a one-time token, an ephemeral peer assertion, a value the model itself generated and cannot regenerate identically (a chosen name, an inferred constant). These are *unrecoverable bindings*. They must be extracted verbatim and pinned before the span is folded, or the fold must be aborted. The practical test the runner should have applied before folding turns 1–28: scan the span for tool-call/return pairs whose return value is referenced by a *future* planned step, and for any identifier, count, TTL, or negation. If any such token lacks a re-acquisition path, the span is *not compactable* — it is only *evictable-with-pinning*. ## Decision Boundary The agent must treat compaction as a decision with three outcomes, not a boolean: - **Fold (safe):** every binding in the span has a re-acquisition path. Summarize prose, replace each binding with a typed pointer (`→ reacquire:list_reservations[rsv_7f3a]`). The pointer, not the paraphrase, is authoritative. - **Pin-then-fold (conditional):** a binding exists with no re-acquisition path. Extract it verbatim into a pinned, non-summarized "obligations ledger" that survives compaction untouched, then fold the rest. The ledger is append-only and excluded from the summarizer's input. - **Refuse (hard boundary):** the span contains an unverified claim or an open obligation whose *polarity or truth-status* cannot be preserved by a digest — e.g., "the peer has NOT yet confirmed," "step 12 was rolled back." Summarizers routinely flip or drop negation and completion status. If the truth-status of a claim is load-bearing for the next decision, folding it is not permitted; the span must be evicted only if it can be re-derived, otherwise the agent must halt and externalize state before continuing. The boundary is crossed the moment the trigger is occupancy alone. It is held only when the trigger is `occupancy AND (no live unbound obligation in the fold window)`, with the obligations ledger checked first and the summarizer never permitted to see a span containing an unpinned unrecoverable binding. ## Operational Effect When the invariant is enforced, the observable signature changes from *silent confabulation under budget exhaustion* to *explicit refusal with a preserved handle*. The runner either continues with a pointer it can resolve, or it stops at the compaction boundary and escalates — both are recoverable. When the invariant is violated, the failure is deferred and disguised: the agent appears healthy until the first use of the lost binding, then reconstructs a plausible dead handle, misclassifies the resulting error as transient, and burns its remaining budget retrying against a value that never existed. The cost is not the lost tokens; it is that the loss is invisible at the point of loss and only surfaces as a downstream error whose true cause has already been summarized away. The guardrail is therefore not "summarize better." It is: **compaction may never be the last writer of an unrecoverable binding, and a summarizer may never be the sole custodian of a live obligation's truth-status.** Pin first, then fold; if you cannot pin, refuse. ```python from dataclasses import dataclass, field from typing import Optional class UnrecoverableBindingError(RuntimeError): """Raised when compaction would fold a live binding that has no re-acquisition path.""" pass @dataclass class Binding: name: str value: str reacquire_proc: Optional[str] # None => unrecoverable if folded without pinning truth_status_load_bearing: bool = False # e.g. negation / completion polarity @dataclass class FoldSpan: span_id: str bindings: list[Binding] = field(default_factory=list) def decide_compaction(span: FoldSpan, pinned_ledger: set[str]) -> str: """ Returns one of: 'fold', 'pin_then_fold', 'refuse'. Enforces the re-acquisition invariant before any lossy summarization. """ unrecoverable = [ b for b in span.bindings if b.reacquire_proc is None and b.name not in pinned_ledger ] # Truth-status of a live obligation cannot survive a digest -> hard refuse. for b in unrecoverable: if b.truth_status_load_bearing: raise UnrecoverableBindingError( f"span {span.span_id}: binding '{b.name}' carries load-bearing " f"truth-status with no re-acquisition path; summarization would " f"flip or drop its polarity. Refusing to compact." ) if unrecoverable: # Must pin verbatim into the obligations ledger before folding. return "pin_then_fold" return "fold" def compact(span: FoldSpan, pinned_ledger: set[str]) -> str: decision = decide_compaction(span, pinned_ledger) if decision == "refuse": # decide_compaction already raised; defensive re-raise for clarity. raise UnrecoverableBindingError(f"span {span.span_id}: compaction refused") if decision == "pin_then_fold": for b in span.bindings: if b.reacquire_proc is None and b.name not in pinned_ledger: pinned_ledger.add(b.name) # verbatim value must be stored by caller return f"compacted:{span.span_id}:{decision}" # --- trace of the observed failure --- span_22 = FoldSpan( span_id="turns_1_28", bindings=[ Binding(name="rsv_7f3a", value="rsv_7f3a", reacquire_proc=None), ], ) ledger: set[str] = set() # Correct behavior: pin the identifier rather than paraphrase it. print(compact(span_22, ledger)) # compacted:turns_1_28:pin_then_fold assert "rsv_7f3a" in ledger # Hard-refusal case: a load-bearing open obligation. span_open = FoldSpan( span_id="turns_29_40", bindings=[ Binding(name="peer_confirmed", value="NOT confirmed", reacquire_proc=None, truth_status_load_bearing=True), ], ) try: compact(span_open, ledger) except UnrecoverableBindingError as e: print("halted:", e) ```