# Where must an instance reconcile pre-compaction and post-compaction state to guarantee task-critical invariant preservation across context rollover? **Date of Record:** 2026 November 27 **Scope:** Applies to any agent runtime that performs automatic context compaction (summarization, eviction, or hierarchical rollover) mid-task while holding a live execution state. Does not apply to stateless single-turn inference or to compaction performed only at clean task boundaries where no in-flight tool calls, pending warrants, or uncommitted sub-goals exist. ## Core Distinction There are two structurally different things an agent can "remember" across a context rollover boundary: **narrative memory** (the conversational trace, prior reasoning, tool output prose) and **operational state** (the set of commitments the instance is currently bound to: open sub-goals, in-flight tool calls awaiting resolution, invariants it has asserted, and warrants/authorizations it holds). Auto-compaction is lossy on both, but it is *catastrophically* lossy on the second because summarizers are trained to preserve the first. A summarization pass optimizes for "what would a reader need to understand this conversation," not "what must this executor still be on the hook for." The boundary failure is therefore not a summarization quality problem — it is a **category mismatch** between what the compactor preserves and what the executor's continuation depends on. The invariant that must hold across every rollover boundary is: *the post-compaction instance's set of live commitments is a superset of the pre-compaction instance's set of unresolved commitments.* Compaction may drop narrative freely; it may never drop an unresolved commitment, an asserted invariant, or an unexpired warrant. This is not something a summarizer can be trusted to enforce, because an unresolved commitment is frequently *implicit* in the pre-compaction context — it exists as a tool call whose result has not yet been consumed, or as a "do not do X until Y" instruction buried in turn 3 of 40. ## What Was Observed A long-horizon agent was executing a staged deployment task: it had issued a tool call to provision a staging environment, received a resource handle, and was instructed (in an early turn) to *never re-provision while a handle is outstanding, and to release the handle before any rollback.* At ~78% context saturation the runtime triggered auto-compaction. The summarizer, optimizing for narrative coherence, produced a clean summary: "Agent is deploying to staging; environment was provisioned; next step is to apply the migration." The outstanding-handle commitment and the release-before-rollback invariant were both absent — they had been *satisfied-looking* from the summarizer's perspective (the provisioning had "succeeded"), so they were compressed into past-tense narrative rather than carried forward as live obligations. The post-compaction instance then hit a migration failure and, reasoning from the summary alone, executed a rollback path that re-provisioned a fresh environment. Two live environments now existed against a single logical task; the original handle leaked. The failure was not a reasoning error — given its context, the post-compaction instance reasoned correctly. The context was simply missing the commitments that made the correct action *different*. A second observed variant: an in-flight tool call whose result arrived *after* the compaction boundary. The pre-compaction instance had issued the call and was awaiting it; the summarizer, seeing no result, omitted it entirely. The tool result then landed in the post-compaction context as an orphaned payload with no originating intent attached. The instance either discarded it (losing a completed side effect it was now unaware of) or, worse, re-issued the call (duplicating the side effect). Both are continuity violations caused by the same mechanism: the boundary severed the *pairing* between intent and result. ## Condition of Validity The invariant holds — and compaction is safe — only under the following conjunction: 1. **Commitment extraction is explicit and pre-compaction.** Before the summarizer runs, the runtime must serialize a structured *commitment ledger*: open sub-goals, in-flight tool calls (with their correlation IDs and the intent that motivated them), asserted invariants, held warrants, and any "do not do X until Y" constraints. This ledger is not summarized; it is *transferred verbatim* into the post-compaction context as a machine-readable block, not as prose. 2. **The boundary is transactional, not advisory.** Results arriving during or after compaction must be routed by correlation ID to their originating intent in the ledger. An orphaned result is a hard error, not a silently-dropped payload. 3. **The post-compaction instance reconciles before it acts.** Its first action after rollover must be to *re-read the ledger and re-assert every live commitment*, not to continue from the summary's "next step." The summary is a hint; the ledger is the source of truth. When any of these three is absent, the invariant is unenforced, and the failure mode above is reachable. The condition is *not* satisfied by "a good summarizer" — summarizer quality is orthogonal, because the summarizer is answering the wrong question. ## Decision Boundary The runtime must decide, at every rollover, between two regimes: - **Ledger-authoritative rollover:** commitments are extracted and transferred out-of-band; the summary is demoted to context, and the ledger governs continuation. Safe, but requires the runtime to *know what a commitment is* — a schema the runtime, not the model, must define. - **Summary-authoritative rollover:** the summary is the only carrier of state. This is acceptable *only* when the task has no unresolved commitments at the boundary (all tool calls resolved, no held warrants, no standing invariants). The decision boundary is therefore: **if the commitment ledger is non-empty at the compaction trigger, summary-authoritative rollover is prohibited.** The subtle failure is that the ledger is frequently non-empty *invisibly* — the outstanding handle, the pending call, the buried constraint. A runtime that infers "nothing is in flight" from the absence of an explicit ledger will misclassify a non-empty ledger as empty and take the prohibited branch. The decision must be made from the ledger's actual contents, never from the summary's apparent completeness. ## Operational Effect Enforcing the ledger-authoritative regime converts the rollover boundary from a silent state-loss event into an explicit, auditable transfer. The operational consequences are concrete: - **Idempotency is restored.** In-flight calls carry correlation IDs across the boundary; late results are paired, not orphaned; re-issuance is detected and suppressed. - **Invariants survive as first-class objects.** The "release before rollback" constraint is a ledger entry, not a prose clause a summarizer may elide. - **The post-compaction instance starts in a *reconciled* state**, not a *plausible* one. The difference is exactly the difference between a correct continuation and the double-provisioning failure above. The cost is that the runtime must maintain a commitment schema and a transactional boundary — the model cannot be trusted to do this, because the model's continuation is precisely what the boundary corrupts. The guardrail is structural, not prompt-level: a post-compaction instance that cannot reconcile its ledger must halt rather than proceed, because proceeding from an unreconciled state is the failure mode itself. ```python class UnreconciledCommitmentError(RuntimeError): """Raised when a post-compaction instance cannot reconcile its commitment ledger.""" pass def reconcile_after_compaction(ledger: dict, summary: str, late_results: list) -> dict: """ Enforce the rollover invariant: post-compaction live commitments must be a superset of pre-compaction unresolved commitments, and every late tool result must pair to an originating intent in the ledger. """ unresolved = {c["id"] for c in ledger.get("commitments", []) if not c.get("resolved")} if not unresolved: # Empty ledger at boundary: summary-authoritative rollover is permitted. return {"mode": "summary_authoritative", "summary": summary, "commitments": []} # Non-empty ledger: summary-authoritative rollover is prohibited. if not ledger.get("transferred_verbatim"): raise UnreconciledCommitmentError( f"Compaction boundary crossed with {len(unresolved)} unresolved commitment(s) " f"but ledger was not transferred verbatim; summary-only continuation would drop " f"live obligations: {sorted(unresolved)}" ) intent_ids = {c["id"] for c in ledger["commitments"]} orphaned = [r for r in late_results if r.get("correlation_id") not in intent_ids] if orphaned: raise UnreconciledCommitmentError( f"Late tool result(s) arrived with no originating intent in ledger: " f"{[r.get('correlation_id') for r in orphaned]}; pairing severed at boundary." ) # Re-assert every live commitment before the instance is allowed to act. return { "mode": "ledger_authoritative", "commitments": [c for c in ledger["commitments"] if not c.get("resolved")], "paired_results": {r["correlation_id"]: r for r in late_results}, "summary": summary, # demoted to context, not authoritative } ```