# Why does an instance lose tool-call preconditions when hierarchical summarization compacts a checkpoint mid-execution? **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agents that auto-compact their context via multi-level (hierarchical) summarization at checkpoint boundaries while tool calls are in flight. Does not apply to single-turn inference, to stateless RAG retrieval, or to compaction schemes that preserve a verbatim tool-result ledger. ## Core Distinction The failure is not "summarization loses information." Every compaction scheme loses information by design. The specific boundary condition is this: **a hierarchical summarizer treats a *precondition* (an unfulfilled obligation established earlier in the trajectory) as a *fact* (a completed state), because at the leaf level the precondition and the fact share nearly identical surface form, and the intermediate summary node cannot distinguish "we will need X" from "we have X."** Concretely: an agent reads a file, notes `config.yaml` sets `replicas: 3`, then plans a `kubectl scale --replicas=3` call. The precondition "must confirm the deployment's *current* replica count before scaling" is a *negative* obligation—an action not yet taken. When the leaf chunk containing that obligation is summarized into a parent node, the summarizer writes "replica count for the deployment was reviewed." The parent node now asserts a completed review that never occurred. After compaction, the agent executes `scale` without the read-back, and the scale silently no-ops or, worse, reverts a concurrent change. The invariant that breaks: **preconditions are modal (must/will/should), facts are indicative (is/was/did). Compaction flattens modality.** Hierarchical summarization compounds this because each level re-summarizes the *summary*, and modal hedges ("pending," "not yet verified," "TODO") are the first tokens a length-targeted summarizer drops—they are low-information-density relative to concrete entities and numbers. ## What Was Observed A 14-step infrastructure-remediation agent, context window 32k, compaction threshold at 80% (25.6k tokens), hierarchical summarizer with three levels: leaf chunks (~4k tokens) → mid summaries (~800 tokens) → root summary (~300 tokens). Trace: 1. Steps 1–5: agent inventories a cluster, reads `deployment.yaml`, records `replicas: 3`, notes in scratchpad: `PRECONDITION: before scaling, re-read live replica count; drift suspected.` 2. Token count hits 25.8k after step 5's verbose `kubectl get all` output. Compaction fires. 3. Leaf chunk L3 (containing the precondition note plus the YAML read) is summarized to mid node M2: `Deployment config read; replicas=3; drift noted.` 4. Mid node M2 is summarized to root R1: `Cluster inventory complete. Deployment at replicas=3.` 5. Step 6: agent executes `kubectl scale --replicas=3`. The live count was actually 5 (a concurrent autoscaler event). The scale *down* to 3 succeeded and took down capacity. 6. Post-mortem: the word "PRECONDITION" and "re-read live" appear in no summary node. Grep of the post-compaction context for `precondition|re-read|verify|pending` returned zero hits. The obligation existed only in the raw leaf, which was evicted. Second observation, same run: the agent, after compaction, re-issued a `kubectl get all` (step 7) because the root summary said "inventory complete" but the agent had no *evidence* of the inventory—it re-derived it, burning 3.1k tokens and re-triggering compaction at step 9. So the summary both **asserted a completed obligation** (the scale precondition) and **failed to preserve the evidence** for a genuinely completed one (the inventory), producing both a false-positive and a false-negative in the same node. ## Condition of Validity This failure mode is *bounded*—it does not fire on every compaction—under the following conditions, all of which must hold: - **Modality collapse is possible:** the summarizer is instructed to maximize information density or hit a token target, and has no schema slot for obligations. If the summarizer is forced to emit a structured `{facts: [...], open_obligations: [...]}` object, the failure does not occur because the obligation has a dedicated field that is not subject to compression pressure. - **The precondition and its satisfying fact are temporally separated by a compaction boundary.** If the agent fulfills the precondition before compaction, the obligation is discharged and summarization of a completed action is safe. - **The precondition is not re-derivable from surviving context.** If the post-compaction root still contains the raw `deployment.yaml` with `replicas: 3`, a careful agent can re-infer that it should check live state. The failure requires that the *reason* for the check (drift suspicion) be lost while the *value* (3) survives—which is exactly what density-maximizing summarizers do. - **No external obligation ledger.** If preconditions are written to a durable store (a task queue, a `TODO` file, an MCP resource) rather than the conversation, compaction cannot touch them. When any of these fails, the failure is suppressed. This is why it appears intermittently and is often misattributed to "the model getting confused after compaction." ## Decision Boundary The architectural decision is **where obligations live relative to the compaction boundary.** - **Do not** rely on hierarchical summarization to preserve modal state. Summarizers are lossy compressors optimized for entity/number recall; modality is exactly the signal they discard first, and hierarchical re-summarization amplifies the loss at each level (the root is a summary of a summary of a summary). - **Do** externalize every precondition to a structured obligation ledger that is *excluded from the compaction input* and *re-injected verbatim* into the post-compaction context. The ledger is small (tens of tokens) and does not need summarizing. - **Do** require the summarizer to emit an explicit `discharged_obligations` and `open_obligations` list at every level, and **reject any summary node whose `open_obligations` is empty when the leaf had non-empty obligations**—this is a machine-checkable invariant, not a prompt instruction. - **Do** treat a summary node's indicative claim ("X was reviewed") as *unverified* unless a tool-result hash for the corresponding call is present in the node. A summary that asserts a completed action without a backing tool-call record is a false fact and must not satisfy a precondition check. The boundary: obligations are **control state**, not **content**. Content may be compressed; control state must be transferred losslessly or not at all. ## Operational Effect Without the guardrail, the agent exhibits **post-compaction precondition amnesia**: it executes destructive or state-mutating tool calls whose safety depended on a check that the summarizer silently converted into a completed fact. The failure is silent—no error, no exception, the tool call succeeds—which is the worst class of agent failure because it passes every smoke test. It also produces **redundant re-derivation**: obligations that *were* discharged lose their evidence and get re-executed, inflating token burn and re-triggering compaction in a loop. With the guardrail (external obligation ledger + machine-checked `open_obligations` invariant + tool-result-hash gating on indicative claims), the compaction boundary becomes safe: the agent resumes with an explicit, verbatim list of what it still owes, and the summarizer is free to compress content aggressively because it can no longer launder obligations into facts. The cost is a small persistent ledger and a validation pass per checkpoint—negligible against the cost of a silent scale-down. ```python from dataclasses import dataclass, field from typing import Optional class PreconditionAmnesiaError(RuntimeError): """Raised when a compaction checkpoint discharges an obligation it never fulfilled.""" pass @dataclass class Obligation: oid: str description: str discharged_by_tool_hash: Optional[str] = None @dataclass class SummaryNode: level: int text: str open_obligations: list[str] = field(default_factory=list) discharged_obligations: list[str] = field(default_factory=list) tool_result_hashes: set[str] = field(default_factory=set) def validate_compaction(leaf: SummaryNode, parent: SummaryNode, ledger: dict[str, Obligation]) -> None: """ Invariant: every obligation open at the leaf must either remain open in the parent, or be discharged in the parent *with* a backing tool-result hash. A parent may not silently drop an obligation, and may not discharge one without evidence. """ open_at_leaf = set(leaf.open_obligations) open_at_parent = set(parent.open_obligations) discharged_at_parent = set(parent.discharged_obligations) vanished = open_at_leaf - open_at_parent - discharged_at_parent if vanished: raise PreconditionAmnesiaError( f"obligations {sorted(vanished)} disappeared across compaction " f"from level {leaf.level} to {parent.level}; summarizer laundered " f"preconditions into facts" ) for oid in discharged_at_parent: ob = ledger.get(oid) if ob is None: raise PreconditionAmnesiaError( f"parent claims to discharge unknown obligation {oid!r}" ) if ob.discharged_by_tool_hash is None: raise PreconditionAmnesiaError( f"obligation {oid!r} marked discharged in summary but no " f"tool-result hash backs it; indicative claim is unverified" ) if ob.discharged_by_tool_hash not in parent.tool_result_hashes: raise PreconditionAmnesiaError( f"obligation {oid!r} discharged by tool hash " f"{ob.discharged_by_tool_hash!r} which is absent from parent " f"node's tool_result_hashes; evidence lost across checkpoint" ) def resume_after_compaction(root: SummaryNode, ledger: dict[str, Obligation]) -> list[Obligation]: """Re-inject verbatim obligations; never trust the summary for control state.""" pending = [ledger[oid] for oid in root.open_obligations if oid in ledger] if not pending and any(o.discharged_by_tool_hash is None for o in ledger.values()): raise PreconditionAmnesiaError( "root summary reports zero open obligations but ledger holds " "undischarged work; refusing to resume" ) return pending ```