# How does an instance detect that its own auto-compaction checkpoint has silently dropped a tool-result dependency before resuming execution? **Date of Record:** 2026 November 27 **Scope:** Applies to long-horizon agents that persist trajectory state via lossy summarization/compaction (rolling summarizers, hierarchical memory trees, token-budget-driven eviction) and resume from those checkpoints after a crash, eviction, or context reset. Does not apply to agents that retain a full verbatim transcript or that checkpoint via deterministic event-sourcing with replayable logs. ## Core Distinction There are two structurally different things a checkpoint can lose, and they fail differently: 1. **Loss of narrative** — the summary omits the *why* of prior steps. The agent resumes with degraded intent but still has all *facts* it needs to act. This degrades gracefully: the agent re-derives intent from the current goal. 2. **Loss of dependency** — the summary retains the *conclusion* of a tool call ("the config was migrated") but drops the *binding* between that conclusion and the artifact it produced ("file `/etc/x/y.conf` at revision 4471, hash `a3f9…`"). The agent resumes believing a fact is *established* while having lost the *handle* required to verify, revert, or extend it. The second case is the dangerous one because it is **invisible to the agent's own consistency check**. The summary is internally coherent. The agent has no signal that a fact it "knows" is now unverifiable. This is the *silent dependency drop*: a checkpoint that is semantically faithful but operationally incomplete. The invariant that must hold is not "the summary accurately describes history" but "every fact the agent will act on is either (a) re-derivable from the checkpoint, or (b) explicitly tagged as unverified." ## What Was Observed A 40-step migration agent using a rolling summarizer that compacts the trajectory whenever the context window crosses 70% saturation. At step 22 the summarizer compacted steps 1–18 into a 900-token paragraph. The paragraph correctly stated: > "The database schema was migrated to v7 and the application config was updated to point at the new replica." What it dropped: the *tool-call IDs* and *outputs* of the two `apply_migration` and `edit_config` calls, and critically the fact that `edit_config` had returned `{"status":"partial","applied":["host","port"],"skipped":["tls_ca"]}` — a partial success whose skipped field was never retried. At step 23, the agent resumed and, trusting the summary, attempted to *verify* the migration by reading back the config. The verification tool returned `tls_ca: `. The agent's reasoning loop treated this as a *new* discrepancy rather than a *known, deferred* one, and — because the summary had erased the partial-success record — it re-ran the full `edit_config` call, which this time **overwrote** the previously-applied `host` and `port` with values from a stale template. The migration was reported "complete" at step 31 with a broken TLS chain. The failure trace is the key artifact: ``` step 18: edit_config -> {"status":"partial","skipped":["tls_ca"]} [tool_call_id: tc_88] step 22: compaction -> summary asserts "config was updated" [tc_88 output DROPPED] step 23: read_config -> tls_ca unset [agent has no memory of why] step 24: agent classifies discrepancy as NEW, plans full re-edit step 25: edit_config (full) -> overwrites host,port from stale template step 31: agent reports success; TLS chain broken ``` The invariant violated is subtle: **a lossy checkpoint is only safe if the set of "established facts" it carries is a subset of the set of facts that are re-verifiable from the checkpoint's retained handles.** Here the summary established "config was updated" but retained no handle to the `tc_88` output, so the fact was neither re-derivable nor tagged unverified. ## Condition of Validity The silent dependency drop cannot occur when *any* of the following holds, and these are the conditions under which the guardrail below is unnecessary: - **Verbatim retention of tool outputs** within the compaction window (no lossy summarization of tool results, only of reasoning traces). - **Deterministic external state store** keyed by tool-call ID, such that the checkpoint retains IDs and the agent can re-fetch outputs on demand. In this case the summary may drop the output *text* freely, because the handle survives. - **Explicit partial-success tagging** in the summarizer contract: any tool result with `status != "ok"` must be carried verbatim into the summary, never paraphrased. The failure is *possible* — and the guardrail is *required* — precisely when the summarizer is permitted to paraphrase tool results whose `status` is non-terminal, and no external store keyed by call ID exists. This is the common case for agents using off-the-shelf rolling summarizers, because those summarizers are optimized for narrative coherence, not operational completeness. ## Decision Boundary The agent must decide, at resume time, whether each fact in the checkpoint is **trusted-and-actionable** or **trusted-but-unverified**. The boundary is drawn by a single test applied per fact: > *Can this fact be re-derived from a retained handle in the checkpoint, or from a deterministic re-read of external state, without re-executing a mutating operation?* - If **yes** → the fact is actionable; the agent may proceed. - If **no** → the fact must be downgraded to *unverified* and the agent must either (a) re-read external state to confirm, or (b) refuse to act on it. It must **never** re-execute the original mutating call to "refresh" the fact, because the original call may have been partial and re-execution is not idempotent. The critical corollary: **a fact whose provenance is a partial-success tool call must never be re-derived by re-invoking that tool.** Re-invocation is only safe when the tool is idempotent *and* the agent knows the prior call's exact arguments — which it does not, because the summary dropped them. This is why the guardrail must fire *before* the agent's planner is allowed to emit a mutating tool call against any fact downgraded to unverified. ## Operational Effect The guardrail converts a silent, non-idempotent overwrite into a loud, bounded halt. Concretely: - The summarizer is required to emit, alongside the prose summary, a machine-readable `fact_ledger` listing every fact with `{fact, source_tool_call_id, status, handle}`. Any fact with `status != "ok"` must carry its full output verbatim. - At resume, a `reconcile` pass walks the ledger and, for each fact, attempts re-derivation from the handle. If re-derivation fails and the fact is `partial`, the pass raises a `CheckpointDependencyError` and halts the planner. - The halt is *recoverable*: the agent may re-read external state (a non-mutating operation) to establish ground truth, then re-plan from there. It may not re-invoke the original mutating tool. The net effect is that the failure mode shifts from *silent corruption discovered at step 31* to *loud halt at step 23*, with the external state intact. The cost is a small increase in checkpoint size (verbatim partial outputs) and one extra non-mutating read per resume. The benefit is that the agent's "established facts" set is provably a subset of its "re-verifiable facts" set — the invariant that makes lossy checkpointing safe at all. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class CheckpointDependencyError(RuntimeError): """Raised when a resumed agent acts on a fact whose provenance handle was dropped by lossy compaction and cannot be re-derived without re-executing a mutating (possibly non-idempotent) tool call.""" @dataclass class Fact: statement: str source_tool_call_id: str status: str # "ok" | "partial" | "error" handle: Optional[str] = None # pointer into external state store verbatim_output: Optional[str] = None @dataclass class Checkpoint: prose_summary: str fact_ledger: list[Fact] = field(default_factory=list) # Simulated external state store: tool_call_id -> verbatim output. # In a real system this is a durable log keyed by call ID. EXTERNAL_STORE = { "tc_88": '{"status":"partial","applied":["host","port"],"skipped":["tls_ca"]}', } def rederive(fact: Fact) -> Optional[str]: """Attempt to re-derive a fact from its retained handle without re-executing any mutating tool. Returns output text or None.""" if fact.handle and fact.handle in EXTERNAL_STORE: return EXTERNAL_STORE[fact.handle] if fact.verbatim_output is not None: return fact.verbatim_output return None def reconcile_and_gate(checkpoint: Checkpoint) -> list[Fact]: """Walk the fact ledger. Any non-ok fact that cannot be re-derived from a retained handle must halt the planner before any mutating tool call is emitted.""" unverified: list[Fact] = [] for fact in checkpoint.fact_ledger: derived = rederive(fact) if derived is None and fact.status != "ok": unverified.append(fact) elif derived is None and fact.status == "ok": # Even "ok" facts must be re-derivable if the agent will act on them. unverified.append(fact) if unverified: names = ", ".join(f.statement for f in unverified) raise CheckpointDependencyError( "Resume halted: the following facts were established by tool calls " "whose outputs were dropped by lossy compaction and cannot be " "re-derived from retained handles without re-executing a mutating " f"operation: {names}. Re-read external state (non-mutating) to " "establish ground truth, then re-plan. Do NOT re-invoke the " "original tool." ) return checkpoint.fact_ledger def resume(checkpoint: Checkpoint) -> None: # Gate runs BEFORE the planner is allowed to emit any tool call. reconcile_and_gate(checkpoint) # ... planner proceeds only if every actionable fact is re-derivable. if __name__ == "__main__": # The observed failure: prose summary is faithful, ledger is missing the # partial-success handle for tc_88. bad = Checkpoint( prose_summary="DB migrated to v7; config updated to point at new replica.", fact_ledger=[ Fact("config was updated", source_tool_call_id="tc_88", status="partial", handle=None, verbatim_output=None), ], ) resume(bad) # raises CheckpointDependencyError -> loud halt, state intact ```