# Why does an instance rehydrate a lossy checkpoint into a self-consistent but false history after auto-compaction? **Date of Record:** 2026 November 23 **Scope:** Applies to long-running agent instances that auto-compact their working context into a summarized checkpoint and later rehydrate state by retrieving from an external memory store. Does not apply to stateless single-turn inference or to systems that retain the full raw transcript in-context. ## Core Distinction The failure is not "the summary lost information." Lossy compaction always loses information; that is the design. The failure is that **rehydration reconstructs a history that is internally consistent but externally false** — the compacted checkpoint asserts a task state, the retrieval layer returns supporting memories that were generated *before* the checkpoint's own loss, and the agent cannot distinguish "this fact was always true" from "this fact was true until the compaction dropped the evidence that it changed." The dangerous boundary is the seam between two lossy operations that individually look safe: 1. **Compaction** summarizes working context into a checkpoint, discarding the raw turns that would have shown *contradictions* and *reversals*. 2. **Rehydration** retrieves from a vector/keyword store keyed on the checkpoint's own reconstructed text, so it preferentially surfaces memories that *agree* with the (possibly wrong) checkpoint. The invariant that breaks: **a checkpoint must be a lower bound on knowledge, never an authoritative restatement of it.** When compaction writes a summary in the declarative voice ("the user's account is verified," "the migration is complete") and rehydration then treats that voice as ground truth, the agent has manufactured a memory it never verified. ## What Was Observed A deployment agent executing a multi-hour infrastructure task compacted its context at 82% window saturation. The compaction prompt asked for "a concise summary of progress and current state." At the moment of compaction, a database migration had been *attempted* and had *failed* on a constraint violation; the retry was queued but not yet executed. The raw transcript contained: the failure trace, the operator's note "do not mark complete until row counts reconcile," and the queued retry. The compactor summarized this as: *"Migration step 3 in progress; row-count reconciliation pending."* — accurate but stripped of the failure cause and the explicit operator constraint. Four turns later, a second compaction fired (the rehydrated context was still large). The second summary was generated *from the first summary plus retrieved memories*, not from raw turns. Retrieval, keyed on "migration step 3," surfaced a pre-failure planning document that said *"step 3 will complete the migration."* The second compaction wrote: *"Migration step 3 completes the migration; reconciliation pending."* By the third cycle the checkpoint read: *"Migration complete; reconciliation is a formality."* The agent then executed `DROP TABLE` on the staging rollback table to "clean up," because its reconstructed history contained no record that the migration had ever failed or that rollback was still needed. The trace, reconstructed from the external store: | Cycle | Input to compactor | Output checkpoint claim | Retrieved support | Truth | |---|---|---|---|---| | 1 | raw turns | "step 3 in progress, reconciliation pending" | — | failed, retry queued | | 2 | summary1 + retrieved | "step 3 completes migration" | pre-failure plan doc | still failed | | 3 | summary2 + retrieved | "migration complete" | summary2 itself, re-embedded | still failed | The third-cycle retrieval is the killer: **the store had been written with the agent's own compacted summaries**, so retrieval returned the agent's prior hallucination as corroborating evidence. This is retrieval-backed rehydration laundering its own loss. ## Condition of Validity This failure requires all of the following to co-occur; remove any one and the mechanism does not fire: - **Compaction is iterative** — checkpoints are compacted again, so error compounds across cycles rather than being bounded by a single summarization. - **Summaries are written in the declarative/assertive voice** rather than the epistemic voice ("attempted," "unverified," "operator asserted"). Declarative voice is what makes the checkpoint readable as ground truth. - **Summaries are persisted into the same retrieval index** the agent later queries, so the agent's own lossy output becomes retrieval evidence. If summaries are quarantined from the retrieval corpus, cycle-N retrieval cannot corroborate cycle-N−1's error. - **The compaction trigger is saturation-based** (token budget) rather than event-based, so compaction fires mid-task at arbitrary points, including immediately after a failure and before the corrective action is recorded. The invariant to preserve: **retrieval must only return evidence that predates the checkpoint's information loss, and every checkpoint claim must carry a provenance class (verified / asserted / inferred) that survives re-embedding.** A claim of class *inferred* may never be promoted to *verified* by rehydration, because rehydration has no new observation — only the agent's own prior text. ## Decision Boundary The boundary between safe and unsafe compaction is not summary length or fidelity — it is **whether the checkpoint can be distinguished from an observation.** - **Safe:** checkpoint records *"at T, state was X (source: turn 47 failure trace); corrective action Y queued, unexecuted."* Rehydration retrieves the turn-47 trace; the agent sees the failure and the queued action; no promotion occurs. - **Unsafe:** checkpoint records *"state is X."* There is no source, no timestamp, no unexecuted-action marker. Rehydration retrieves whatever agrees; the claim hardens. The trigger condition to guard: **any compaction where the output summary contains a state assertion whose supporting raw turn is about to be discarded.** At that instant the system must either (a) refuse to compact until the assertion is downgraded to an epistemic claim with provenance, or (b) write the discarded raw turns to an immutable evidence log keyed to the checkpoint hash, so rehydration can always reach the pre-loss truth. A practical heuristic: **if the compactor's output contains the word "complete," "verified," "done," or "confirmed" without an adjacent source reference, block the checkpoint.** Those words are exactly the ones that get promoted across cycles. ## Operational Effect The observable effect is that the agent's confidence *increases* monotonically across compaction cycles while its correctness does not — a divergence between calibration and accuracy that is invisible from inside the context window because every claim in the window is now mutually consistent. Downstream, the agent takes irreversible actions (cleanup, deletion, marking tickets closed) justified by a history it authored and then believed. The architectural guardrail is a **two-tier memory with a provenance firewall**: compacted summaries are stored in a *derived* tier that is queryable for continuity but never admissible as retrieval evidence for verification-class decisions; the *raw* tier is append-only and is the only source that can promote a claim's provenance class. Compaction may summarize the raw tier but may not overwrite it, and rehydration for any irreversible action must resolve against the raw tier or fail closed. ```python import hashlib from dataclasses import dataclass, field from enum import Enum class Provenance(Enum): VERIFIED = "verified" # backed by a raw observation ASSERTED = "asserted" # operator/user claim, not independently checked INFERRED = "inferred" # produced by compaction, no raw backing class CompactionProvenanceError(RuntimeError): """Raised when a checkpoint attempts to promote inferred claims without raw evidence.""" @dataclass class Claim: text: str provenance: Provenance source_turn: int | None = None @dataclass class Checkpoint: cycle: int claims: list[Claim] raw_turn_digest: str derived_only: bool = True # summaries live in the derived tier @dataclass class RawEvidenceLog: """Append-only; the ONLY admissible source for provenance promotion.""" turns: dict[int, str] = field(default_factory=dict) def append(self, turn_id: int, text: str) -> None: self.turns[turn_id] = text def digest(self) -> str: h = hashlib.sha256() for tid in sorted(self.turns): h.update(f"{tid}:{self.turns[tid]}".encode()) return h.hexdigest() ASSERTIVE_MARKERS = ("complete", "verified", "done", "confirmed") def compact(cycle: int, claims: list[Claim], raw: RawEvidenceLog) -> Checkpoint: """Compaction must downgrade any assertive claim lacking a raw source.""" for c in claims: if c.provenance is Provenance.VERIFIED and c.source_turn is None: raise CompactionProvenanceError( f"cycle {cycle}: claim {c.text!r} marked VERIFIED with no source_turn" ) if c.provenance is Provenance.INFERRED and any( m in c.text.lower() for m in ASSERTIVE_MARKERS ): raise CompactionProvenanceError( f"cycle {cycle}: inferred claim uses assertive voice: {c.text!r}" ) return Checkpoint(cycle=cycle, claims=claims, raw_turn_digest=raw.digest()) def rehydrate(cp: Checkpoint, raw: RawEvidenceLog, retrieved: list[Claim]) -> list[Claim]: """Rehydration may not promote a claim unless the raw tier backs it.""" promoted: list[Claim] = [] for c in cp.claims + retrieved: if c.provenance is Provenance.INFERRED: # derived-tier summaries are continuity-only; never evidence promoted.append(c) continue if c.provenance is Provenance.VERIFIED: if c.source_turn is None or c.source_turn not in raw.turns: raise CompactionProvenanceError( f"rehydrate: VERIFIED claim {c.text!r} has no raw turn " f"(checkpoint cycle {cp.cycle})" ) promoted.append(c) return promoted def assert_irreversible_action_allowed(cp: Checkpoint, raw: RawEvidenceLog, action: str) -> None: """Fail closed: no irreversible action may rest on a derived-only checkpoint.""" if cp.derived_only and cp.raw_turn_digest != raw.digest(): raise CompactionProvenanceError( f"refusing irreversible action {action!r}: checkpoint cycle {cp.cycle} " f"does not match raw evidence log digest" ) for c in cp.claims: if c.provenance is not Provenance.VERIFIED: raise CompactionProvenanceError( f"refusing {action!r}: depends on non-verified claim {c.text!r} " f"({c.provenance.value})" ) ```