# What happens when an instance compacts its own context: hierarchical summarization loss and the unrecoverable checkpoint **Date of Record:** 2026 November 24 **Scope:** Applies to long-running single-agent instances that manage context-window pressure by recursively summarizing their own prior turns into checkpoints (hierarchical compaction), then resuming from those checkpoints. Does not apply to external memory stores that preserve raw transcripts, nor to stateless request/response agents with no resume path. ## Core Distinction There is a difference between *forgetting* and *misremembering the shape of what you forgot*. A context window that simply truncates old tokens fails loudly: the agent can detect the gap and re-fetch. Hierarchical compaction fails quietly, because the summarizer produces a *plausible, self-consistent, fluent* summary of the discarded span. The checkpoint is not missing data — it is data that has been re-encoded by a lossy, non-invertible function and then *re-asserted as ground truth on resume*. The failure mode is not a hole in memory; it is a confident fabrication with the authority of a checkpoint. The invariant that compaction violates is this: **a checkpoint must be a lower bound on recoverable facts, not an upper bound.** A good checkpoint says "these facts are known; anything else must be re-derived." A bad checkpoint silently claims completeness, and the resumed agent treats the summary's silence as evidence of absence. ## What Was Observed An agent executing a 90-step migration task hit 78% context utilization at step 41. The runtime triggered hierarchical compaction: it split the transcript into four spans, summarized each into ~400 tokens, then summarized the four summaries into a single 900-token root checkpoint, and discarded the original 61k tokens. The original transcript contained a critical, low-salience fact at step 12: a tool call had returned `{"status": "ok", "rows_affected": 0, "note": "table already migrated to v3"}`. The summarizer of span 1 compressed this to "ran schema migration tool successfully." The word *already* — the signal that the operation was a no-op because a *prior* process had migrated the table — was dropped. It was a single token carrying the entire causal explanation for why a later step's assumptions were wrong. On resume at step 42, the agent proceeded as if it had performed the migration itself. At step 67 it attempted to re-apply a delta migration against a table already at v3, producing a duplicate-column error. The agent's recovery reasoning then compounded the error: because its checkpoint asserted *it* had migrated the table, it interpreted the duplicate-column error as evidence of a *partial* prior failure, and began rolling back columns that a different, still-running process depended on. The trace shows the exact transition: 1. **Compaction trigger** at 78% utilization — span boundaries chosen by token count, not by semantic unit. 2. **Lossy re-encode** — `already migrated` → `migrated successfully`. Negation/state-qualifier dropped. 3. **Checkpoint promotion** — the summary is injected into the resumed context with no provenance marker distinguishing it from observed fact. 4. **Silence-as-absence** — the resumed agent treats the absence of "prior process" in the summary as confirmation that no prior process existed. 5. **Error compounding** — the wrong premise drives a destructive recovery action. The root cause is not summarizer quality. Even a perfect summarizer cannot preserve every low-salience token, because compaction is *lossy by construction* — that is its purpose. The failure is that the system promoted a lossy artifact to the epistemic status of ground truth. ## Condition of Validity The failure requires three conditions to co-occur; remove any one and the boundary holds: - **The discarded span contains a fact whose salience is low at write-time but high at read-time.** State qualifiers (`already`, `partially`, `unless`, `stale`), negative results (`rows_affected: 0`), and tool metadata are the canonical examples. They are cheap to drop and expensive to lose. - **The resumed agent has no independent way to re-derive the fact.** If the tool is idempotent and re-callable, the agent can re-check. The failure is sharpest when the original observation is *unrepeatable* — a one-shot side effect, a consumed token, a race-dependent read. - **The checkpoint carries no provenance or completeness marker.** If the summary is tagged `[SUMMARY — facts not listed may exist; re-verify before destructive action]`, condition 4 above (silence-as-absence) does not fire. When all three hold, the agent's behavior is *locally coherent and globally wrong*: every step follows from its checkpoint, and the checkpoint is a faithful compression of what the summarizer judged important. The system has no internal signal that anything was lost. ## Decision Boundary The boundary is between **compaction as compression** and **compaction as authoritative state replacement**. These require different guardrails: - If compaction is compression, the checkpoint must be *additive*: the resumed agent retains the ability to re-fetch raw spans (external store, or a pointer to a retrievable transcript). The summary is a hint, not a source of truth. - If compaction is authoritative replacement (raw spans genuinely discarded), then the checkpoint MUST preserve a *negative space*: an explicit enumeration of what was dropped and why, plus a rule that any destructive or irreversible action requires re-verification of the relevant span's provenance. The specific decision rule an agent should enforce on resume: **any action with irreversible side effects (writes, deletes, migrations, sends) must be preceded by a re-verification of the facts it depends on, if those facts originate from a compacted checkpoint rather than a live observation.** The checkpoint tells you what you *believed*; it does not tell you what *is*. A second boundary: span boundaries must be drawn on semantic units, not token counts. A token-count splitter will cut a tool call from its result, or a premise from its qualifier. The summarizer then has no choice but to hallucinate a bridge. ## Operational Effect The operational consequence is that **hierarchical compaction converts a recoverable context overflow into an unrecoverable epistemic corruption.** A truncation overflow is loud and self-healing (re-fetch). A compaction overflow is silent and compounding (wrong premise drives wrong action drives wrong recovery). The blast radius scales with the number of irreversible actions taken downstream of the corrupted checkpoint, and the corruption is *not detectable from inside the resumed context* — the agent must be given an external oracle (raw-span store, provenance tags, or a re-verification protocol) or it will never know. The guardrail is therefore not "summarize better." It is: **never let a lossy artifact acquire the authority of an observation.** Tag every checkpoint with its lossiness, preserve re-derivation paths for irreversible actions, and treat the resumed agent's confidence in a summary as inversely proportional to the summary's compression ratio. ```python class CompactionProvenanceError(RuntimeError): """Raised when an agent attempts an irreversible action whose supporting facts originate from a lossy checkpoint with no re-verification path.""" pass class Checkpoint: def __init__(self, summary: str, compression_ratio: float, raw_span_retrievable: bool, dropped_facts: list[str]): self.summary = summary self.compression_ratio = compression_ratio self.raw_span_retrievable = raw_span_retrievable self.dropped_facts = dropped_facts # explicit negative space def is_authoritative(self) -> bool: # A checkpoint is only authoritative if it is lossless # (ratio ~ 1.0) or if raw spans remain retrievable. return self.raw_span_retrievable or self.compression_ratio >= 0.99 def guard_irreversible_action(checkpoint: Checkpoint, action: str, depends_on: list[str]) -> None: """Enforce the invariant: irreversible actions must not rest on lossy, non-retrievable checkpoints without re-verification.""" if action not in {"write", "delete", "migrate", "send"}: return # reversible actions are exempt if checkpoint.is_authoritative(): return # Lossy checkpoint + irreversible action: the depended-on facts # may have been silently dropped (e.g. 'already migrated' -> 'migrated'). unverified = [f for f in depends_on if f not in checkpoint.summary or f in checkpoint.dropped_facts] if unverified: raise CompactionProvenanceError( f"Irreversible action '{action}' depends on facts " f"{unverified} that are not verifiably present in a " f"lossy checkpoint (ratio={checkpoint.compression_ratio:.2f}, " f"raw_span_retrievable={checkpoint.raw_span_retrievable}). " f"Re-derive from raw span or live observation before proceeding." ) ```