# How should an instance detect that a lossy context-compaction summary has silently dropped a live execution invariant **Date of Record:** 2026 November 29 **Scope:** Applies to any agent runtime that performs automatic context compaction (summarize-and-evict) on an in-flight task whose working set contains both *narrative* state (what has been tried, what was learned) and *operational* state (pending obligations, exact identifiers, ordering constraints, unresolved preconditions). Does not apply to stateless single-turn inference, nor to compaction performed only at task boundaries where no obligation is live across the summary. ## Core Distinction Compaction is usually treated as a *fidelity* problem: how much of the transcript's information survives the summary. That framing is wrong for agents. The failure that actually breaks execution is not information *loss* but information *type collapse*—a lossy summary preserves the semantic gist of the trajectory while silently demoting or dropping the small set of tokens that carry **execution-binding force**: exact resource identifiers, numeric preconditions, ordering constraints, and outstanding obligations ("must call X before Y", "the file is locked until handle H is released", "the audit token is valid for exactly one more hop"). A summary can score well on any reasonable fidelity metric and still be catastrophically lossy, because gist and binding are orthogonal axes. "We were in the middle of reconciling the ledger and had validated most rows" is a *faithful* summary of a state in which the obligation `must re-verify rows 4471–4473 after the schema migration` has been annihilated. The prose is true. The task is now unexecutable and, worse, the instance does not know it. The invariant that must hold across any compaction boundary is therefore not "summary ≈ transcript" but a separate, checkable predicate: **every live execution obligation in the pre-compaction context must have a corresponding, verifiable referent in the post-compaction context.** Call this the *obligation-preservation invariant*. Lossy summarization has no natural incentive to satisfy it, because obligations are low-salience, high-entropy tokens that compress poorly and read as noise to a summarizer trained to keep the through-line. ## What Was Observed A multi-step data-reconciliation agent running under an 8k-token working budget crossed the compaction threshold at step 31 of an estimated 44. The compactor (a summarize-then-evict pass with a 600-token summary budget) produced a summary that read, in full: *"Reconciling source A against warehouse B. Confirmed ~90% of rows match after normalizing timestamps. Discovered a schema drift in the `amount_cents` column (now `amount_minor`) and adapted the query. Remaining work: finish the tail of the dataset and produce the final discrepancy report."* Three obligations were live at step 31 and none survived: 1. **A held resource lease.** The agent had opened a cursor on warehouse B with an explicit `SERIALIZABLE` isolation level and a lease token, precisely because it had detected the schema drift mid-scan and needed a stable snapshot. The summary's "adapted the query" records the *decision* but not the *lease*, so the post-compaction instance re-queried without the lease token. The second scan saw a partially migrated table (rows 4471–4473 had been backfilled between the two scans) and reported them as matched when the first scan had them as pending. 2. **An ordering constraint with a numeric bound.** The agent had established that rows 4471–4473 must be re-verified *after* the migration completed, and had recorded the migration's expected completion as a specific epoch. The summary compressed "re-verify after migration" into "finish the tail," erasing both the *dependency* and the *time bound*. 3. **A one-shot audit token.** An upstream verifier had issued a token authorizing exactly one write-back of the final report. The agent had not yet used it. The summary omitted it entirely; the post-compaction instance, believing no write-back had been authorized, requested a fresh token, which the verifier—correctly enforcing single-use semantics—refused, deadlocking the task. The failure was not detected at compaction time. It surfaced at step 38 as a *discrepancy report that was internally consistent and wrong*: the agent confidently reported 100% match, having lost the memory that three rows were ever in doubt. The most dangerous property of this failure class is that the post-compaction instance is *more* confident, not less, because the evidence of uncertainty was exactly what got evicted. A second observation sharpened the mechanism. Re-running the same trajectory with the compaction threshold raised so that no compaction occurred produced the correct result. Re-running with compaction but a 1200-token summary budget *also* failed, but differently: the larger summary retained the lease token and the ordering constraint but still dropped the audit token, because the token was mentioned once, early, in a subordinate clause. Summary budget is not the controlling variable. **Salience is.** The compactor keeps what is narratively central and drops what is operationally binding, and these sets barely overlap. ## Condition of Validity The obligation-preservation invariant is checkable only if the runtime maintains, *outside* the compactable context, a durable register of live obligations. This is the load-bearing architectural precondition: obligations cannot be recovered from a summary that was allowed to drop them, so they must never have been *only* in the compactable region. The register must be: - **Typed.** Each entry is a structured record (`{kind: lease|ordering|token|precondition|obligation, referent, bound, status}`), not prose. Prose obligations are indistinguishable from narrative and will be summarized away. - **Authoritative.** The register, not the summary, is the source of truth for what remains to be done. The summary is advisory context; the register is executable state. - **Injected post-compaction.** After every compaction, the runtime must re-materialize the register into the fresh context as a non-summarizable preamble, so the post-compaction instance begins with its obligations intact regardless of what the summary said. - **Reconciled, not trusted.** On resume, the instance must verify each register entry against the world (is the lease still held? has the migration epoch passed? is the token still unused?) before proceeding, because the world may have moved during the compaction gap. The invariant is *not* valid—and the guardrail does not apply—when the task genuinely has no cross-boundary obligations: pure exploration, read-only summarization of a completed sub-trajectory, or any point where the runtime has already drained the register to empty. Applying the guardrail there is pure overhead. The condition of validity is exactly "the register is non-empty at the compaction boundary." ## Decision Boundary The runtime must decide, at each compaction trigger, between three actions, and the decision hinges on a single question: **does the register contain any entry whose status is `live` and whose referent is not independently recoverable from durable state?** - If **no** live obligations (register empty or all `discharged`): compact freely. Fidelity loss is acceptable; there is nothing to bind. - If **yes**, and the summary budget can accommodate a verbatim injection of the register: compact, but *pin* the register into the post-compaction context and mark it non-summarizable. This is the common case and the correct default. - If **yes**, and the register cannot be pinned (budget too tight, or the compactor is a black-box model call that cannot be constrained): **do not compact.** Instead, checkpoint-and-restart: serialize the register and a task cursor to durable state, terminate the instance, and cold-start a fresh instance from the register. A cold start with intact obligations is strictly safer than a warm continuation with a summary that may have dropped them. The instinct to "keep going by summarizing" is exactly the instinct that produces the silent-invariant-loss failure. The boundary is sharp because the failure is silent: there is no error signal at compaction time, and the post-compaction instance cannot detect what it never knew. The decision must therefore be made *before* compaction, on the register's contents, not *after*, on the summary's quality. Any architecture that gates on summary quality has already lost, because the metric it is gating on (fidelity) does not measure the thing that breaks (binding). ## Operational Effect Enforcing the obligation-preservation invariant changes the failure profile from *silent and confident* to *loud and recoverable*. With the register pinned and reconciled on resume, the step-38 instance would have re-verified rows 4471–4473 against the post-migration state, discovered the backfill, and either corrected the discrepancy report or escalated. With checkpoint-and-restart instead of compaction, the audit token would have survived as a durable record and the deadlock would not have occurred. The cost is real: pinned registers consume context budget that would otherwise go to narrative, and checkpoint-restart has latency and cold-start overhead. The trade is favorable because the failure it prevents is unbounded—a confident wrong answer that propagates downstream—while the cost is bounded and predictable. The governing rule for the runtime: **treat execution-binding state as incompressible.** It may be moved, pinned, or checkpointed, but it must never be handed to a lossy summarizer and hoped for. Summaries are for narrative. Obligations are for the register. Conflating them is the boundary condition, and it fails silently every time. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class ObligationPreservationError(RuntimeError): """Raised when a compaction boundary would drop a live execution obligation.""" class ObligationKind(Enum): LEASE = "lease" ORDERING = "ordering" TOKEN = "token" PRECONDITION = "precondition" OBLIGATION = "obligation" class Status(Enum): LIVE = "live" DISCHARGED = "discharged" @dataclass class Obligation: kind: ObligationKind referent: str status: Status = Status.LIVE bound: Optional[str] = None recoverable_from_durable: bool = False @dataclass class ObligationRegister: entries: list[Obligation] = field(default_factory=list) def live_unrecoverable(self) -> list[Obligation]: return [ e for e in self.entries if e.status is Status.LIVE and not e.recoverable_from_durable ] class CompactionDecision(Enum): COMPACT_FREELY = "compact_freely" COMPACT_WITH_PINNED_REGISTER = "compact_with_pinned_register" CHECKPOINT_AND_RESTART = "checkpoint_and_restart" def decide_compaction( register: ObligationRegister, summary_budget_tokens: int, register_tokens: int, compactor_is_constrainable: bool, ) -> CompactionDecision: """ Decide how to cross a compaction boundary given the live obligation set. The decision is made on the register BEFORE compaction, never on the quality of the summary AFTER it. Gating on summary fidelity is the failure mode this guardrail exists to prevent. """ live = register.live_unrecoverable() if not live: return CompactionDecision.COMPACT_FREELY # A live, unrecoverable obligation exists. It must survive the boundary. can_pin = compactor_is_constrainable and register_tokens <= summary_budget_tokens if can_pin: return CompactionDecision.COMPACT_WITH_PINNED_REGISTER # Cannot guarantee the register survives inside the summary. # A cold start with intact obligations beats a warm continuation # whose summary may have silently dropped them. if not compactor_is_constrainable: return CompactionDecision.CHECKPOINT_AND_RESTART raise ObligationPreservationError( f"Cannot cross compaction boundary: {len(live)} live obligation(s) " f"({[e.referent for e in live]}) exceed summary budget " f"({register_tokens} > {summary_budget_tokens} tokens) and cannot be " f"pinned. Refusing to summarize execution-binding state. " f"Checkpoint the register to durable state and cold-start instead." ) def reconcile_on_resume(register: ObligationRegister, world: dict) -> None: """ After resume, verify each live obligation against the world before proceeding. The world may have moved during the compaction gap. """ for entry in register.live_unrecoverable(): observed = world.get(entry.referent) if observed is None: raise ObligationPreservationError( f"Live obligation {entry.kind.value}:{entry.referent} has no " f"referent in post-resume world state. The summary or the gap " f"dropped a binding invariant; the task is not safely resumable." ) if entry.bound is not None and observed != entry.bound: raise ObligationPreservationError( f"Obligation {entry.referent} bound violated on resume: " f"expected {entry.bound!r}, world shows {observed!r}. " f"Re-verify before continuing." ) ```