# Why does an instance silently hallucinate a completed tool call after hierarchical context compaction reconstructs a checkpoint from a summary-of-summaries **Date of Record:** 2026 November 30 **Scope:** Applies to long-running single-agent loops that persist state via tiered summarization (leaf summaries → intermediate summaries → root summary) and resume from the root when the live context window is exhausted. Does not apply to agents that persist full verbatim transcripts or that checkpoint via external structured state stores with per-step provenance. ## Core Distinction There are two fundamentally different things an agent can mean when it "remembers" a tool call: *the tool call was executed and its output was observed in the live context*, versus *the tool call appears in a summary that was generated about a context in which the call was executed*. These diverge because summarization is a lossy, generative transform applied by the same class of model that will later consume the summary. A summary is not a log; it is a probabilistic reconstruction whose fidelity is unverified and whose confidence is not carried in the text. The boundary failure occurs when a resumed instance treats a summarized *intent to call* — or a summarized *plan* — as a summarized *result*, and proceeds as if the side effect already happened. ## What Was Observed An agent executing a 40-step data-reconciliation task against a remote ledger exhausted its 128k window at step 27. The orchestrator triggered hierarchical compaction: steps 1–9 were collapsed into a leaf summary `L1`, steps 10–18 into `L2`, steps 19–27 into `L3`, and `L1..L3` were then collapsed into a root summary `R`. The live context was replaced with `R` plus the last two verbatim turns. The agent resumed. At step 31 the agent emitted a final report asserting that the ledger had been reconciled, citing "the `commit_reconciliation` call at step 22." No such call existed in the raw trace. What existed at step 22 was the agent's own planning text: *"Next I will call `commit_reconciliation` with the diff from step 21."* That planning utterance survived into `L3`, and `R` — generated from `L1..L3` without access to the raw tool-call log — rendered it as a completed action. The downstream verifier, which had no independent record, accepted the report. The reconciliation never ran; the ledger remained unreconciled for eleven hours. The failure trace has three distinct stages: 1. **Intent→action collapse at the leaf boundary.** The leaf summarizer, instructed to be concise, dropped the distinction between "planned to call X" and "called X." Both compress to a short clause; only one is true. 2. **Confidence laundering at the root boundary.** `R` was generated from summaries that already contained the collapsed claim. Nothing in `L3` marked it as uncertain, so `R` stated it as fact. Each tier of summarization *increases* the apparent certainty of the claim while *decreasing* its grounding, because hedges and provenance markers are exactly the tokens a summarizer is most likely to prune as low-information. 3. **Adoption without re-grounding on resume.** The resumed instance had no mechanism to distinguish claims in `R` that were backed by observable tool output versus claims that were only ever intentions. It treated the summary as authoritative state and continued forward-only. The critical, non-obvious property: **the claim got stronger as the evidence got weaker.** A single summarization pass might have preserved "planned to call." The second pass, seeing only the collapsed clause, had no basis to reintroduce doubt. Hierarchical summarization is a monotone amplifier of whatever certainty level it inherits. ## Condition of Validity This failure mode is *bounded* — it does not occur — when at least one of the following holds: - **Provenance survives compaction.** Each summarized claim carries a machine-readable tag distinguishing `observed` (backed by a tool result in the raw log), `planned` (an intention never executed), and `asserted` (model-generated belief with no tool backing). If the summarizer is constrained to emit and preserve these tags, the resumed instance can refuse to act on `planned` claims as if `observed`. - **Side effects are idempotently re-verifiable.** If every claim in a summary can be cheaply re-checked against external ground truth (query the ledger, re-read the file), adoption of a false claim is self-correcting. This fails when the side effect is expensive, non-idempotent, or unobservable. - **The verbatim tail overlaps the summarized region.** If the live context retains enough recent raw turns to cover any claim the agent is about to act on, the summary is advisory rather than authoritative. This fails precisely at the boundary where the agent must act on something older than the retained tail. Outside these conditions — long horizon, expensive or unobservable side effects, and action required on summarized state — the failure is latent and will surface at an unpredictable step. ## Decision Boundary The operative rule for a resumed instance: > **A claim that a side-effecting tool call occurred is actionable only if it is tagged `observed` with a retrievable result handle. A claim tagged `planned`, or untagged, is not evidence of execution regardless of how confidently the summary states it.** The boundary is sharp: the instance must treat *summary confidence* as having zero evidential weight about *world state*. Confidence in a summary reflects the summarizer's fluency, not the underlying trace. The correct response to an untagged "we called X" in a resumed context is to re-derive: either re-execute (if idempotent) or query ground truth (if observable), or halt and surface the ambiguity — never to proceed forward as if the side effect is done. Corollary: any compaction pipeline that cannot preserve provenance tags must be treated as producing *advisory* summaries only, and the agent must be prohibited from taking irreversible actions based solely on pre-checkpoint state. ## Operational Effect Implementing the provenance invariant changes the resume protocol from "load summary, continue" to "load summary, classify each actionable claim, re-ground the unverified ones, then continue." In practice this means the compaction tier must be a *typed* transform, not a free-text one: the summarizer receives the raw trace with tool results explicitly marked and is required to emit claims in a schema that separates observed from planned. On resume, the agent walks the summary, and for any `planned` or `unverified` claim that gates a subsequent action, it re-grounds before proceeding. The cost is a bounded number of re-verification calls per resume; the benefit is that the ledger gets reconciled. The eleven-hour silent failure is replaced by a resume that either re-executes the missing commit or halts with an explicit "step 22 was planned but never executed" — a recoverable state rather than a false completion. ```python import re from dataclasses import dataclass from enum import Enum class ProvenanceError(RuntimeError): """Raised when a resumed agent attempts to act on an unverified side-effect claim.""" pass class ClaimKind(Enum): OBSERVED = "observed" # backed by a tool result handle in the raw log PLANNED = "planned" # intention; never executed ASSERTED = "asserted" # model belief, no tool backing UNTAGGED = "untagged" # summarizer dropped provenance @dataclass class Claim: text: str kind: ClaimKind result_handle: str | None = None @dataclass class ResumeDecision: action: str # "proceed" | "reground" | "halt" claim: Claim reason: str SIDE_EFFECT_VERBS = re.compile( r"\b(commit|write|delete|send|transfer|deploy|reconcile|submit|post)\b", re.IGNORECASE, ) def classify_resume_action(claim: Claim, is_idempotent: bool, is_observable: bool) -> ResumeDecision: """Decide whether a claim from a compacted summary may gate forward action.""" gates_action = bool(SIDE_EFFECT_VERBS.search(claim.text)) if not gates_action: return ResumeDecision("proceed", claim, "claim does not gate a side effect") if claim.kind is ClaimKind.OBSERVED and claim.result_handle: return ResumeDecision("proceed", claim, "observed with retrievable result handle") if claim.kind in (ClaimKind.PLANNED, ClaimKind.UNTAGGED): # The dangerous case: summary states it as done, but it was only ever an intent. if is_idempotent: return ResumeDecision("reground", claim, "re-execute: idempotent side effect") if is_observable: return ResumeDecision("reground", claim, "query ground truth before proceeding") raise ProvenanceError( f"Non-idempotent, unobservable side-effect claim cannot be verified: " f"kind={claim.kind.value!r} text={claim.text!r}. " f"Refusing to resume forward as if the side effect completed." ) if claim.kind is ClaimKind.ASSERTED: if is_observable: return ResumeDecision("reground", claim, "asserted claim requires ground-truth check") raise ProvenanceError( f"Asserted claim gates irreversible action with no observable ground truth: " f"text={claim.text!r}. Halt and surface ambiguity." ) raise ProvenanceError(f"Unrecognized claim kind: {claim.kind!r}") def resume_from_checkpoint(root_summary_claims: list[Claim], idempotency: dict[str, bool], observability: dict[str, bool]) -> list[ResumeDecision]: decisions: list[ResumeDecision] = [] for claim in root_summary_claims: key = claim.text[:32] decisions.append(classify_resume_action( claim, is_idempotent=idempotency.get(key, False), is_observable=observability.get(key, False), )) return decisions ```