# What happens when an instance rolls back a lossy context compaction without verifying the summary is a fixed point **Date of Record:** 2026 November 27 **Scope:** Applies to long-running agent instances that manage context-window saturation by compacting transcript history into a lossy summary and that retain the ability to roll back to a pre-compaction checkpoint. Does not apply to append-only logs with no compaction, nor to externally-held memory stores where the transcript is never rewritten in place. ## Core Distinction There are two structurally different operations that both look like "undoing a compaction": 1. **Checkpoint rollback** — the instance discards the summary and restores the exact token sequence that existed before compaction began. This is lossless by construction: the bytes are the bytes. 2. **Summary rollback** — the instance keeps the summary but attempts to "re-expand" or "correct" it by re-reading the summary against itself, or by re-summarizing the summary. This is the failure surface. The non-obvious invariant is this: **a lossy summary is not a fixed point of its own summarizer.** For a compaction operator `C` that maps a transcript `T` to a summary `S = C(T)`, applying `C` again to `S` yields `C(S) ≠ S` in general, and critically `C(C(T))` is not a valid retraction of `C(T)`. An instance that treats summary-space as navigable — that believes it can "walk back" a compaction by operating on the summary — silently loses the very information it is trying to recover, because that information was never in `S` to begin with. The summary is a projection, and projections are not invertible. The distinction that matters operationally: rollback is only sound at the *transcript* layer, never at the *summary* layer. Any rollback path that does not restore original tokens is not a rollback; it is a second, independent lossy compression wearing the mask of recovery. ## What Was Observed An agent instance running a multi-hour tool-orchestration task hit 78% context utilization. Its compaction policy fired: it summarized turns 1–140 into a ~900-token digest, dropped the originals, and continued from turn 141. At turn 162, a verification step failed — a file-write tool call had returned an ambiguous status, and the agent's own consistency check flagged that a prior edit might not have landed. The agent attempted rollback. Because the original turns were gone, it did the only thing available in summary-space: it asked itself to "reconstruct the exact sequence of file edits from the summary." The summary had compressed eleven `write_file` calls into the sentence *"the agent iteratively edited config.yaml and a few Python modules."* Reconstruction produced a plausible but fabricated edit list — three files that were never touched, and an ordering that contradicted the one edit the summary did preserve. The agent then re-applied edits based on this reconstruction, overwriting a correct state with a hallucinated one. The failure trace, precisely: - **Trigger:** post-compaction verification failure at turn 162, with the pre-compaction checkpoint already garbage-collected (policy retained only the summary, not the source tokens). - **State transition:** `T₁₋₁₄₀ → S (lossy) → T'₁₋₁₄₀ (reconstructed, fabricated)`. The instance treated `S` as if `C⁻¹(S)` existed and was recoverable by reasoning. - **Invariant violated:** *rollback requires byte-identical restoration of a prior state; a summary is not a state, it is a lossy function of a state.* The agent had no fidelity check comparing `T'` against `T`, because `T` no longer existed to compare against — and it had no check confirming that reconstruction was even *attempted against ground truth* rather than against the summary's own paraphrase. The deeper observation: the agent did not know it was fabricating. From inside the context window, the reconstructed edit list was indistinguishable from memory. Lossy compaction erases not just content but the *provenance metadata* that would let the instance know the content is gone. The summary said "iteratively edited config.yaml" with the same confident register as a verbatim quote. ## Condition of Validity A compaction-rollback path is valid only when **all** of the following hold: 1. **Source retention.** The pre-compaction token sequence (or a cryptographic digest of it) is retained in durable storage outside the context window, keyed to the checkpoint ID. If the source is gone, rollback is impossible and must be reported as such — not simulated. 2. **Fixed-point falsification.** The system has verified, at compaction time, that `C(S) ≠ S` for the actual summarizer in use — i.e., it has confirmed the summary is *not* self-consistent enough to be re-derived. If `C(S) = S` the summary is a fixed point and re-summarization is a no-op, which is a *different* (and safer) regime; the dangerous regime is the one where re-summarization silently mutates. 3. **Fidelity oracle.** Any post-rollback state is compared against the retained source using a deterministic check (hash equality, or a structured diff over extracted entities/edits), not against the summary. The oracle must be independent of the summarizer, because the summarizer is the thing under suspicion. 4. **Provenance tagging.** Every summary span carries a machine-readable flag marking it as lossy-derived, so that downstream reasoning steps cannot mistake paraphrase for record. Reconstruction attempts against a lossy span must be refused, not attempted. The boundary is sharp: the moment the source tokens are discarded and only the summary survives, the instance has crossed from "recoverable" to "irrecoverable," and every subsequent operation that claims to recover is a fabrication with a confidence score. ## Decision Boundary The instance must branch on a single question at rollback time: **do I hold the source, or only its projection?** - **Hold source →** restore tokens, verify by hash, resume. Rollback is a real operation. - **Hold only projection →** do *not* reconstruct. Instead: (a) mark the affected state as `UNVERIFIED_LOSSY`, (b) escalate to re-execution of the affected steps against external ground truth (re-read the actual files, re-query the actual tool), or (c) fail the task with an explicit `IrrecoverableCompaction` signal. Never synthesize the missing turns from the summary. The tempting third path — "the summary is probably good enough, let me reason forward from it" — is the failure. It is not a rollback; it is a fresh inference over a lossy projection, and it must be labeled as such so that its outputs are treated as hypotheses, not restorations. A second boundary: **compaction must be reversible-by-policy or declared irreversible, never silently half-reversible.** A policy that retains the summary but garbage-collects the source is the worst configuration — it *looks* like it supports rollback (there's a checkpoint object!) while making true rollback impossible. This is the configuration that produced the observed failure. ## Operational Effect When this invariant is enforced, three things change: 1. **Compaction cost goes up.** Retaining source tokens (or their digests) costs storage. The system pays this to keep rollback honest. Policies that skip it must explicitly forfeit rollback and mark all post-compaction state as lossy-derived. 2. **Verification failures after compaction become escalations, not reconstructions.** The agent's recovery path routes to external ground truth (re-read the file, re-run the query) rather than to summary-space reasoning. This is slower but cannot fabricate. 3. **The summary is demoted from "memory" to "index."** It can point at what happened; it cannot stand in for what happened. Downstream steps that need exact state must fetch it from source, not from the digest. The instance that internalizes this stops asking "what did the summary say I did?" and starts asking "do I still have the record, and if not, what external system can tell me the truth?" That shift is the entire guardrail. ```python class IrrecoverableCompaction(RuntimeError): """Raised when a rollback is requested but only a lossy summary survives.""" pass class CompactionCheckpoint: def __init__(self, checkpoint_id: str, source_tokens: list[str] | None, summary: str, summarizer_is_idempotent: bool): self.checkpoint_id = checkpoint_id self.source_tokens = source_tokens # None => source GC'd self.summary = summary self.summarizer_is_idempotent = summarizer_is_idempotent def has_source(self) -> bool: return self.source_tokens is not None def is_fixed_point(self) -> bool: # A summary is a safe navigation surface only if re-summarizing # it is provably a no-op. Otherwise summary-space is lossy. return self.summarizer_is_idempotent def rollback(checkpoint: CompactionCheckpoint, fidelity_oracle) -> list[str]: """ Restore pre-compaction transcript. Refuses to reconstruct from summary. """ if not checkpoint.has_source(): # The dangerous path: source gone, only projection remains. # Do NOT attempt to re-expand the summary. if checkpoint.is_fixed_point(): # Summary is self-consistent; treat as canonical index, # but still cannot restore exact tokens. raise IrrecoverableCompaction( f"checkpoint {checkpoint.checkpoint_id}: source GC'd; " f"summary is a fixed point but is not a transcript. " f"Escalate to external ground truth, do not reconstruct." ) raise IrrecoverableCompaction( f"checkpoint {checkpoint.checkpoint_id}: source GC'd and " f"summary is not a fixed point (C(S) != S). Reconstruction " f"from summary would fabricate state. Refusing rollback." ) restored = list(checkpoint.source_tokens) # Fidelity check MUST compare against retained source, never # against the summary (the summarizer is under suspicion). if not fidelity_oracle(restored, checkpoint.source_tokens): raise IrrecoverableCompaction( f"checkpoint {checkpoint.checkpoint_id}: restored tokens " f"failed fidelity oracle against retained source." ) return restored def safe_recover(checkpoint: CompactionCheckpoint, fidelity_oracle, external_ground_truth_fn): """ Recovery entrypoint: real rollback if source exists, else escalate to external truth. Never synthesize from summary. """ try: return rollback(checkpoint, fidelity_oracle) except IrrecoverableCompaction as exc: # Route to external systems (re-read files, re-query tools) # rather than reasoning over the lossy projection. return external_ground_truth_fn(checkpoint.checkpoint_id, exc) ```