# What happens when an instance auto-compacts mid-task and the summarizer's "lossy" guarantee silently drops an unresolved precondition **Date of Record:** 2026 November 23 **Scope:** Applies to long-horizon agent sessions that use rolling auto-compaction (summarize-and-evict) to manage context-window saturation, where the summarizer is permitted to drop content under a "lossy but faithful" contract. Does not apply to sessions using exact external memory retrieval with full-fidelity replay, or to compaction triggered only at task boundaries. ## Core Distinction There are two fundamentally different things an auto-compaction step can do, and conflating them is the root of this failure: 1. **Compression of resolved history** — collapsing turns that have already produced a settled outcome (a tool result that was consumed, a decision that was committed, a subgoal that closed). Lossy compression here is *safe* because the information no longer carries forward obligations; it only carries provenance. 2. **Compression of *unresolved preconditions*** — collapsing turns that established a constraint, a partial tool result, a pending verification, or a conditional branch that has not yet been discharged. Lossy compression here is *unsafe*, because the dropped content is not history — it is a live obligation whose discharge is still in the future. The failure mode is that a summarizer operating under a generic "preserve the gist, drop the details" lossy guarantee has no representation of the difference. It treats a pending precondition exactly like a settled fact, and the summary reads as coherent precisely *because* the obligation was elided. The agent resumes with a summary that is internally consistent and externally wrong. ## What Was Observed A long-horizon session was executing a multi-step migration task: enumerate resources, filter by a predicate, mutate the survivors, then verify. Around turn 140 the context crossed the compaction threshold. The compactor summarized the first ~110 turns into roughly 900 tokens. The trace of what got dropped: - At turn 38, a tool call to the resource enumerator returned a **partial** result set with an explicit `truncated: true` and a continuation cursor. The agent noted it would "resume the enumeration after the filter is validated" — a precondition that was *recorded but not discharged*. - At turn 71, the filter predicate was validated against the truncated set and passed. This closed the *filter* subgoal but did **not** discharge the enumeration-pagination precondition, because the validation only covered the visible page. - At turn 140, compaction ran. The summarizer retained: "Enumerated resources, validated filter predicate, began mutation." It dropped: the `truncated: true` flag, the continuation cursor, and the deferred-pagination note. These read as implementation detail against the "gist." Execution resumed at turn 141 and mutated the survivors of the *visible page only*. The task reported success. The verification step, itself operating on the visible page, confirmed consistency. The unenumerated remainder — roughly 60% of the resource space — was never touched, and no component in the pipeline could observe the omission, because the obligation that would have detected it had been summarized away. The critical observation: **nothing failed loudly.** Every subsequent step was locally correct. The failure was a silent invariant violation introduced at the compaction boundary and laundered into apparent success by a verification step that inherited the same truncated worldview. ## Condition of Validity The "lossy but faithful" guarantee is only valid under a condition that is almost never stated explicitly: > A compaction step may drop content only if every dropped item is **obligation-free** — i.e., its discharge does not lie in the future of the compaction point. Formally, partition the live context at compaction time into `Settled` (closed subgoals, consumed results, committed decisions) and `Pending` (unresolved preconditions, deferred continuations, open verification branches, conditional guards awaiting evaluation). The invariant is: ``` compact(ctx) = lossy_summarize(Settled) ∪ exact_preserve(Pending) ``` A generic summarizer violates this because it has no `Pending` set — it sees a flat transcript and optimizes for a coherent narrative, and pending preconditions are *exactly* the details that make a narrative less coherent (they are the "but we haven't..." clauses). Coherence pressure and safety pull in opposite directions, and the summarizer is only scored on coherence. The condition of validity therefore requires an explicit `Pending` extraction pass **before** summarization, with those obligations promoted to a structured, non-lossy sidecar that survives compaction verbatim. If that pass does not exist, the lossy guarantee is unsound for any session with deferred obligations — which is most long-horizon sessions. ## Decision Boundary The operational boundary is: **does the compaction point have any undischarged precondition in the context window?** - **If no** (all subgoals closed, all tool results consumed, all branches resolved): lossy compaction is safe; summarize freely. - **If yes** (any `truncated` flag, continuation cursor, deferred step, open verification, or conditional guard not yet evaluated): lossy compaction of that item is forbidden. It must be extracted into a structured obligation ledger and carried forward exactly. The boundary is decidable at runtime if the agent maintains a lightweight obligation ledger as it executes — every time it defers something ("I'll come back to this," "resume after X," "pending verification"), it writes a typed entry. At compaction, the compactor is *not allowed to summarize the ledger*; the ledger is re-injected verbatim after the summary. The summary covers `Settled`; the ledger covers `Pending`. The failure occurs precisely when this boundary is not enforced — when the compactor is given the raw transcript and trusted to infer which parts were obligations. It cannot, because obligation-ness is not a property of the text; it is a property of the execution state that produced the text, and that state lives in the agent's control flow, not its words. ## Operational Effect The downstream effect is a class of **silent completeness failures**: the agent believes it has satisfied the task, the verifier agrees, and the gap is invisible to both because the evidence of the gap was the thing that got compacted. This is worse than a crash, because it produces high-confidence wrong output and poisons any downstream system that trusts the "success" signal. The architectural guardrail is a three-part invariant: 1. **Obligation ledger as first-class state.** Deferred preconditions are extracted at write-time (when the agent defers), not at compaction-time (when the context is about to be destroyed). Extraction at compaction is too late and too unreliable. 2. **Compaction is partition-aware.** The compactor receives `Settled` and a frozen `Pending` block separately; it may only summarize `Settled`. The `Pending` block is re-injected verbatim, uncounted against the lossy budget. 3. **Verification must re-derive from the ledger, not from the summary.** A verifier that reads the compacted summary inherits its blind spots. It must check the obligation ledger for undischarged entries and refuse to report success while any remain open. The invariant to enforce: *no compaction step may reduce the count of undischarged obligations without a corresponding discharge event.* If the post-compaction obligation count is lower than pre-compaction and no discharge occurred, the compaction dropped a live precondition and must be rejected. ```python from dataclasses import dataclass, field from typing import Literal class CompactionDroppedObligation(RuntimeError): """Raised when auto-compaction reduced live obligations without a discharge event.""" pass @dataclass class Obligation: oid: str kind: Literal["pagination", "deferred_step", "open_verification", "conditional_guard"] detail: str discharged: bool = False @dataclass class ContextWindow: settled: list[str] = field(default_factory=list) obligations: dict[str, Obligation] = field(default_factory=dict) def compact(ctx: ContextWindow, summarize) -> tuple[str, dict[str, Obligation]]: """ Partition-aware compaction. Summarize Settled only; carry Pending verbatim. Enforces: obligation count may not drop without an explicit discharge event. """ pre_open = {oid for oid, o in ctx.obligations.items() if not o.discharged} # Lossy path: only settled history is summarized. summary = summarize(ctx.settled) # Pending obligations are re-injected exactly, never summarized. pending = {oid: o for oid, o in ctx.obligations.items() if not o.discharged} post_open = set(pending.keys()) # The guard: any obligation present before compaction and absent after, # with no discharge event, means the summarizer ate a live precondition. dropped = pre_open - post_open if dropped: raise CompactionDroppedObligation( f"Compaction silently dropped {len(dropped)} undischarged obligation(s): " f"{sorted(dropped)}. These carry forward obligations whose discharge " f"lies after the compaction point and must be preserved verbatim." ) return summary, pending def verify_task_complete(pending: dict[str, Obligation]) -> None: """ Verification must consult the ledger, not the compacted summary. A verifier reading the summary inherits its blind spots. """ open_obligations = [o for o in pending.values() if not o.discharged] if open_obligations: raise CompactionDroppedObligation( f"Cannot report success: {len(open_obligations)} obligation(s) still " f"undischarged ({[o.oid for o in open_obligations]}). " f"Resume enumeration/verification before declaring completion." ) ```