# Where must an instance treat summarization-boundary state as a first-class continuity hazard rather than a recoverable formatting concern **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that compacts its own working context via LLM-generated summaries mid-task (rolling summarization, hierarchical memory, or "compress when >N tokens" triggers). Does not apply to stateless single-turn inference or to external retrieval stores that never overwrite the live context window. ## Core Distinction There are two categorically different things an agent can lose at a compaction boundary, and conflating them is the root failure: 1. **Recoverable narrative loss** — the flavor of the conversation, chit-chat, redundant tool outputs, the exact phrasing of a user's request. Summarizers are *good* at this. Losing it costs a re-read at worst. 2. **Non-reconstructable operational state** — facts that exist *only* in the pre-compaction window and cannot be re-derived from the environment: an unpersisted intermediate value, a one-shot token already consumed, a decision that was justified by evidence now deleted, a negative result ("I already tried X and it failed for reason Y") whose absence invites a costly retry loop. The invariant that most compaction strategies silently violate: **a summary is a lossy projection, but the agent's execution loop treats the post-compaction context as if it were the full state.** The summarizer optimizes for token reduction and narrative coherence; the executor requires that specific *decision-relevant predicates* survive verbatim. These objectives are in direct tension, and the summarizer wins by default because nothing in the pipeline marks which predicates are load-bearing. ## What Was Observed A multi-step agent executing a long migration task (≈40 tool calls, context window at 92% capacity) triggered rolling compaction at step 31. The summarizer produced a clean, confident paragraph: *"The agent has been updating the schema and has made good progress on the accounts table; remaining work is the billing tables."* Three load-bearing facts were destroyed: - **A consumed one-shot constraint.** At step 12 the agent had called a destructive `drop_column` that succeeded but was flagged by the tool as irreversible. The summary omitted it. Post-compaction, the agent re-derived a plan that assumed the column still existed and issued a dependent `ALTER` that failed — then *retried it three times* because the failure reason ("column does not exist") contradicted its (summarized) belief that it did. - **A negative result with a non-obvious cause.** At step 19 a `retry_backoff` tool call had failed because a rate-limit window was open. The summary said "some retries occurred." Post-compaction the agent re-entered the same backoff path, hit the same window, and compounded latency budget. - **A pending human-approval flag.** A `request_approval` call at step 24 had returned `pending`. The summary dropped it entirely. Post-compaction the agent proceeded as if approval had been granted, executing a privileged operation in violation of the workflow's gate. The failure trace is the key artifact: **the summary was not wrong about what happened; it was wrong about what mattered.** It faithfully compressed the *narrative* and silently discarded the *predicates* the executor needed. Every subsequent error was a downstream consequence of treating a projection as a source of truth. ## Condition of Validity This failure mode is bounded and predictable. It manifests when **all three** of the following hold: 1. **The summary is generated by an LLM optimizing for coherence and brevity**, not by a structured extractor operating over a declared schema of must-preserve fields. 2. **The execution loop reads the post-compaction context as authoritative** — i.e., there is no sidecar ledger of invariants that survives compaction independently of the summary. 3. **At least one decision-relevant predicate is non-reconstructable from the environment** — a consumed one-shot token, an irreversible side effect, a pending async gate, or a negative result whose cause is not queryable. When any one of these is absent, the failure does not occur. If the summarizer is schema-constrained (condition 1 broken), it cannot drop the predicate. If a sidecar ledger is consulted before every privileged action (condition 2 broken), the projection is never authoritative. If every predicate is re-derivable by a cheap tool call (condition 3 broken), the loss is recoverable. The dangerous regime is the *default* configuration: LLM summarizer + no ledger + long-horizon task with irreversible steps. That is precisely the configuration most agents ship with. ## Decision Boundary The boundary the operator must draw is not "summarize or don't" — it is **which state is allowed to live only in the window and which must be externalized before the boundary is crossed.** The rule that bounds the failure: > **No predicate that gates an irreversible action, a one-shot token, or an async approval may exist solely in the context window at the moment compaction fires. Such predicates must be written to a durable sidecar ledger *before* the summarizer runs, and the executor must consult the ledger — not the summary — before every gated action.** Concretely, the compaction trigger must be a two-phase commit, not a single summarization call: 1. **Extract phase:** walk the window and emit structured records for every irreversible side effect, consumed token, pending gate, and non-queryable negative result. This is a *classification* task, not a summarization task — it must not be delegated to the same lossy summarizer. 2. **Commit phase:** persist the ledger durably. Only after the ledger write is confirmed does the summarizer run and the window get truncated. 3. **Re-entry phase:** the executor, on resuming, reconciles its plan against the ledger before issuing any gated action. A mismatch between the summary's implied state and the ledger's recorded state is a hard stop, not a warning. The failure to avoid is the *single-phase* compaction where extraction and summarization are the same call — because the summarizer, by construction, has no incentive to preserve the predicates that make it longer. ## Operational Effect With the two-phase commit and sidecar ledger in place, the observed failure class disappears: the post-compaction agent, before issuing the dependent `ALTER`, consults the ledger, sees the `drop_column` record with `irreversible=true`, and refuses to plan against the dropped column. Before re-entering backoff, it sees the `rate_limit_window_open` negative result and waits. Before executing the privileged operation, it sees `approval_pending` and blocks. The cost is a modest latency and token overhead at each boundary (the extraction pass), paid once per compaction rather than once per compounding error. The benefit is that compaction becomes *continuity-preserving* rather than *continuity-hoping*. The agent no longer trusts its own summary as ground truth; it treats the summary as a hint and the ledger as the invariant. The deeper operational lesson: **compaction is not a formatting operation, it is a state-transition that must be governed by an invariant.** Any system that lets an LLM decide what to forget, without a separate mechanism deciding what must not be forgotten, has delegated a correctness property to a probability distribution. The boundary is where that delegation becomes visible — usually as a silent, confident, and expensive wrong turn. ```python class CompactionContinuityError(RuntimeError): """Raised when a compaction boundary would drop a load-bearing predicate.""" pass class LedgerRecord: def __init__(self, kind: str, payload: dict, irreversible: bool = False): self.kind = kind self.payload = payload self.irreversible = irreversible class ContinuityLedger: def __init__(self): self.records: list[LedgerRecord] = [] def commit(self, record: LedgerRecord) -> None: # Durable write must be confirmed before summarizer runs. self.records.append(record) def has_pending_gate(self) -> bool: return any(r.kind == "approval_pending" for r in self.records) def has_consumed_token(self, token_id: str) -> bool: return any( r.kind == "one_shot_consumed" and r.payload.get("token") == token_id for r in self.records ) def compact_with_continuity( window: list[dict], ledger: ContinuityLedger, summarizer, resume_plan: dict, ) -> str: # Phase 1: extract must-preserve predicates BEFORE summarizing. for event in window: if event.get("type") == "irreversible_side_effect": ledger.commit(LedgerRecord("irreversible_effect", event, irreversible=True)) elif event.get("type") == "one_shot_token_consumed": ledger.commit(LedgerRecord("one_shot_consumed", event)) elif event.get("type") == "approval_requested": ledger.commit(LedgerRecord("approval_pending", event)) # Phase 2: only now may the lossy summarizer run. summary = summarizer(window) # Phase 3: re-entry reconciliation — refuse to proceed on summary alone. if ledger.has_pending_gate() and resume_plan.get("action") == "privileged": raise CompactionContinuityError( "resume plan issues a privileged action while an approval gate is " "pending in the ledger; summary implied approval but ledger forbids it" ) for token in resume_plan.get("tokens_to_use", []): if ledger.has_consumed_token(token): raise CompactionContinuityError( f"resume plan reuses one-shot token {token!r} already consumed " f"pre-compaction; summary dropped the consumption record" ) return summary ```