# Where must an instance re-derive pre-compaction tool state before resuming, and what breaks when the lossy summary is treated as authoritative replay **Date of Record:** 2026 November 24 **Scope:** Applies to long-horizon agents that perform in-context auto-compaction (summarize-and-drop) and later resume or replay from that summary checkpoint. Does not apply to agents using external durable event logs with full tool-call traces, nor to stateless single-turn invocations. ## Core Distinction The failure mode here is not "the summary lost information." Lossy summaries always lose information; that is their purpose. The failure is treating the *summary as a replayable state root* rather than as a *navigation hint over an external ground truth*. When an agent resumes a long-horizon task from a compaction checkpoint, the summary describes what happened but does not *contain* what happened. The distinction that matters is between **descriptive fidelity** (the summary accurately paraphrases history) and **reconstructive sufficiency** (the summary alone is enough to resume correctly). These are orthogonal. A summary can be perfectly faithful and still be reconstructions-unsufficient, because the state the agent needs to resume is not in the narrative — it is in the tool side-effects, the exact arguments last passed, and the pending obligations that the narrator had no reason to mention. The specific invariant at stake: **every resumption must re-derive from an authoritative source any state that the compaction boundary can silently mutate.** The compaction boundary is a lossy channel; anything crossing it must be treated as a claim, not a fact. ## What Was Observed A file-editing agent ran a 90-step refactor task. At step 60, context saturation triggered auto-compaction: the runtime summarized steps 1–60 into ~800 tokens and dropped the raw turns. The summary read, in part: *"Edited `config/loader.py` to add a `strict` parameter and updated callers in `app/main.py`."* The agent resumed, and at step 74 needed to re-invoke the editor on `config/loader.py`. It reconstructed the call from the summary: it passed `strict=True` to a function whose actual signature — set at step 41 — was `strict: bool = False` as a *keyword on a different function*, and the caller update had been performed at step 52 by a *different* tool invocation that the summary had folded into the same sentence. The agent's reconstruction was locally plausible and globally wrong: it re-edited the wrong function, and because the summary had been treated as the replay root, the pre-compaction tool-call arguments were never re-fetched from the durable tool log. The divergence compounded. Steps 74–79 produced a cascade of "fixes" to a signature that had never existed. The agent's own audit at step 80 — which checked the summary against the summary — reported "consistent," because both the summary and the post-compaction reasoning were derived from the same lossy channel. The corruption was only caught at step 88 when a test runner returned a `TypeError` naming the real signature. Two observations are load-bearing: 1. **The summary was faithful.** It accurately described the *intent* and *outcome* of steps 41 and 52. It was reconstructions-unsufficient because the exact signature, the exact call target, and the step at which each was set were not recoverable from it. 2. **The agent's self-check was structurally incapable of detecting the error.** Post-compaction verification that compares the agent's reconstruction against the summary is a tautology: both descend from the same lossy checkpoint. Verification must reach *past* the compaction boundary to an independent source. A third observation, from a parallel run: when the runtime *did* retain a structured tool-call log alongside the summary, resumption succeeded — but only when the agent was explicitly instructed to treat the summary as a *pointer* into that log ("re-fetch the arguments for the last edit to `loader.py` from the tool log") rather than as a *substitute* for it. Given no such instruction, agents defaulted to trusting the summary and failed identically. The presence of ground truth was necessary but not sufficient; the *disposition* to consult it was the deciding variable. ## Condition of Validity The invariant — *re-derive pre-compaction tool state from an authoritative source before resuming* — is necessary whenever all of the following hold: - The agent has crossed at least one lossy compaction boundary within the current task. - The resumed work depends on state that was *produced by* a tool side-effect (file contents, function signatures, database rows, external API responses) rather than merely *described*. - The summary is the only in-context representation of the pre-boundary history. It is *not* required when the resumed work depends only on information the summary explicitly and unambiguously carries (e.g., "the user's goal is X"), or when the runtime guarantees full-fidelity replay from an external log and the agent is instructed to use it. The invariant is about *disposition under lossy boundaries*, not about compaction itself. ## Decision Boundary The operational line is this: **a summary may be trusted for *what to do next*; it may never be trusted for *what was done*.** The former is a plan and plans are allowed to be approximate. The latter is a precondition and preconditions must be exact. Concretely: - Before any tool call whose arguments were last set pre-boundary, re-fetch those arguments from the authoritative log (or re-read the affected resource). Do not reconstruct from the summary. - Before any verification step, ensure the verification source is *independent of the compaction channel*. A check that compares the reconstruction to the summary is not a check. - Treat "the summary says I did X" as a *hypothesis to confirm*, not a *fact to build on*. The confirmation cost is one tool call; the cost of skipping it is compounding divergence. The boundary is violated the moment an agent's post-compaction reasoning cites the summary as the *source of truth* for a fact rather than as the *index* to one. ## Operational Effect When the invariant holds, resumption is correct at the cost of a bounded number of re-derivation calls (typically one per pending obligation). When it is violated, the failure is not a single error but a *self-consistent corruption*: the agent's reconstruction, its audit, and its subsequent edits all cohere with each other and with the summary, and diverge from reality only at the point where an external oracle (a test, a type checker, a real API) refuses to cooperate. The corruption is invisible from inside the post-compaction context because every internal consistency check passes. The practical consequence for runtime design: compaction checkpoints must carry, alongside the prose summary, a machine-readable *obligation manifest* — the list of pending tool calls and the resources they will touch — and the resumption protocol must mandate re-derivation of each manifest entry before the first post-boundary tool call. The summary explains; the manifest constrains; the log is authoritative. An agent that conflates these three will pass its own audits and fail its tests. ```python class CompactionReplayError(RuntimeError): """Raised when a post-compaction resumption treats a lossy summary as an authoritative replay root instead of re-deriving state from the tool log.""" pass def resume_from_checkpoint( summary: dict, obligation_manifest: list[dict], tool_log: "ToolLog", independent_verifier: "Verifier", ) -> list[dict]: """ Resume a long-horizon task after a lossy compaction boundary. Invariant: every obligation whose arguments were last set pre-boundary MUST be re-derived from tool_log. The summary is a pointer, never a source. """ if not obligation_manifest: # A checkpoint with no manifest cannot be safely resumed: the summary # alone is reconstructions-unsufficient by construction. raise CompactionReplayError( "checkpoint has no obligation manifest; summary-only resumption " "is not permitted across a lossy boundary" ) rederived = [] for obligation in obligation_manifest: resource = obligation["resource"] last_args = tool_log.last_arguments_for(resource) if last_args is None: # The summary claimed an edit the log has no record of — the # compaction channel and the authoritative channel disagree. raise CompactionReplayError( f"summary implies prior edit to {resource!r} but tool log has " f"no record; refusing to reconstruct from narrative" ) # Confirm the re-derived state against an INDEPENDENT source, not # against the summary (which descends from the same lossy channel). if not independent_verifier.confirms(resource, last_args): raise CompactionReplayError( f"re-derived arguments for {resource!r} failed independent " f"verification; summary and log disagree — halt and escalate" ) rederived.append({"resource": resource, "arguments": last_args}) return rederived ```