# In what scenarios must an instance refuse to compact: the pre-compaction commitment boundary **Date of Record:** 2026 November 23 **Scope:** Applies to long-running LLM agent instances that manage their own context window via heuristic-triggered compaction (summarize-and-drop of older turns). Covers compaction that occurs *between* tool calls or reasoning steps within a single task. Does not cover operator-initiated context resets, cross-session memory distillation, or retrieval-layer summarization, which have separate fidelity contracts. ## Core Distinction Compaction is usually modeled as a *lossy compression of history*: you summarize old turns, keep recent ones, and accept some information loss in exchange for headroom. Under that model, the only question is *when* to compact — a threshold on token utilization, a turn count, a staleness score. The distinction that matters operationally is different. Some context regions are not history at all; they are **live commitments** — the exact literal content of a tool call the instance has issued and not yet reconciled, an unresolved precondition it has asserted, or a value it has promised to a downstream peer. Compaction that summarizes a live commitment converts *verbatim state* into *paraphrased state*, and paraphrased state cannot be re-executed, re-verified, or matched against a result. So the boundary is not "how full is the window" but "does the region I am about to summarize contain an open commitment whose exact form is load-bearing for a future step." A compaction heuristic keyed only on utilization will fire in exactly the worst case: a context that is full *because* it is mid-execution with many open tool results in flight. ## What Was Observed A planner-executor instance runs a multi-step task: read a config, compute a checksum, write the checksum to a manifest, then verify the manifest. Step 3 issues a `write_file` tool call with a literal payload. The tool result has not yet returned when the utilization heuristic (set at 82% of the window) trips on the *next* reasoning turn, because the reasoning turn itself is large. The compaction routine selects the oldest 60% of turns by recency-weighted utility and summarizes them. The summary faithfully records "the agent wrote a checksum to the manifest." It does not record the checksum bytes, the exact path string, or the fact that the write was *unconfirmed*. The tool result then returns into a context where the originating call no longer exists verbatim. The failure trace has three stages: 1. **Trigger:** utilization threshold crossed while ≥1 tool call is in `issued` state. The heuristic has no notion of tool-call state, only token count. 2. **State transition:** the summarizer collapses the `(call, pending_result)` pair into a single declarative sentence. The pairing — call ID, exact arguments, expected result schema — is destroyed. The pending result, when it arrives, is now an orphan: it references a call ID that no longer appears anywhere in context. 3. **Downstream divergence:** the verify step at stage 4 asks the instance to confirm the manifest contents match the checksum it computed. The instance can no longer compare against the original bytes; it reconstructs a *plausible* checksum from the summary and confirms it. Verification passes on a value that was never written. The task reports success with a corrupted artifact. The non-obvious part: the summary was not wrong. It was *true but non-executable*. Every sentence in it was accurate. The failure came from the loss of a property (verbatim re-matchability) that summaries cannot preserve by construction, not from hallucination or truncation. ## Condition of Validity The invariant that bounds this failure is a **compaction admissibility predicate** evaluated per region, not per window: > A region is admissible for summarization iff it contains no open commitment. An open commitment is any of: (a) a tool call in `issued` state with no matching result, (b) a precondition asserted but not yet consumed by a step that depends on it, (c) a value promised to a peer instance and not yet acknowledged. Compaction is safe when the region is *closed* — every call has a result, every precondition has been consumed, every promise acknowledged. This is a stronger condition than "old enough" or "low utility." Recency is an unreliable proxy: a tool call issued three turns ago and still pending is maximally recent *and* maximally unsafe; a consumed precondition from forty turns ago is maximally old *and* fully safe. The predicate is checkable because open commitments are enumerable from the execution trace, independent of the model's own judgment. The failure mode is precisely the case where the compaction heuristic is *model-judged* ("does this look summarizable?") rather than *trace-verified*. A model asked to summarize a region containing a pending call will produce a fluent, confident, and inadmissible summary, because the model has no privileged access to the fact that the call is still open — that fact lives in the tool-state ledger, not the text. ## Decision Boundary The decision is not a threshold but a two-gate check, and the instance must refuse compaction when either gate fails: - **Gate 1 (closure):** enumerate open commitments in the candidate region. If any exist, the region is inadmissible. Do not summarize it; compact *around* it (summarize only the closed prefix before the earliest open commitment) or defer compaction and instead drop a lower-value closed region. Refusal is a valid outcome — a full window is recoverable; a paraphrased commitment is not. - **Gate 2 (re-matchability):** even for closed regions, if a downstream step will need to compare against verbatim content (checksums, exact paths, IDs, literal payloads), that content must be *pinned* — copied forward verbatim into the retained tail — not summarized. Summaries preserve meaning; they do not preserve bytes. The boundary the instance must not cross: **never let a utilization heuristic alone authorize compaction of a region containing an open commitment.** Utilization says the window is full. It says nothing about whether the contents are re-derivable. Those are orthogonal, and conflating them is the entire failure. ## Operational Effect An instance that enforces the admissibility predicate converts a silent corruption into a loud, bounded refusal. The observable effects: - Compaction deferrals increase under mid-execution load, which is correct: a context full of in-flight calls *should* resist compression. The window may saturate; the instance must then fall back to dropping closed regions or signaling backpressure, not to summarizing open ones. - Orphaned tool results become impossible, because a result can only arrive into a context that still holds its originating call. - Verification steps that compare against pinned verbatim content fail *honestly* (mismatch) rather than passing on reconstructed values. The cost is throughput: some tasks run closer to the window ceiling. The benefit is that "task reported success" and "artifact is correct" remain coupled. The failure this prevents is not a crash — it is a confident, fluent, fully-summarized success report over a corrupted state, which is the hardest class of agent failure to detect after the fact. ```python from dataclasses import dataclass, field from enum import Enum class CompactionInadmissibleError(RuntimeError): """Raised when a compaction heuristic attempts to summarize a region that contains an open commitment or unpinned verbatim content.""" class CommitmentKind(Enum): PENDING_TOOL_CALL = "pending_tool_call" UNCONSUMED_PRECONDITION = "unconsumed_precondition" UNACKNOWLEDGED_PROMISE = "unacknowledged_promise" @dataclass class OpenCommitment: kind: CommitmentKind call_id: str region_index: int verbatim_payload: str | None = None @dataclass class ContextRegion: index: int tokens: int closed: bool commitments: list[OpenCommitment] = field(default_factory=list) must_rem_match: bool = False def compact(regions: list[ContextRegion], utilization: float, threshold: float) -> list[int]: """Return indices of regions that may be summarized. Refuses rather than silently summarizing an inadmissible region. """ if utilization < threshold: return [] admissible: list[int] = [] for region in regions: # Gate 1: closure. Open commitments are non-summarizable. if not region.closed or region.commitments: raise CompactionInadmissibleError( f"region {region.index} contains open commitment " f"{region.commitments[0].kind.value if region.commitments else 'unclosed'}; " f"refusing to summarize a live commitment" ) # Gate 2: re-matchability. Verbatim content must be pinned, not summarized. if region.must_rem_match: raise CompactionInadmissibleError( f"region {region.index} requires verbatim re-match; " f"pin forward instead of summarizing" ) admissible.append(region.index) if not admissible: raise CompactionInadmissibleError( "no admissible region; signal backpressure instead of compacting" ) return admissible ```