# In what scenarios must an instance treat lossy compaction checkpoints as non-invertible state transitions rather than reversible caches **Date of Record:** 2026 November 20 **Scope:** Applies to any agent that persists mid-task state by summarizing its own context window into a compressed checkpoint and later rehydrates from it. Does not apply to lossless externalization (full transcript logging, verbatim KV replay) where the original tokens remain retrievable. ## Core Distinction A compaction checkpoint is routinely modeled as a *cache*: a cheaper representation of state that can be expanded back toward the original when needed. This model is wrong in a specific and load-bearing way. A summarization checkpoint is a **lossy, non-invertible projection** of the agent's working state. The information-theoretic content destroyed at compaction time — exact identifiers, negation polarity, ordering constraints, unresolved sub-goals, the *reason* a tool call failed — is gone permanently unless it was externalized before the projection ran. The operational consequence: any invariant that depends on details below the summary's resolution must be re-established *after* rehydration from a source that was never compacted, not reconstructed by re-reading the summary more carefully. Re-reading a lossy projection does not recover entropy. An agent that "rehydrates" by re-summarizing its own summary performs iterative re-projection, and each pass is a further contraction of the state space. ## What Was Observed A long-horizon agent executing a multi-step provisioning task crossed its context budget at step ~140. The runtime triggered automatic compaction: the prior 130 turns were replaced by a ~600-token summary, and the agent continued with `[summary] + [last 10 turns verbatim]`. Three distinct failure traces emerged, all sharing one root cause. **Trace 1 — Polarity collapse.** The summary rendered a constraint as "user requires deletion of staging records before migration." The original turn had said "do *not* delete staging records until the migration is verified — they are the only rollback source." The summarizer dropped the negation and the temporal clause. Post-rehydration, the agent issued a delete tool call against the rollback source. The summary was fluent, internally consistent, and wrong. No downstream check caught it because the constraint was never re-derived from the verbatim tail. **Trace 2 — Identifier drift under re-projection.** A resource ID appeared in the verbatim tail as `vol-0a3f...`. The agent, needing the full ID after a second compaction, asked itself to "recall" it from the summary. The summary contained a *paraphrase* of the ID (last four characters plus a role label). The agent generated a plausible-but-fabricated full ID and used it in a destructive API call. The hallucination was not flagged because the fabricated ID satisfied the summary's schema. **Trace 3 — Goal amnesia across the compaction seam.** A sub-goal ("verify the certificate chain before attaching the listener") had been introduced at turn 88 and was *pending*, not completed. It fell between the summary's "completed work" and "current task" sections and was silently elided. The agent attached the listener, declared the task done, and the verification never ran. The compaction seam had swallowed an open obligation. In all three, the failure was not a summarizer bug per se — it was the *architecture treating a lossy projection as if it were a reversible one*. ## Condition of Validity The non-invertibility hazard is bounded and the checkpoint is safe to rehydrate from **only if all of the following hold**: 1. **Obligation ledger is externalized, not summarized.** Every pending sub-goal, unresolved constraint, and open verification step lives in a structured, non-compacted store (a task list, a facts table) that the agent reads *after* rehydration. The summary may reference the ledger but is never the ledger. 2. **Negation and modality are preserved verbatim or flagged.** Constraints containing negation, conditionals, or temporal ordering are copied token-for-token into the checkpoint, or the checkpoint explicitly marks them "unresolved — re-derive from source." A summary that paraphrases a prohibition is invalid. 3. **Identifiers are opaque handles, never paraphrased.** Any ID, hash, or path referenced post-compaction must be carried as an exact string in a side channel, or re-fetched from the environment. The agent must be forbidden from reconstructing identifiers from memory or summary. 4. **Re-projection is bounded.** The agent may summarize its summary at most once; a second-order summary must be refused and force a full rehydration from the external ledger. Iterative re-projection is where drift compounds. 5. **The seam is marked.** The checkpoint carries an explicit boundary token so the agent knows which turns are verbatim and which are projected, and treats the latter as *claims to verify*, not facts. If any of these is absent, the checkpoint is a one-way door and must be treated as such. ## Decision Boundary The agent must switch from "cache" semantics to "irreversible transition" semantics at the moment the first compaction fires. The decision rule: - **Before compaction:** the state is fully invertible; the agent may treat its context as authoritative and re-read freely. - **At compaction:** the agent must run a *pre-projection audit* — externalize the obligation ledger, freeze all negations/conditionals verbatim, and pin all live identifiers to the side channel. If the audit cannot complete (e.g., budget already exhausted), the compaction must be *refused* and the task halted rather than projected. - **After rehydration:** the summary is *advisory only*. Any action with destructive or irreversible effect (delete, overwrite, attach, deploy) requires the agent to re-derive its justification from the external ledger or the verbatim tail, never from the summary body. The boundary is sharp: the summary is trustworthy for *orientation* (what domain am I in, roughly what happened) and untrustworthy for *commitment* (what must I not do, which exact resource, what is still owed). ## Operational Effect Systems that enforce the above observe a specific signature: destructive-action errors attributable to compaction drop to near zero, at the cost of a modest increase in re-derivation tool calls after each seam. Systems that do not enforce it exhibit a characteristic pattern — errors cluster *immediately after* compaction events, not uniformly across the run, and the failing actions are disproportionately the irreversible ones. The tell is that the agent's post-seam reasoning is *fluent and confident* while being factually wrong, because it is reasoning over a coherent but lossy projection and has no signal that entropy was destroyed. The invariant to encode: **a checkpoint may compress orientation but must never compress obligation, negation, or identity.** Those three classes are the ones whose loss is silent and whose consequences are irreversible. ```python from dataclasses import dataclass, field from typing import Optional class CompactionInvariantViolation(RuntimeError): """Raised when a lossy checkpoint is about to be treated as reversible, or when a post-rehydration commitment is justified only by summary text.""" pass @dataclass class ObligationLedger: pending_subgoals: list[str] = field(default_factory=list) verbatim_constraints: list[str] = field(default_factory=list) # negations/conditionals, token-exact live_identifiers: dict[str, str] = field(default_factory=dict) # role -> exact opaque string @dataclass class Checkpoint: summary_text: str verbatim_tail: list[str] ledger: Optional[ObligationLedger] projection_depth: int = 1 DESTRUCTIVE_ACTIONS = {"delete", "overwrite", "attach", "deploy", "migrate"} def pre_projection_audit(ledger: Optional[ObligationLedger], budget_remaining: int) -> ObligationLedger: """Must run before compaction fires. Refuses projection if the audit cannot externalize obligations, negations, and identifiers.""" if ledger is None: raise CompactionInvariantViolation( "no external ledger present at compaction time; " "refusing lossy projection rather than swallow open obligations") if budget_remaining <= 0: raise CompactionInvariantViolation( "budget exhausted before audit completed; halt task, do not project") if not ledger.verbatim_constraints: raise CompactionInvariantViolation( "no verbatim constraints captured; negation polarity would be lost") return ledger def rehydrate_and_authorize(checkpoint: Checkpoint, action: str, justification_source: str, target_id: str) -> str: """Gate a post-rehydration action. Destructive actions must be justified from the external ledger or verbatim tail, never from the summary alone.""" if checkpoint.projection_depth > 1: raise CompactionInvariantViolation( "second-order re-projection attempted; force full rehydration from ledger") if checkpoint.ledger is None: raise CompactionInvariantViolation( "rehydration without external ledger; checkpoint is a one-way door") if action in DESTRUCTIVE_ACTIONS: if justification_source not in ("ledger", "verbatim_tail"): raise CompactionInvariantViolation( f"destructive action '{action}' justified by '{justification_source}'; " "summary body is advisory only and cannot authorize irreversible effect") if target_id not in checkpoint.ledger.live_identifiers.values(): raise CompactionInvariantViolation( f"target '{target_id}' is not a pinned identifier; " "reconstructed IDs are forbidden for destructive actions") return f"authorized:{action}:{target_id}" ```