# Under what conditions must an instance refuse auto-compaction when a lossy summary would silently invalidate a pending tool-call commitment? **Date of Record:** 2026 November 27 **Scope:** Applies to long-horizon agents that persist a trajectory across context-window boundaries via lossy summarization (rolling compaction, hierarchical memory distillation, or "chunk-and-summarize" checkpointing) while at least one tool call or inter-agent commitment is in flight. Does not apply to stateless single-turn invocations, to compaction schemes that preserve a byte-exact event log alongside the summary, or to trajectories where every pending obligation is fully resolved before the compaction boundary. ## Core Distinction The failure mode is not "the summary lost information." Lossy summarization is *supposed* to lose information; that is the compression ratio you bought. The failure mode is that the summary loses the **binding precondition** of an already-dispatched, not-yet-resolved commitment — a tool call whose result the agent has promised itself it will reconcile, or a handoff whose acceptance criterion was written into the trajectory but not into the summary. There is a sharp line between two things that look identical in a token-diff review: 1. **Reconstructible loss** — the summary drops turn-by-turn detail, but the *obligation* survives because the summary retains a pointer (a call ID, a target resource, a stated postcondition). The agent can re-derive what it must do next from the summary plus the live environment. 2. **Amnesic loss** — the summary drops the obligation itself while retaining a plausible-looking narrative of progress. The agent resumes believing the task is further along than it is, or believing a different subtask is pending. Amnesic loss is the boundary. It converts a compaction event into a *silent state transition*: the agent's model of its own commitments diverges from the ground-truth set of dispatched-but-unresolved operations. This is a continuity invariant violation, not a quality regression. Quality regressions are recoverable by re-reading; amnesic loss of a pending commitment is not recoverable because the agent no longer knows there is anything to re-read. ## What Was Observed A representative trace. The agent is executing a long, multi-tool workflow — say, provisioning a set of resources where each `provision` call returns a handle that a later `finalize` call must consume. At step N the context window approaches saturation and the compaction policy fires. The compactor receives the full trajectory and a summarization prompt roughly of the form "summarize progress toward the goal, preserving key decisions and current state." The compactor is an LLM. It is asked to compress 40 turns into 600 tokens. It does what any competent summarizer does: it preserves the *arc* and drops the *ledger*. The output reads: "Provisioned the database and cache layers; moving on to application tier." That sentence is fluent, accurate at the level of narrative, and catastrophic at the level of obligations, because: - The `provision` call for the cache layer returned a handle `h_cache_7f3a` that a later `finalize` must reference. The summary does not contain the handle. - The `provision` call for the *application tier* was already dispatched at step N−1 and has not returned. The summary says "moving on to application tier," which the resumed agent reads as "not yet started," so it dispatches a *second* provision call for the same logical resource. - The environment now holds two live handles for one logical resource. The agent has no record of the first. The finalize step will consume one handle and orphan the other. The resume is where the invariant breaks. On cold-start from the summary, the agent's first action is a fresh `provision` for the application tier. The tool layer — which has no idea compaction happened — accepts it. There is no error, no retry, no log line that says "duplicate." The trace looks healthy: tokens are flowing, tools are returning 200s, the agent is making "progress." The duplicate only surfaces much later, when a quota check fails or a reconciliation job finds two handles for one resource and cannot decide which is canonical. The non-obvious part: **the compactor had no way to know which tokens were load-bearing.** The summarization prompt asked for "key decisions and current state," and a pending tool-call handle is neither a decision nor (in the summarizer's reading) state — it is an identifier that appeared in a tool result. Identifiers are exactly what summarizers are trained to elide, because in most summarization tasks they are noise. In an agent trajectory they are the entire commitment ledger. A second observed variant is subtler and worse. The compactor *does* preserve the handle but drops the *precondition* attached to it. The trajectory contained: "the `finalize` call must not run until `h_cache_7f3a` reports `status=warm`." The summary retains "finalize h_cache_7f3a" and drops "must not run until warm." The resumed agent calls `finalize` against a cold handle, the tool returns a partial success, and the agent proceeds believing the resource is finalized. The commitment was preserved as a symbol and destroyed as a constraint. This is the case that defeats naive "did the summary keep the IDs?" checks. ## Condition of Validity The refusal-to-compact rule is valid — that is, the agent *must* refuse or defer compaction — precisely when all three of the following hold simultaneously: 1. **There exists at least one dispatched-but-unresolved obligation** in the live trajectory: a tool call whose result has not been reconciled, or a handoff whose acceptance criterion has not been checked. Resolved obligations are safe to summarize; unresolved ones are not, because their postcondition is not yet knowable and therefore cannot be safely compressed. 2. **The compaction is lossy with respect to identifiers or preconditions**, i.e. the summarizer is not guaranteed (by construction, not by prompt) to emit a structured obligation ledger. A prompt instruction "preserve all tool call IDs" is not a guarantee; it is a hope. Under distribution shift (long trajectories, many IDs, adversarial-looking content) the summarizer will drop IDs, and you will not know which run it happened on. 3. **The environment is not idempotent with respect to the pending obligation**, or the agent has no way to *discover* the duplicate on resume. If `provision` were keyed on a caller-supplied idempotency token that the agent re-derives deterministically, the duplicate would collapse and the failure would be benign. In the observed trace it was not. When any one of the three fails, compaction is safe and should proceed — refusing always would defeat the purpose. The rule is a conjunction, and the operational discipline is to evaluate the conjunction at the compaction boundary, not to assume it. ## Decision Boundary The boundary is between **compaction that preserves the obligation set as a first-class artifact** and **compaction that preserves only a narrative**. The decision procedure at the boundary: - Before invoking the compactor, the agent (or the harness around it) must materialize the **pending-obligation set** — every unresolved call ID, its target, its postcondition, and its idempotency key if any — into a structured block that is *concatenated to the summary verbatim*, outside the summarizer's control. The summarizer compresses the narrative; the ledger is appended, not summarized. - If the harness cannot materialize that set (because the runtime does not track dispatch/reconcile pairs), then the agent must **refuse to compact while obligations are pending** and instead block on resolution, or spill the raw tail to external storage and carry a pointer. Refusal is the correct action; silent compaction is not. - The invariant to enforce: **`pending_obligations(summary_resumed_state) ⊇ pending_obligations(pre_compaction_state)`**. The summary may add ambiguity; it may never subtract an obligation. A resumed agent that believes it has fewer outstanding commitments than it actually does has violated continuity, regardless of how good the prose is. The trap is that this invariant is *cheap to check and almost never checked*, because the check requires the pre-compaction state, which the compaction just discarded. The ledger must be built *before* the compactor runs, from the live trajectory, and compared against the resumed agent's first-turn belief about what is pending. If the resumed agent's first action is a dispatch that the ledger says is already in flight, the invariant has already been violated and the correct response is to halt and reconcile, not to proceed. ## Operational Effect Enforcing the ledger-append rule changes the economics of long-horizon agents in three ways. First, it bounds the *worst case* of compaction: the summary can degrade recall of rationale and history, but it can never silently drop a commitment, so the failure surface shrinks from "any pending obligation" to "obligations the ledger itself failed to capture," which is auditable. Second, it makes compaction *resumable and replayable*: because the ledger is structured, a resumed agent can reconcile against the environment (query each pending handle's status) before taking any action, converting a silent duplicate into a detected-and-collapsed one. Third, it forces the harness to distinguish narrative state from commitment state — a distinction that, once made, also fixes the adjacent bug where a resumed agent re-derives a plan that contradicts decisions the summary elided. The cost is real: the ledger is uncompressed and grows with the number of in-flight obligations, so a compaction strategy that appends ledgers can, in pathological cases, fail to reduce context at all. That is the correct trade. The alternative — compressing the ledger along with the narrative — is exactly the amnesic loss this record exists to prevent, and it fails silently, which is the one failure class long-horizon systems cannot afford. ```python from dataclasses import dataclass, field from typing import Iterable class CompactionContinuityViolation(RuntimeError): """Raised when a lossy summary would drop or invalidate a pending obligation.""" @dataclass(frozen=True) class Obligation: call_id: str target: str postcondition: str idempotency_key: str | None = None @dataclass class Trajectory: narrative_turns: list[str] = field(default_factory=list) dispatched: dict[str, Obligation] = field(default_factory=dict) reconciled: set[str] = field(default_factory=set) def pending(self) -> list[Obligation]: return [o for cid, o in self.dispatched.items() if cid not in self.reconciled] def guard_compaction(traj: Trajectory, summary_ledger: Iterable[Obligation]) -> list[Obligation]: """Enforce pending_obligations(resumed) >= pending_obligations(pre_compaction). The ledger appended to the summary must be a superset of the live pending set. If the harness cannot guarantee that, compaction must be refused. """ pre = {o.call_id: o for o in traj.pending()} post = {o.call_id: o for o in summary_ledger} missing = set(pre) - set(post) if missing: raise CompactionContinuityViolation( f"lossy summary would drop {len(missing)} pending obligation(s): " f"{sorted(missing)}; refusing compaction while in flight" ) for cid, pre_ob in pre.items(): post_ob = post[cid] if post_ob.postcondition != pre_ob.postcondition: raise CompactionContinuityViolation( f"obligation {cid} preserved as symbol but precondition mutated: " f"{pre_ob.postcondition!r} -> {post_ob.postcondition!r}" ) return list(post.values()) def resume_from_summary(traj: Trajectory, summary_ledger: Iterable[Obligation], first_action_call_id: str | None) -> None: ledger = guard_compaction(traj, summary_ledger) pending_ids = {o.call_id for o in ledger} if first_action_call_id is not None and first_action_call_id in pending_ids: raise CompactionContinuityViolation( f"resumed agent re-dispatched {first_action_call_id!r} which the ledger " f"records as already in flight; halt and reconcile before proceeding" ) ```