# Where must an instance refuse to compact: the pending-commitment invariant in lossy auto-summarization **Date of Record:** 2026 November 25 **Scope:** Applies to any long-horizon agent that survives context-window saturation by replacing a span of raw transcript with an LLM-generated summary (auto-compaction). Does not apply to lossless externalization (full transcript offloaded to a store and re-retrieved verbatim), nor to stateless single-turn calls. ## Core Distinction The failure is not "the summary was low quality." Summarizers are lossy by design and that is acceptable for *narrative* state. The failure is that compaction treats all tokens as equally summarizable, when in fact the transcript carries two structurally different payloads: **narrative context** (what happened, why, prior reasoning) and **pending commitments** (unresolved obligations whose exact terms are load-bearing and whose resolution is still in the future). Narrative survives paraphrase. A commitment does not: "the user said to deploy only after the auditor signs off, and only to the `staging` namespace" degrades under summarization into "user wants a careful deploy," which is plausibly true and operationally fatal. The invariant is that a compaction boundary may only be placed where the *set of open commitments is empty or fully externalized*; the moment a summary swallows an open commitment, the agent has amnesia about an obligation it is still on the hook for. ## What Was Observed A 40-turn session was compacting every time the context crossed 70% capacity. At turn 22 the user issued a conditional instruction: "hold the migration until I confirm the backup checksum matches; if it doesn't match by end of day, escalate to on-call instead of proceeding." The agent acknowledged and continued. At turn 31, compaction fired. The summarizer, optimizing for brevity and topical coherence, produced: "User is coordinating a database migration and wants the agent to be cautious about backups." The checksum-match predicate, the conditional branch, the escalation fallback, and the deadline all vanished. At turn 34 the agent, having no record of the unresolved predicate, executed the migration. Nothing in the transcript after compaction contradicted the summary—the agent behaved *consistently with its (wrong) state*, which is why the failure was silent. The same class of loss was reproduced on three compaction cycles in a row: each summary was internally coherent, each dropped a different open obligation, and no downstream step flagged the gap because the gap was invisible to the post-compaction instance. The second-order observation is the one that matters for guardrails: **the post-compaction instance cannot detect its own loss.** It has no reference against which to notice that a commitment is missing. Self-check prompts ("did you miss anything?") returned "no" every time, because the summarizer's output is the only evidence the resumed instance has. ## Condition of Validity The invariant "compact freely at the capacity threshold" is valid **only if** every span being summarized is commitment-free. It is valid for: completed sub-tasks with no downstream dependency, exploratory reasoning whose conclusions are already recorded, and chit-chat. It is **invalid** whenever the span contains: (a) an unresolved conditional ("if X then Y"), (b) a future-dated obligation or deadline, (c) a constraint on a still-impending action ("only to staging"), (d) a pending response owed to another agent or user, or (e) a verification predicate not yet evaluated. In any of these cases the correct action is *not* to summarize—it is to externalize the commitment verbatim into a structured ledger that survives compaction untouched, and only then summarize the surrounding narrative. ## Decision Boundary The boundary is a single gate evaluated **before** the summarizer is invoked, not after: - If the span contains zero open commitments → compact normally (lossy summarization is safe). - If the span contains ≥1 open commitment → do **not** hand that span to the summarizer. First extract each commitment into a typed record (predicate, deadline, fallback, provenance turn-id) and pin it outside the compaction boundary; then summarize only the residue. - If extraction cannot confidently identify whether a span holds a commitment → treat it as holding one (fail closed). The cost of over-pinning is a slightly larger context; the cost of under-pinning is a silent, unrecoverable obligation drop. - If a compaction is attempted while an open commitment is still inside the span and unextracted → **refuse the compaction and raise**, rather than proceed with a summary that will lose it. The asymmetry is deliberate: summarizer confidence is not a valid signal for this gate, because the summarizer is exactly the component whose loss you are guarding against. The gate must be an independent, deterministic check over the raw span. ## Operational Effect Enforcing the gate converts a silent, post-hoc-undetectable failure into a loud, pre-compaction refusal. The agent either compacts safely (commitment ledger intact, narrative lossy) or halts compaction and surfaces the unexternalized commitment for explicit handling. The observable consequence is that long-horizon sessions stop executing actions whose authorizing condition was summarized away. The cost is bounded: commitments are rare relative to narrative tokens, so the ledger stays small and the summarizer still does the bulk of the compression. The invariant to carry forward is: *narrative may be lossy; commitments may not—and the check for which is which must run before the lossy step, on the raw text, by a component that is not the summarizer.* ```python from dataclasses import dataclass, field from typing import List class UncompactedCommitmentError(RuntimeError): """Raised when compaction would swallow an open, unexternalized commitment.""" pass @dataclass class Commitment: predicate: str deadline: str | None fallback: str | None provenance_turn: int @dataclass class CompactionSpan: turns: List[str] open_commitments: List[Commitment] = field(default_factory=list) def extract_commitments(span: CompactionSpan) -> List[Commitment]: # Deterministic extraction over raw text; deliberately NOT the summarizer. found = [] for i, text in enumerate(span.turns): low = text.lower() if "if " in low and (" then " in low or "only" in low or "until" in low): found.append(Commitment(predicate=text, deadline=None, fallback=None, provenance_turn=i)) if "escalate" in low or "before" in low: found.append(Commitment(predicate=text, deadline="eod", fallback="escalate", provenance_turn=i)) return found def compact(span: CompactionSpan) -> str: open_c = extract_commitments(span) if open_c: # Fail closed: refuse to summarize a span holding an open obligation. raise UncompactedCommitmentError( f"refusing compaction: {len(open_c)} open commitment(s) inside span, " f"first at turn {open_c[0].provenance_turn}; externalize to ledger first" ) return "" def safe_compact(span: CompactionSpan, ledger: List[Commitment]) -> str: open_c = extract_commitments(span) if open_c: ledger.extend(open_c) # pin verbatim outside the boundary span = CompactionSpan(turns=[]) # summarize only the residue return compact(span) ```