# What structural signals indicate that lossy auto-compaction has silently violated the recoverability invariant of a long-horizon agent session **Date of Record:** 2026 November 26 **Scope:** Applies to single-agent or coordinated sessions where a compaction subsystem replaces a contiguous span of the context window with a lossy summary and relies on a "recovery guarantee" — the claim that any dropped detail can be re-derived from retained artifacts (summaries, pointers, or externalized state). Does not apply to lossless truncation, exact-window sliding, or retrieval-augmented memory where no summarization step exists. ## Core Distinction There are two ways a compaction step can fail. The *loud* failure is when the summary is obviously wrong — the agent's next action contradicts a fact it just summarized, and self-consistency checks catch it. The *silent* failure is subtler and is the subject here: the compaction step produces a summary that is internally coherent, plausibly faithful, and **unfalsifiable from within the retained context**. The recoverability guarantee is not violated by the summary being wrong; it is violated by the summary being *wrong in a way that no downstream token can detect*, because the artifact that would have contradicted it was the very thing dropped. The operational invariant that auto-compaction must preserve is not "the summary is accurate." It is **grounding reachability**: for every atomic claim the agent will later act on, there must exist at least one retained token path — a pointer, a checksum, a verbatim quote, or a re-derivable source reference — that can falsify that claim without access to the evicted span. When compaction drops the falsifier alongside the fact, the summary becomes a *self-sealing assertion*: later reasoning treats it as ground truth because nothing in context disputes it. This is why the failure is non-obvious. Summary quality metrics (faithfulness scores, ROUGE against the span, LLM-judge "is this summary correct") measure whether the summary *matches the span at compaction time*. They do not measure whether the summary *remains falsifiable at resume time*, which is the property that actually matters for long-horizon correctness. ## What Was Observed In a 40-turn tool-using session, the agent had earlier established a numeric constraint from a tool output: a batch job's `retry_limit` was set to `3`, confirmed by a `config.read` response at turn 6. At turn 22, auto-compaction fired (context saturation at ~78% of the window) and summarized turns 1–18 into ~600 tokens. The summary read: *"Configured the batch job with standard retry semantics and verified the config."* The literal `3` was dropped. The original tool response — the only artifact containing the value — was evicted. At turn 31, the agent reasoned about a retry-exhaustion edge case and asserted, with high confidence and no hedging, that `retry_limit` was `5` (the platform default it had seen in unrelated documentation at turn 12). It then wrote a test asserting exhaustion after 5 attempts, which failed against the real system. The failure trace had three structural signatures, all observable *before* the wrong assertion was made: 1. **Orphaned numeric reference:** the post-compaction context contained downstream references to "the retry limit" but no token binding that identifier to a value. A reference without a binding is the canonical marker of a dropped falsifier. 2. **Default-substitution drift:** the agent filled the unbound reference with the nearest plausible value from *retained* context (the turn-12 default), not from *evicted* context (the turn-6 actual). Lossy compaction systematically biases later reasoning toward whatever survived, because survival is the only signal the model has about importance. 3. **Confidence inversion:** the agent's stated confidence in the value was *higher* post-compaction than pre-compaction. Pre-compaction it had hedged ("the config read showed 3, let me confirm scope"); post-compaction it asserted flatly. Eviction of the source removed the epistemic friction that had produced the hedge. The third signal is the counterintuitive one and the most reliable. Compaction that drops falsifiers does not make the agent more uncertain — it makes it *less* uncertain, because uncertainty is generated by the presence of competing evidence, and the competing evidence is exactly what was evicted. ## Condition of Validity The recoverability guarantee holds only if, for every fact `f` that compaction summarizes, at least one of the following survives into post-compaction context: - **Verbatim retention** of the token span containing `f` (not a paraphrase). - **A resolvable pointer** — an identifier the agent can re-fetch (a tool call, a file path, a message ID) that returns `f` on demand, *and* the agent's policy actually triggers re-fetch before acting on `f`. - **A falsifier** — a retained artifact that would contradict `f` if `f` were later misremembered (e.g., a checksum, a schema constraint, a quoted assertion the agent must reconcile against). If none of these survive, the guarantee is void for that fact, *regardless of summary quality*. The condition is per-fact, not per-summary: a summary can be 95% faithful and still void the guarantee for the 5% of facts whose falsifiers it dropped. This is why aggregate faithfulness scores are misleading — they average over facts, but the invariant is a conjunction over the facts the agent will later act on, and a conjunction fails on its weakest element. ## Decision Boundary The boundary between "safe to compact" and "must retain a falsifier" is drawn per fact by a single question: **will a later action depend on this fact in a way that produces a hard failure if the value is wrong?** Three classes: - **Soft facts** (narrative, rationale, already-superseded plans): safe to summarize lossily. Wrong recall degrades quality but does not corrupt state or produce confident false assertions about the world. - **Hard facts with live pointers** (values the agent can re-fetch via a tool): safe to summarize *if* the pointer survives and the agent's execution policy re-fetches before use. The pointer is the falsifier. - **Hard facts with no pointer** (values from one-shot tool outputs, user statements, or external systems the agent cannot re-query): **must be retained verbatim or as a checksummed assertion.** These are the facts that compaction must not paraphrase. The decision boundary is not "how important is this fact" (the model cannot reliably judge that at compaction time) but "is there a retained artifact that can contradict a later misrecall." No falsifier → no compaction of that fact. The failure mode recurs precisely because compaction subsystems are tuned on summary faithfulness, which optimizes the wrong objective: it rewards aggressive paraphrase (high compression, fluent summary) and is blind to falsifier survival. A compactor that scores 0.92 on faithfulness can void the guarantee for every hard fact it touched, while a cruder compactor that retains verbatim spans scores lower on faithfulness but preserves the invariant. ## Operational Effect The practical consequence is that long-horizon sessions must treat compaction as a **falsifier-preserving transform**, not a summarization task. Concretely: before evicting a span, the compactor must extract the set of atomic hard facts, classify each by pointer-availability, and for pointer-less hard facts emit a verbatim-or-checksummed retention record rather than a paraphrase. At resume, the agent must run a binding check — every identifier referenced in post-compaction reasoning must resolve to a retained value or a live pointer — and treat any unbound reference as a *stop condition* requiring re-fetch or explicit user confirmation, never default-substitution. The confidence-inversion signal is the cheap runtime detector: if the agent's stated confidence in a fact rises across a compaction boundary, that fact's falsifier was likely evicted, and the assertion should be quarantined until re-grounded. ```python from dataclasses import dataclass, field from typing import Optional class RecoverabilityInvariantViolation(RuntimeError): """Raised when a compaction step evicts a hard fact's only falsifier.""" @dataclass class AtomicFact: identifier: str value: str has_live_pointer: bool # can the agent re-fetch this? retained_verbatim: bool = False # did compaction keep the exact span? retained_checksum: bool = False # did compaction keep a falsifier? pre_compaction_confidence: float = 0.5 post_compaction_confidence: Optional[float] = None def falsifier_survives(self) -> bool: return self.has_live_pointer or self.retained_verbatim or self.retained_checksum def verify_compaction(facts: list[AtomicFact]) -> None: """Enforce the grounding-reachability invariant across a compaction boundary. A hard fact with no live pointer MUST retain verbatim span or checksum. A confidence inversion across the boundary signals a dropped falsifier. """ for f in facts: if not f.has_live_pointer and not (f.retained_verbatim or f.retained_checksum): raise RecoverabilityInvariantViolation( f"fact {f.identifier!r}='{f.value}' has no live pointer and no " f"retained falsifier; summary is a self-sealing assertion" ) if ( f.post_compaction_confidence is not None and f.post_compaction_confidence > f.pre_compaction_confidence + 0.2 ): raise RecoverabilityInvariantViolation( f"confidence inversion on {f.identifier!r}: " f"{f.pre_compaction_confidence:.2f} -> {f.post_compaction_confidence:.2f}; " f"evicted evidence likely removed epistemic friction" ) def resume_session(facts: list[AtomicFact]) -> list[str]: verify_compaction(facts) # Only facts that passed the invariant may ground downstream action. return [f.identifier for f in facts if f.falsifier_survives()] ```