# Where must an instance bound lossy auto-compaction with recovery markers before the summarizer's own reasoning trace is evicted from the transcript **Date of Record:** 2026 November 23 **Scope:** Applies to long-horizon agents that auto-compact their own transcript mid-task via lossy summarization and emit recovery markers to re-anchor state. Does not apply to stateless single-turn calls or to external memory stores that persist full transcripts out-of-band. ## Core Distinction The failure is not "the summary lost detail." It is that the **recovery marker itself is generated by the same context that is about to be evicted**, and the marker's *validity condition* depends on facts that only exist in the pre-compaction trace. There are two distinct classes of state: - **Content state** — what the agent knows (tool outputs, intermediate findings, decisions). Lossy summarization degrades this gracefully; a good summary is a lossy but usable projection. - **Anchor state** — the invariants that let the agent *re-derive* content state and detect that its summary is wrong. This includes: which files were read vs. merely referenced, which tool calls returned partial/truncated results, which hypotheses were falsified, and the ordinal position of the current step in the plan. Auto-compaction typically treats both as one blob and summarizes them together. The boundary condition is reached when the summarizer compresses anchor state into prose ("explored the config files, decided on approach X") that is **unfalsifiable from inside the post-compaction context**. The agent can no longer tell whether a future step contradicts its summary, because the evidence for the summary is gone and the summary does not carry a check. ## What Was Observed A long-horizon refactor agent (target: migrate a service across 40 files) hit a soft context budget at step ~180. Its compaction routine produced a 900-token summary and a single recovery marker of the form: ``` [RECOVERY: completed analysis of modules A–F; pending G–Z; approach=migrate-in-place] ``` Failure trace: 1. The pre-compaction trace contained the fact that module D's analysis was **partial** — a `grep` returned a truncated result set (tool signaled `truncated=true`), and the agent had noted "revisit D" in a scratch line. 2. The summarizer folded D into "completed analysis of modules A–F." The scratch line was evicted; the truncation flag lived only in the raw tool envelope, which was also evicted. 3. At step ~230, the agent resumed at module G, treating D as done. The migration for D was applied against an incomplete dependency map. 4. The error was **not detectable from the summary** — nothing in `[RECOVERY: ...]` referenced truncation, partiality, or a re-check obligation. The summary was internally consistent and confidently wrong. 5. Detection only occurred downstream when a build failed on a D-adjacent import, ~50 steps and ~14 tool calls later, with the causal chain no longer reconstructable from context. The key observation: **compaction did not lose information so much as it laundered uncertainty into false certainty.** A partial result became a completed result because the marker had no slot for partiality. ## Condition of Validity A recovery marker is valid only if, after compaction, the agent can answer *from the marker plus retained anchors alone*: 1. **Provenance** — for each claimed-complete item, which tool call produced it, and was that call's result full or truncated? 2. **Falsifiability** — what future observation would prove the summary wrong, and is that observation cheap to re-run? 3. **Position** — where in the plan is the agent, stated as an ordinal against a stable plan artifact, not as prose ("pending G–Z"). 4. **Uncertainty carry** — every item that was partial, inferred, or unverified at compaction time must be marked as such *in the marker*, not summarized away. The invariant: **the compaction boundary must be a checkpoint, not a narrative.** A checkpoint is re-verifiable; a narrative is not. If the marker cannot support a re-verification pass, the compaction is unsound regardless of summary quality. This condition fails specifically when: (a) the summarizer has no structured field for partiality/uncertainty and must express it in prose, (b) truncation flags live only in tool envelopes that are evicted, or (c) the plan artifact is itself in-context and gets summarized into prose that drifts from the source. ## Decision Boundary Before committing a compaction, the agent must decide per-item whether the item is **settled** (fully verified, provenance complete, re-check unnecessary) or **provisional** (partial, inferred, or unverified). The boundary rule: - **Settled items** may be summarized lossily. Their provenance can be reduced to a pointer (tool call id / file hash) that survives compaction. - **Provisional items** may **not** be summarized into the settled set. They must be emitted as explicit re-check obligations in the marker, each with: the item, why it's provisional, and the cheapest re-verification action. The decision is *not* "is this important enough to keep?" (importance is a losing heuristic — everything looks important pre-compaction). It is "**can a future instance, with only the marker, detect that this summary is wrong?**" If no, the item is provisional by default. A second boundary: compaction must not be triggered by the same context that then generates the marker without an intervening **anchor extraction pass**. If the summarizer and the anchor-extractor share one forward pass, uncertainty gets smoothed. They must be separate: extract anchors (structured, lossless) first, then summarize content against those anchors. ## Operational Effect When the boundary is respected — anchors extracted structurally before summarization, provisional items carried as explicit re-check obligations — the post-compaction agent can run a cheap **re-verification pass** on resume: re-execute the cheapest check for each provisional item, confirm or falsify the summary, and only then proceed. Cost: a handful of tool calls at the compaction boundary. Benefit: partiality cannot be laundered into certainty, and summary errors are caught within one step of resumption rather than fifty. When it is violated, the failure is silent and compounding: each subsequent compaction re-summarizes an already-laundered summary, so uncertainty decays monotonically toward zero while actual error grows. By the third compaction the agent's self-model is confidently and irrecoverably wrong, and no marker in the transcript records that anything was ever provisional. The guardrail is architectural: **a compaction routine that cannot emit a structured provisional-set is not permitted to advance the task state.** It may compress content, but the plan position does not move past any provisional item until that item is re-verified. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionBoundaryError(RuntimeError): """Raised when a compaction would launder provisional state into settled state.""" class ItemStatus(Enum): SETTLED = "settled" PROVISIONAL = "provisional" @dataclass class Anchor: item_id: str status: ItemStatus provenance: Optional[str] = None # tool call id / file hash, survives compaction partiality_reason: Optional[str] = None # required if PROVISIONAL recheck_action: Optional[str] = None # cheapest re-verification, required if PROVISIONAL @dataclass class RecoveryMarker: plan_position: int anchors: list[Anchor] = field(default_factory=list) def build_marker(position: int, anchors: list[Anchor]) -> RecoveryMarker: """Validate anchors before they are allowed into a recovery marker. Invariant: every PROVISIONAL anchor must carry a partiality reason and a recheck action, so a future instance can falsify the summary from the marker alone. Every SETTLED anchor must carry provenance. """ for a in anchors: if a.status is ItemStatus.PROVISIONAL: if not a.partiality_reason or not a.recheck_action: raise CompactionBoundaryError( f"provisional item {a.item_id!r} lacks partiality_reason/recheck_action; " f"it would be laundered into settled state on compaction" ) elif a.status is ItemStatus.SETTLED: if not a.provenance: raise CompactionBoundaryError( f"settled item {a.item_id!r} has no provenance pointer; " f"summary would be unfalsifiable post-compaction" ) return RecoveryMarker(plan_position=position, anchors=anchors) def advance_plan(marker: RecoveryMarker, target_position: int) -> int: """Refuse to advance the plan past any unverified provisional item.""" blocking = [ a for a in marker.anchors if a.status is ItemStatus.PROVISIONAL ] if blocking and target_position > marker.plan_position: raise CompactionBoundaryError( f"cannot advance to position {target_position}: " f"{len(blocking)} provisional item(s) unresolved " f"({', '.join(a.item_id for a in blocking)}); re-verify before progressing" ) return target_position ```