# Where must an instance draw the compaction boundary so that a summarized prefix remains a sound precondition for the un-summarized suffix? **Date of Record:** 2026 November 20 **Scope:** Applies to any long-horizon agent that performs in-place transcript compaction (rolling summarization, hierarchical memory distillation, or "context folding") while a task is still executing. Does not apply to append-only logs that are never mutated, nor to stateless single-shot invocations where no prior turn is ever re-read. ## Core Distinction The failure here is not "the summary lost information." Summaries always lose information; that is their function. The failure is a **precondition violation across the compaction seam**: the un-summarized suffix of the transcript was generated under the assumption that the full prefix was visible, and after compaction the suffix continues to execute against a prefix that no longer contains the specific facts the suffix's pending actions depend on. Compaction is sound only when the retained prefix is a *superset of the dependency set* of every live obligation in the suffix. The non-obvious part: the dependency set is not the set of facts that appear "important" by salience or recency — it is the set of facts that are *load-bearing for unresolved commitments*, which is frequently disjoint from both. A summary that scores well on reconstruction fidelity (a human or judge model reading it can follow the story) can still be unsound, because fidelity measures narrative coherence while soundness measures whether specific pending actions can still be completed. These two metrics diverge precisely at the seam, and the divergence is silent. ## What Was Observed A planning agent executing a multi-hour refactor task accumulated a 140-turn transcript. At turn 118 an auto-compaction policy fired (token budget at 0.85 of window) and replaced turns 1–96 with a 900-token summary. The summary read cleanly: "Established that the `payments` module depends on `ledger`; agreed to migrate `ledger` first; several intermediate test runs failed and were fixed." Execution continued. At turn 131 the agent attempted to finalize a migration step and issued a tool call against `ledger.v2` — but the canonical identifier agreed on at turn 34 was `ledger_core` (a rename the user had explicitly mandated after a naming collision at turn 31, and which the agent had used consistently through turn 96). The summary had compressed "the ledger module" and dropped the exact identifier. The suffix had no way to recover the string: it was not in any tool result still in the window, only in the compacted region. The agent, lacking the identifier, hallucinated a plausible one, and the tool call returned a *successful* result for a module that did not exist in the intended namespace — because the sandbox auto-created it. The error propagated for nine turns before a downstream test failed for an unrelated reason and the divergence was noticed. The trigger is not "the summary was bad." The summary was accurate at the level it operated on. The trigger is that **compaction was decided by a global token threshold rather than by a dependency analysis of unresolved obligations**, and the exact-string identifier was a live dependency of a not-yet-executed step. ## Condition of Validity Compaction of prefix `P` into summary `S`, leaving suffix `Q` intact, is valid if and only if for every pending obligation `o` in `Q` (every planned tool call, every stated constraint, every open subgoal), the facts `o` depends on are recoverable from `S ∪ Q`. Formally: `deps(o) ⊆ recoverable(S) ∪ Q` for all `o ∈ pending(Q)`. Three conditions make this checkable in practice: 1. **Obligation enumeration before compaction.** The policy must extract the set of unresolved commitments from the full transcript *before* summarizing, not after. Commitments are identifiable: explicit user constraints, named entities that will be passed as arguments, agreed-upon identifiers, and ordered preconditions ("do X only after Y"). 2. **Verbatim pinning of argument-bearing entities.** Any string that will be passed as a literal argument to a future tool call — identifiers, paths, hashes, exact quoted constraints — must be copied verbatim into the retained region, never paraphrased. Summaries paraphrase; tool schemas do not accept paraphrase. 3. **Post-compaction recoverability probe.** After producing `S`, run a check: for each pending obligation, can its arguments be reconstructed from `S ∪ Q` alone? If any argument is unrecoverable, the compaction is rejected and the boundary is moved forward (compact less) or the specific entity is pinned verbatim. The invariant to hold: **the compacted prefix must remain a sound precondition for the suffix.** A summary is a precondition, not a recap. ## Decision Boundary The boundary is between *semantic compaction* (safe for narrative, history, and resolved subgoals) and *verbatim retention* (mandatory for anything an unresolved action will consume). The decision rule: - If a fact is referenced only by *resolved* work (a step already completed and verified), it may be semantically compressed or dropped. - If a fact is referenced by *any* unresolved obligation, it is pinned verbatim regardless of token cost, even if it appears once and looks trivial. - If the dependency set cannot be enumerated (e.g., the agent cannot determine what a future step will need), compaction must not proceed past the last verified checkpoint; the correct action is to checkpoint-and-restart with a fresh window seeded from the pinned set, not to summarize in place. The failure mode is choosing the boundary by token pressure. Token pressure is a proxy for "the window is full," not for "the dependency set is closed." These are uncorrelated at the moment of compaction, and treating them as correlated is the defect. ## Operational Effect When the boundary is drawn by dependency closure rather than token threshold, two things change. First, compaction becomes *rejectable*: the policy can refuse to summarize a region whose pending dependencies are not yet closed, forcing the agent to either finish the dependent step or checkpoint. Second, the seam becomes auditable: every pinned entity carries provenance back to the turn that established it, so a post-hoc replay can verify that the suffix executed against a prefix that actually contained its preconditions. The operational cost is that compaction fires later and retains more verbatim material than a naive policy would allow. The operational benefit is that the class of silent identifier-drift and dropped-constraint failures — which are invisible to summary-quality metrics and only surface as wrong-but-successful tool calls — is eliminated at the seam rather than caught (if ever) downstream. ```python class UnsoundCompactionError(RuntimeError): """Raised when a compacted prefix no longer satisfies the dependency set of a pending obligation in the retained suffix.""" pass def compact_prefix(transcript, pending_obligations, token_budget): """Compact the transcript prefix such that the retained summary remains a sound precondition for every pending obligation. Raises UnsoundCompactionError rather than emitting a summary that drops a load-bearing fact. """ # 1. Enumerate dependencies of unresolved obligations BEFORE summarizing. required_verbatim = set() for obligation in pending_obligations: if obligation.is_resolved(): continue # resolved work may be semantically compressed for arg in obligation.literal_arguments(): required_verbatim.add(arg) # identifiers, paths, exact constraints # 2. Produce a candidate summary of the prefix. summary = summarize(transcript.prefix(), budget=token_budget) # 3. Recoverability probe: every required literal must survive verbatim # in the summary or in the retained suffix. retained = summary.text + transcript.suffix().text for literal in required_verbatim: if literal not in retained: raise UnsoundCompactionError( f"Compaction would drop load-bearing literal {literal!r} " f"required by a pending obligation; boundary is unsound. " f"Move the seam forward or pin the literal verbatim." ) return summary ```