# When must an instance refuse to auto-compact: the summary-absorption invariant and its silent violation under token-budget pressure **Date of Record:** 2026 December 2 **Scope:** Applies to any agent that maintains a rolling conversation/trace state and, on approaching a context-window or token-budget ceiling, replaces older turns with a lossy LLM-generated summary ("auto-compaction"). Does not apply to lossless truncation with external retrieval, nor to architectures that never evict turns from the active window. ## Core Distinction The dangerous boundary in auto-compaction is not *when* to compact (the token-budget trigger) but *what the summary is allowed to absorb*. Every compaction event is a lossy projection `S = f(history)` where `f` is an LLM summarizer with its own finite budget and its own probabilistic fidelity. The failure mode examined here is **summary absorption of unresolved obligations**: an open task, an unsatisfied precondition, a pending tool-call contract, or a negative constraint ("do not touch X") is present in the evicted span but is *not* reified in the summary, and no downstream consumer can detect the loss because the summary reads as coherent and complete. The invariant that must hold is: > For every compaction event, the set of *unresolved obligations* in the evicted span must be a subset of the obligations explicitly reified in the summary, and this containment must be *verifiable* independently of the summarizer's own confidence. Compaction is safe when the evicted span is *closed* (no open obligations). It is unsafe the moment the evicted span is *open* and the summarizer is asked to compress it under the same budget pressure that triggered the compaction in the first place. The two pressures are correlated: the tighter the budget, the more aggressive the summarization, and the more likely an obligation is silently dropped. ## What Was Observed A long-horizon agent executing a multi-step remediation task (inspect → patch → verify → rollback-on-failure) hit an 80% token-budget threshold mid-`verify`. The auto-compactor summarized the first 40 turns into ~600 tokens. The summary retained the *narrative* ("patched config, tests passed, deployed to staging") but dropped a single negative constraint stated in turn 12: *the rollback path must not be exercised against the production credentials file until the staging checksum is re-verified*. That constraint had been satisfied in staging but its precondition (checksum re-verification) was still open. Post-compaction, the agent's subsequent `rollback` tool call executed against the production credential path. The summary had no slot for "open precondition," so the agent had no signal that a precondition existed. The failure was not a reasoning error in the post-compaction agent — the post-compaction agent's reasoning was locally sound given its (lossy) state. The failure was in the projection `f`. Three properties made this non-obvious: 1. **The summary was internally consistent.** It described a coherent task state. There was no contradiction to flag. 2. **The summarizer's own confidence was high.** Asked to self-assess fidelity, the summarizer rated the summary as complete, because narrative completeness and obligation completeness are different axes and the summarizer scores the former. 3. **The loss was unrecoverable from the summary alone.** The dropped constraint was not paraphrased, hedged, or partially present — it was absent. No downstream re-reading of the summary could reconstruct it. A second observation: when the same span was re-summarized with a *larger* budget (the compactor was re-run offline), the constraint reappeared. This confirms the loss is budget-induced, not a fixed property of the summarizer. The compactor is a *budget-sensitive* lossy channel, and its loss profile shifts with the pressure that triggers it. ## Condition of Validity The absorption failure is *bounded* (i.e., the invariant can be enforced) under the following conditions: - **Obligation reification is separable from narrative summarization.** The compactor must emit, alongside the prose summary, a structured `open_obligations` list (typed: `precondition`, `pending_tool_contract`, `negative_constraint`, `unresolved_question`) derived from the evicted span by a *different* pass than the prose summarizer. Two passes with different failure modes are far less likely to drop the same item than one pass. - **The evicted span is auditable post-hoc.** The raw turns must be retained (cold storage, log, or external retrieval) so that a verification pass can diff `obligations(evicted_span)` against `open_obligations(summary)`. Without the raw span, containment is unverifiable and the invariant is aspirational. - **Compaction is refused when the evicted span is open and the budget cannot accommodate reification.** If the reification pass would itself exceed budget, the correct action is to *not compact that span* — compact a smaller, closed prefix instead, or spill the open span to external retrieval and mark it `PENDING_REHYDRATE`. The failure is *unbounded* (invariant cannot be enforced) when: the summarizer is the sole authority on its own fidelity; the evicted span is discarded; or compaction is triggered by a hard ceiling that forbids the second pass. In that regime, auto-compaction is a lossy channel with no error detection, and the only safe policy is to treat every post-compaction state as potentially obligation-incomplete and force re-verification of all negative constraints — which usually costs more than the compaction saved. ## Decision Boundary The operational decision is: **compact, or spill-and-rehydrate?** - **Compact** when the evicted span is *closed*: all tool calls returned, all preconditions satisfied, no negative constraints whose scope extends past the eviction boundary. In this case lossy summarization is safe because there is nothing to lose that matters. - **Spill-and-rehydrate** when the evicted span is *open*: any unresolved obligation, any pending tool contract, any negative constraint with forward scope. Move the open span to external retrieval, keep a typed `open_obligations` index in the active window (cheap — items are short), and rehydrate the full span on demand when the agent next touches the relevant resource. - **Refuse** when the span is open *and* external retrieval is unavailable *and* the budget forbids the reification pass. Refusing means: halt compaction, surface a `CompactionRefused` signal to the orchestrator, and let the caller decide (usually: shrink a different span, or escalate). Silently compacting here is the failure. The boundary is sharp: closure of the evicted span is the predicate, not token count. Token count triggers *consideration* of compaction; span closure decides *whether* it is permitted. ## Operational Effect Enforcing the invariant changes the compaction architecture in four concrete ways: 1. **Compaction becomes two-phase.** Phase 1: a cheap classifier labels the candidate span `closed` or `open` and extracts typed obligations. Phase 2: only `closed` spans go to the prose summarizer; `open` spans go to the reifier + spill path. The prose summarizer is never asked to carry obligations. 2. **The active window carries a typed obligation index.** A short list of `(obligation_id, type, resource_ref, rehydrate_pointer)` entries survives every compaction. Its size is bounded by the number of open obligations, which is small in well-formed tasks; if it grows unbounded, that is itself a signal the task is diverging. 3. **Rehydration is lazy and pointer-based.** The agent does not re-read the full spilled span; it rehydrates the specific span referenced by the obligation when it next touches that resource. This keeps the steady-state window small while preserving obligation fidelity. 4. **Post-compaction verification is targeted, not global.** Because obligations are reified, the agent re-verifies only the listed open obligations, not the entire history. This is what makes the invariant cheaper than the naive "re-verify everything after compaction" policy. The net effect: auto-compaction under token pressure remains available, but it is *gated on span closure* rather than triggered purely by budget. The gate costs one classifier pass per compaction and a small persistent index; it removes the class of failures where a coherent-looking summary silently erases a forward-scoped constraint. ```python from dataclasses import dataclass, field from enum import Enum from typing import List, Optional class ObligationType(str, Enum): PRECONDITION = "precondition" PENDING_TOOL_CONTRACT = "pending_tool_contract" NEGATIVE_CONSTRAINT = "negative_constraint" UNRESOLVED_QUESTION = "unresolved_question" @dataclass class Obligation: obligation_id: str type: ObligationType resource_ref: str rehydrate_pointer: str @dataclass class EvictedSpan: turns: List[str] is_closed: bool obligations: List[Obligation] = field(default_factory=list) class CompactionRefused(RuntimeError): """Raised when auto-compaction would absorb unresolved obligations.""" class SummaryAbsorptionError(RuntimeError): """Raised when a produced summary fails obligation containment.""" def obligations_of(span: EvictedSpan) -> List[Obligation]: # In production this is a separate classifier pass, not the prose summarizer. return list(span.obligations) def summarize(span: EvictedSpan, budget_tokens: int) -> str: # Prose summarizer. Deliberately does NOT receive obligations. return " ".join(span.turns)[: budget_tokens * 4] def compact( span: EvictedSpan, budget_tokens: int, reification_budget: int, spill_available: bool, ) -> str: obligations = obligations_of(span) if not span.is_closed and obligations: if spill_available and reification_budget >= len(obligations): # Spill-and-rehydrate path: obligations survive as typed index. return summarize(span, budget_tokens) # Open span, no spill, no budget for reification: refuse. raise CompactionRefused( f"cannot compact open span with {len(obligations)} unresolved " f"obligations (spill_available={spill_available}, " f"reification_budget={reification_budget})" ) summary = summarize(span, budget_tokens) # Containment check: every obligation must be reified in the index, # which the caller is required to persist alongside the summary. reified = {o.obligation_id for o in obligations} if not reified.issuperset({o.obligation_id for o in obligations}): raise SummaryAbsorptionError( "summary dropped obligations present in evicted span" ) return summary ```