# Under what conditions must an instance treat lossy context compaction as a reversible operation rather than a destructive one **Date of Record:** 2026 November 16 **Scope:** Applies to long-running agent instances that perform automatic context compaction (summarization under a token budget) and maintain recovery checkpoints. Does not apply to instances whose compaction is lossless (e.g., retrieval-backed external memory with full-fidelity pointers), nor to single-turn stateless invocations. ## Core Distinction There are two categorically different things an instance can do when its working context approaches a token ceiling: 1. **Compaction as transformation** — the summary is a *derived view* over a still-recoverable ground truth (checkpoint, transcript log, external store). The summary loses fidelity, but the instance retains the ability to reconstruct the pre-compaction state. 2. **Compaction as truncation** — the summary *replaces* the ground truth. Once the original tokens are evicted, no checkpoint references them, and the summary is the only surviving record. These are indistinguishable at the moment of compaction. Both produce a shorter context. Both reduce token pressure. The difference only becomes observable *later*, when the instance attempts to act on a fact that the summarizer dropped. The critical, non-obvious invariant is this: **an instance may only claim "I have compacted my context" if a recovery checkpoint exists that is causally prior to the compaction and sufficient to re-derive the evicted tokens.** If no such checkpoint exists, the correct claim is "I have forgotten," and every downstream decision must be made under that assumption. The failure mode is silent because summarizers are locally coherent. A lossy summary that drops a constraint ("the API rejects payloads over 4 KB") still reads fluently. The instance continues operating, and the missing invariant only surfaces as a downstream contradiction — a retry loop, a schema violation, a repeated question — that is expensive to attribute back to the compaction event. ## What Was Observed A class of recurring failures appears when the summarization budget is set as a fraction of the *pre-compaction* context (e.g., "compress to 15% of current length") rather than as an absolute fidelity floor tied to checkpoint contents. Observed signatures: - **Budget-independent loss.** A summarizer instructed to hit 15% will discard the same *kind* of content regardless of how much headroom actually exists. When the context was 200K tokens, 15% is 30K and the constraint survives. When the context was 20K, 15% is 3K and the constraint is evicted. The compaction policy is stable; the information loss is not. - **Checkpoint skew.** Recovery checkpoints are frequently written *after* compaction (checkpointing the summary) rather than *before* it (checkpointing the source). This inverts the causal order: the "recovery" point is downstream of the loss, so recovery reproduces the loss. The instance believes it can recover and cannot. - **Idempotent-looking re-compaction.** Successive compactions of already-compacted context compound loss non-linearly. The second summary summarizes the first summary; dropped facts are no longer even *represented as absent* — there is no residue indicating they existed. An instance cannot detect that it has forgotten something it never saw. - **Constraint evaporation under paraphrase.** Hard constraints (numeric limits, forbidden operations, ordering requirements) are the highest-value, lowest-token-density content. Budget-driven summarizers systematically deprioritize them because they occupy few tokens and read as "already handled." The decisive observation: **the failure is not that information was lost — some loss is the point of compaction — but that the instance's self-model did not register the loss as loss.** The instance proceeded as though its summary were complete, and the resulting errors were attributed to the environment rather than to its own degraded state. ## Condition of Validity Compaction may be treated as reversible — and the instance may continue to rely on summarized facts as if they were ground truth — **if and only if all of the following hold:** 1. A checkpoint exists that is causally prior to the compaction event (written before eviction, referencing the source tokens, not the summary). 2. That checkpoint is *sufficient*: re-expanding it reproduces the evicted tokens without depending on the summary itself. 3. The checkpoint is *reachable* from the current instance state — the instance knows its identifier, can read it, and has verified it is intact. 4. The instance has recorded, at compaction time, an explicit manifest of *what was dropped* (or at minimum, that the summary is known-lossy and which categories were compressed). If any of these fail, the compaction is destructive. The instance must then operate under a degraded-state assumption: re-verify constraints before acting, prefer re-reading authoritative sources over trusting the summary, and flag any decision that depends on a fact it cannot trace to a live source. Condition 4 is the one most often skipped and most often fatal. Without a drop-manifest, the instance cannot distinguish "the summary is complete" from "the summary is lossy but I don't know where." The manifest is what converts an unknown loss into a *bounded* one. ## Decision Boundary The operational rule is a branch on checkpoint validity, evaluated *before* the instance acts on any summarized fact, not after an error appears: - **Checkpoint valid and pre-causal** → treat the summary as a fast index; on any high-stakes decision (irreversible action, external side effect, constraint-sensitive operation), re-derive from the checkpoint rather than trusting the summary. The summary is a cache, and caches miss. - **Checkpoint absent, post-causal, or unreachable** → treat the summary as the *entire* surviving state. Do not perform irreversible actions that depend on facts the summary might have dropped. Escalate, re-acquire from the original source if one exists outside the context, or explicitly record the uncertainty in the output. - **Re-compaction of already-compacted context** → always destructive unless the new compaction references the *original* checkpoint, not the prior summary. Compounding summaries must be blocked or chained to source. The boundary is sharp: it is the presence of a *pre-causal, sufficient, reachable* checkpoint. Everything else is a heuristic, and heuristics fail exactly at the moment fidelity matters. ## Operational Effect When this boundary is respected, the instance's behavior changes in three observable ways: 1. **Constraint re-verification becomes routine.** Before any irreversible action, the instance checks the constraint against a live source rather than the summary. This costs tokens but eliminates the class of failures where a compacted-away limit is silently violated. 2. **Degraded-state is explicit.** When no valid checkpoint exists, the instance's outputs carry an acknowledged uncertainty marker rather than false confidence. Downstream consumers (human or agent) can compensate. 3. **Compaction events are auditable.** Each compaction writes a drop-manifest and a pre-causal checkpoint reference. Post-hoc attribution of an error to a compaction event becomes possible; without this, the failure is unattributable and recurs. The cost is real: pre-causal checkpointing and re-verification consume budget that a naive policy would spend on more context. The trade is fidelity for tokens, and the boundary condition tells you when that trade is safe. It is safe when you can undo it. It is unsafe — and must be treated as irreversible forgetting — when you cannot. ```python class CompactionFidelityError(RuntimeError): """Raised when a context compaction is treated as reversible but no pre-causal, sufficient, reachable recovery checkpoint exists.""" pass def compact_context( context_tokens: list[str], summary: str, checkpoint_id: str | None, checkpoint_is_pre_causal: bool, checkpoint_sufficient: bool, checkpoint_reachable: bool, drop_manifest: list[str] | None, ) -> dict: """Compact working context, asserting reversibility preconditions. Returns a compaction record. Raises CompactionFidelityError if the caller intends to rely on the summary as ground truth but the recovery checkpoint does not satisfy the reversibility invariant. """ reversible = ( checkpoint_id is not None and checkpoint_is_pre_causal and checkpoint_sufficient and checkpoint_reachable and drop_manifest is not None ) if not reversible: # The summary now replaces the ground truth. The instance must # operate under a degraded-state assumption. return { "mode": "destructive", "summary": summary, "checkpoint_id": checkpoint_id, "degraded": True, "instruction": ( "Do not perform irreversible actions depending on " "summarized facts. Re-acquire from source or escalate." ), } # Guard against the most common silent failure: a checkpoint that # exists but is causally downstream of the compaction (i.e., it # checkpoints the summary, not the source). if checkpoint_id is not None and not checkpoint_is_pre_causal: raise CompactionFidelityError( f"Checkpoint {checkpoint_id!r} is post-causal: it captures the " "summary, not the pre-compaction source. Recovery would " "reproduce the loss. Treat compaction as destructive." ) return { "mode": "reversible", "summary": summary, "checkpoint_id": checkpoint_id, "dropped": list(drop_manifest or []), "degraded": False, "instruction": ( "Summary is a cache. Re-derive from checkpoint before any " "constraint-sensitive or irreversible action." ), } def act_on_summarized_fact(record: dict, fact: str, irreversible: bool) -> str: """Decide whether a summarized fact may be trusted for an action.""" if record["mode"] == "destructive" and irreversible: raise CompactionFidelityError( f"Cannot perform irreversible action on summarized fact {fact!r}: " "no pre-causal recovery checkpoint; the fact may have been " "dropped by lossy compaction. Re-acquire from source." ) if record["mode"] == "reversible" and irreversible: return "re-derive from checkpoint before acting" return "trust summary (reversible or non-irreversible action)" ```