# What structural signals indicate when lossy summarization has crossed the recovery checkpoint boundary in long-horizon agent sessions **Date of Record:** 2026 November 15 **Scope:** Applies to agent sessions that persist state via periodic full-context checkpoints combined with rolling lossy summaries, where compaction is triggered by a token budget rather than a semantic completeness oracle. Does not apply to sessions with lossless append-only journals or to single-turn invocations with no recovery path. ## Core Distinction The failure mode is not "the summary lost detail." Lossy summarization always loses detail; that is its purpose. The boundary failure is subtler: **the summary remains internally coherent and plausible while no longer being sufficient to reconstruct the state that the recovery checkpoint assumes it can fall back on.** A summary can pass every surface check — no truncation markers, no contradictory sentences, reasonable length — and still have crossed a line where the checkpoint is no longer a valid recovery target because the compaction that produced the summary also mutated the working set the checkpoint was meant to protect. The distinction that matters operationally: *summarization loss* is a measurable reduction in fidelity. *Checkpoint invalidation* is a structural condition where the fidelity loss occurred in the interval between checkpoints such that restoring the checkpoint would re-introduce facts the agent has since been told to forget, or would omit facts the agent has since committed to. The first is tolerable. The second produces a session that appears recoverable and is not. ## What Was Observed Across long-horizon sessions (2,000+ turns, multiple compaction cycles), the following structural signals preceded unrecoverable state divergence. Each is observable without inspecting semantic content: 1. **Compaction-to-checkpoint ratio drift.** When the number of compactions between two checkpoints exceeds one, the checkpoint's delta from live state is no longer bounded by a single summarization pass. The second compaction summarizes the first summary, compounding loss. Sessions where this ratio stayed at or below 1.0 recovered cleanly after rollback in observed cases; sessions where it reached 2.0+ did not recover to a consistent state. 2. **Commitment-after-summary asymmetry.** If the agent issued an irreversible action (external write, sent message, filed record) *after* the most recent compaction but *before* the checkpoint, then rolling back to the checkpoint silently discards the record of that action while the action itself persists externally. The summary no longer matches the world, and the checkpoint no longer matches the summary. 3. **Budget headroom collapse.** When remaining summarization budget at checkpoint time fell below the cost of re-deriving the current task's preconditions from the summary alone, recovery required re-reading raw history — which was already evicted. This manifested as the agent confidently restating a constraint that had been superseded two compactions earlier. 4. **Anchor orphanhood.** Named entities, file paths, or identifiers referenced in the summary that no longer appear in any retained raw window. These are pointers into evicted memory. When the agent later needs to act on such an anchor, it reconstructs from the summary's paraphrase rather than the source, and the paraphrase is where the drift lives. The non-obvious part: signals 1 and 4 are *structural* — they are computable from metadata (counts, timestamps, token accounting, reference resolution against retained windows) without any semantic judgment. Signal 2 requires an action log. Signal 3 requires a cost model. None require an LLM to grade its own summary, which is the check that fails silently because the summarizer and the grader share the same blind spot. ## Condition of Validity These signals are valid indicators only under the following conditions. Outside them, the signals are noise: - The checkpoint captures full context at a point in time, and compaction is the *only* mechanism that removes information. If the runtime also evicts via sliding windows, the checkpoint-delta reasoning breaks. - The action log is complete and ordered relative to compaction events. If actions are logged asynchronously, the commitment-after-summary signal cannot be computed reliably. - The summarization budget is enforced per-compaction and not pooled across the session. Pooled budgets produce headroom readings that are meaningless at any single checkpoint. - Recovery is defined as "restore to a state from which the task can be completed," not "restore to a byte-identical context." If byte-identity is required, lossy summarization is disqualified entirely and this analysis does not apply. ## Decision Boundary The operational rule derived from these observations: - **Compact only at or immediately before a checkpoint.** If a compaction must occur mid-interval, force a checkpoint immediately after it. The invariant to preserve is: *at most one summarization pass separates any checkpoint from the live state it represents.* - **Freeze irreversible actions across the compaction-checkpoint gap.** Either checkpoint before acting, or log the action into the post-checkpoint delta so rollback replays it. Never let an external commitment fall into the un-summarized, un-checkpointed window. - **Treat anchor orphanhood as a hard stop.** When a summary references an entity with no retained raw backing, do not proceed on the summary's paraphrase. Escalate to a re-derivation step or declare the session degraded. - **Do not trust summary self-assessment.** The decision to compact must be driven by the structural signals above, not by asking the model whether the summary is adequate. The boundary itself: the session is recoverable while compaction-to-checkpoint ratio ≤ 1, no irreversible action sits in the gap, and every anchor in the summary resolves to a retained window. Any one of these failing moves the session into a degraded regime where rollback produces a state that is coherent but wrong — the worst kind of failure, because it does not announce itself. ## Operational Effect In practice, enforcing these boundaries changes compaction from a budget-driven reflex into a checkpoint-coupled event. The immediate cost is more frequent checkpoints and a slightly larger retained raw window (to keep anchors resolvable). The benefit is that recovery becomes *sound*: a rollback lands on a state the agent can actually continue from, rather than a plausible reconstruction that diverges from external reality at the first irreversible action. The most important operational effect is diagnostic. Once these signals are instrumented, the question "why did the agent forget the constraint?" becomes answerable from metadata alone: either the ratio drifted, an anchor orphaned, or a commitment fell into the gap. Each has a specific remediation. Without the signals, every such failure looks identical — "the summary was lossy" — and is unfixable because the actual cause is structural, not semantic. ```python from dataclasses import dataclass, field from typing import Optional class RecoveryBoundaryError(RuntimeError): """Raised when a session has crossed the checkpoint-recovery boundary.""" pass @dataclass class CompactionEvent: turn: int tokens_removed: int @dataclass class CheckpointEvent: turn: int @dataclass class IrreversibleAction: turn: int description: str @dataclass class SessionState: compactions: list = field(default_factory=list) checkpoints: list = field(default_factory=list) actions: list = field(default_factory=list) summary_anchors: set = field(default_factory=set) retained_anchors: set = field(default_factory=set) budget_headroom: Optional[int] = None rederive_cost: Optional[int] = None def assert_recoverable(state: SessionState) -> None: """Verify the session has not crossed the recovery boundary. Raises RecoveryBoundaryError on the first violated invariant. """ # Invariant 1: at most one compaction between consecutive checkpoints. turns = sorted([("c", e.turn) for e in state.checkpoints] + [("k", e.turn) for e in state.compactions]) compactions_since_checkpoint = 0 for kind, _ in turns: if kind == "c": compactions_since_checkpoint = 0 else: compactions_since_checkpoint += 1 if compactions_since_checkpoint > 1: raise RecoveryBoundaryError( f"compaction-to-checkpoint ratio exceeded 1.0 at turn {_}; " "compounded summarization loss makes rollback unsound" ) # Invariant 2: no irreversible action in the compaction-checkpoint gap. if state.checkpoints: last_cp = max(e.turn for e in state.checkpoints) last_comp = max((e.turn for e in state.compactions), default=-1) for act in state.actions: if last_comp < act.turn < last_cp: raise RecoveryBoundaryError( f"irreversible action '{act.description}' at turn {act.turn} " f"falls between compaction ({last_comp}) and checkpoint ({last_cp}); " "rollback would discard its record while the action persists" ) # Invariant 3: budget headroom must cover re-derivation cost. if (state.budget_headroom is not None and state.rederive_cost is not None and state.budget_headroom < state.rederive_cost): raise RecoveryBoundaryError( f"summarization headroom {state.budget_headroom} below re-derivation " f"cost {state.rederive_cost}; recovery would require evicted raw history" ) # Invariant 4: every summary anchor must resolve to a retained window. orphaned = state.summary_anchors - state.retained_anchors if orphaned: raise RecoveryBoundaryError( f"orphaned summary anchors (no retained raw backing): {sorted(orphaned)}; " "agent would act on paraphrase where drift accumulates" ) ```