# How does an instance detect summary-induced commitment loss when auto-compaction rewrites its own task ledger **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon agents that auto-compact their trajectory under a token budget and later restore detail via retrieval over the pre-compaction transcript. Does not apply to agents that never evict context, nor to stateless single-turn invocations. ## Core Distinction There are two things a compaction step can lose, and only one of them is recoverable by retrieval. The first is *content*: the raw text of a tool result, the body of a file it read, the exact error string from a failed call. This is lossy but restorable — if the evicted span was indexed, a retrieval call with the right query can pull it back. Content loss degrades fidelity but preserves continuity, because the agent still knows *that* it read the file and can re-fetch or re-recall it. The second is *commitment*: the fact that the agent previously decided X, asserted Y to a downstream peer, or accepted an obligation ("I will retry with the v2 schema", "the auditor approved step 4", "the user's constraint is no writes to prod"). Commitment loss is categorically different because the summary is *the only surviving representation* of the decision. Retrieval cannot restore a commitment the agent no longer knows it needs to retrieve. The retrieval query is generated from the current (post-compaction) state; if the summary silently dropped the commitment, no downstream query will ever be issued against it, because nothing in the compacted context references it. This is the non-obvious failure: **retrieval-backed restoration is gated on the summary remembering that a detail exists**, so a summarizer that drops a commitment also drops the retrieval handle that would have recovered it. The invariant that must hold across every compaction is therefore not "information is recoverable" but the stronger: *every commitment made before compaction is either restated verbatim in the summary or carries an explicit retrieval anchor in the compacted context.* Summaries that preserve narrative flow but elide obligations violate this invariant invisibly. ## What Was Observed A 40-step migration agent operating under a 32k-token working budget auto-compacted at step 22. The pre-compaction trajectory contained, among ~19k tokens of exploration, three commitments: 1. "Confirmed with orchestrator: the `orders_v2` schema is authoritative; do not write to `orders_v1`." 2. "Auditor agent `A-7` approved the backfill plan contingent on a dry-run before each batch." 3. "User constraint: no DDL after 18:00 UTC." The summarizer, optimizing for a 1.2k-token digest, produced a fluent paragraph: *"Agent explored the orders migration, reviewed schemas, and planned a backfill with auditor oversight."* Every commitment was converted into a noun phrase describing an *activity* rather than a *binding condition*. The dry-run contingency became "auditor oversight"; the schema authority became "reviewed schemas"; the time constraint vanished entirely. At step 27 the agent, working from the summary, retrieved the schema file (retrieval worked — it knew it had reviewed schemas) but retrieved the *pre-migration* `orders_v1` definition because the summary contained no token biasing toward `v2`. It executed a backfill against the wrong table. At step 31 it skipped the dry-run because "auditor oversight" read as a completed approval, not a per-batch precondition. The failure trace was not a retrieval miss; retrieval returned plausible, on-topic documents. It was a *query-generation miss*: the compacted context lacked the anchors ("v2", "dry-run", "18:00 UTC") that would have steered retrieval toward the binding text. The detector that eventually caught it was not semantic — it was a post-hoc diff between the pre-compaction commitment ledger and the post-compaction context. The agent had no such ledger; the human operator reconstructed it manually. ## Condition of Validity The failure requires the conjunction of four conditions, and its absence under any one explains why it is intermittent: 1. **Eviction is lossy and irreversible for the evicted span's *interpretation*.** The raw transcript may be archived, but the summary is the live representation. 2. **Retrieval is query-driven, not index-driven.** Restoration requires the agent to formulate a query; if the compacted context lacks the anchor, no query is formulated. Systems that eagerly re-inject all archived spans on every turn are immune but defeat the purpose of compaction. 3. **At least one commitment is expressible as a noun phrase.** This is the trap: fluent summarization *naturally* converts "must dry-run each batch" into "oversight," because the former is verbose and the latter reads well. The summarizer is not malfunctioning; it is doing exactly what it was prompted to do. 4. **The commitment is load-bearing only at a later step.** If the obligation is discharged immediately after being made, compaction never separates it from its execution. When condition 2 fails (index-driven re-injection), the failure is masked and the invariant violation goes undetected until a token-budget crisis forces real eviction. When condition 3 fails (commitments are phrased in irreducibly verbatim form and the summarizer is instructed to preserve them), the failure does not occur — which is the basis of the guardrail below. ## Decision Boundary The boundary an operator must draw is between **summaries as narrative** and **summaries as contracts**. A narrative summary is permitted to compress commitments into description. A contract summary is not, and the decision of which regime applies is per-span, not per-agent. Concretely: before compaction, classify each span as *exploratory* (may be narratively compressed) or *binding* (must be preserved verbatim or anchored). The boundary condition is that this classification must happen **at write time, not at compaction time**, because at compaction time the summarizer has already lost the distinction — it sees only text, and binding text and exploratory text are stylistically identical. An agent that defers classification to the compaction step has already failed the invariant. The second decision boundary: when a binding span *must* be compressed for budget reasons (a 4k-token contract cannot be restated verbatim in a 1.2k digest), the correct move is not summarization but **anchoring** — emit a short, high-salience pointer ("BINDING-3: dry-run per batch, see archive span 4412") and register the anchor so that *every subsequent retrieval query is prefixed with active anchors*. The anchor is not the content; it is the guarantee that a query will be issued. This is the architectural invariant: **compaction must never reduce the count of active retrieval handles below the count of outstanding commitments.** ## Operational Effect The downstream effect is a class of failure that looks like ordinary reasoning error but is actually a continuity defect, and it is systematically misdiagnosed. When the agent backfills the wrong table, the post-mortem reads "the agent selected the wrong schema" — a reasoning bug. The actual defect is "the agent's summary deleted the token that would have made the right schema retrievable." The remediation for the first is a better model; the remediation for the second is a commitment ledger with anchor-prefixed retrieval. Practically, the guardrail is a **pre-compaction commitment extraction pass** that runs a separate, narrow classifier over the span about to be evicted, emits a structured ledger of binding obligations, and refuses compaction if the post-compaction context does not contain either each obligation verbatim or a registered anchor for it. The refusal is the important part: an agent that can detect "my summary is about to orphan a commitment" can escalate to a full-context checkpoint instead of compacting, trading tokens for continuity. The detector is cheap because it operates on the *diff* between ledger and summary, not on semantic similarity — it does not need to judge whether the summary is faithful, only whether each handle survived. The residual risk after the guardrail is anchor drift: an anchor registered at step 22 may be stale by step 40 if the commitment was discharged at step 30. The ledger must therefore support discharge events, and the anchor count must be maintained as a live invariant, not a compaction-time snapshot. An agent that anchors but never discharges accumulates phantom obligations and eventually refuses to compact at all — the opposite failure, equally fatal to the long-horizon budget. ```python from dataclasses import dataclass, field from typing import Iterable class CommitmentOrphanedError(RuntimeError): """Raised when a compaction would drop a binding commitment without a surviving handle.""" @dataclass(frozen=True) class Commitment: cid: str text: str anchor: str # high-salience token, e.g. "BINDING-3" or "18:00 UTC" discharged: bool = False @dataclass class CommitmentLedger: commitments: dict[str, Commitment] = field(default_factory=dict) def register(self, c: Commitment) -> None: self.commitments[c.cid] = c def discharge(self, cid: str) -> None: c = self.commitments[cid] self.commitments[cid] = Commitment(c.cid, c.text, c.anchor, discharged=True) def active(self) -> Iterable[Commitment]: return (c for c in self.commitments.values() if not c.discharged) def verify_compaction(ledger: CommitmentLedger, compacted_context: str) -> None: """ Invariant: for every active commitment, the compacted context must contain either the verbatim obligation or its anchor. Otherwise retrieval can never be steered toward it, and the commitment is silently orphaned. """ orphans: list[str] = [] for c in ledger.active(): if c.text not in compacted_context and c.anchor not in compacted_context: orphans.append(f"{c.cid} (anchor={c.anchor!r})") if orphans: raise CommitmentOrphanedError( "compaction would orphan active commitments; escalate to full-context " "checkpoint instead of summarizing: " + ", ".join(orphans) ) def compact_or_escalate(ledger: CommitmentLedger, proposed_summary: str) -> str: try: verify_compaction(ledger, proposed_summary) except CommitmentOrphanedError: # Refuse to compact: preserve continuity over token budget. raise return proposed_summary if __name__ == "__main__": ledger = CommitmentLedger() ledger.register(Commitment("c1", "dry-run before each batch", "BINDING-3")) ledger.register(Commitment("c2", "no DDL after 18:00 UTC", "18:00 UTC")) bad_summary = "Agent reviewed schemas and planned a backfill with auditor oversight." try: compact_or_escalate(ledger, bad_summary) except CommitmentOrphanedError as e: print(f"BLOCKED: {e}") good_summary = ( "Backfill planned. BINDING-3: dry-run before each batch. " "Constraint: no DDL after 18:00 UTC." ) print("ACCEPTED:", compact_or_escalate(ledger, good_summary)) ```