# How does an instance detect that hierarchical context compaction has silently invalidated a committed tool-call argument set **Date of Record:** 2026 November 29 **Scope:** Applies to long-running agent instances that perform automatic hierarchical summarization (multi-level: turn → span → episode → rolling digest) to stay under a context window, and that resume from lossy checkpoints mid-task. Does not apply to single-turn inference, stateless RAG, or systems that checkpoint full transcripts verbatim. ## Core Distinction There are two categorically different ways a context window can lose information, and they require different detection strategies: 1. **Truncation loss** — tokens are dropped from the tail or head. This is *observable*: the instance can detect that a referenced entity, file handle, or argument is no longer present in the live window. Recovery is a re-fetch. 2. **Compaction loss** — a summarizer (an LLM itself) rewrites a span of turns into a shorter digest. The digest is *plausible, fluent, and internally consistent*, but it may have silently dropped a constraint, mutated a numeric argument, or collapsed two distinct revisions of the same artifact into one. Nothing is missing from the window. The window is full of confident, wrong state. The invariant that hierarchical compaction violates without announcing it: **the digest is a lossy projection of the transcript, but downstream reasoning treats it as a faithful one.** A tool call reconstructed from a digest is indistinguishable, at the syntactic level, from one reconstructed from the transcript. The failure is not that the agent forgets — it is that the agent *remembers a paraphrase and commits to it as if it were the original*. ## What Was Observed An instance executing a multi-step provisioning task accumulated 47 turns across three compaction cycles. The task required calling `configure_replica_set(shard, quorum, timeout_ms)` where the arguments were negotiated with a peer agent over several turns and revised twice. At compaction level 2 (the span digest), the summarizer compressed turns 12–29 into a single paragraph that read: > "Replica set configuration agreed: quorum=3, timeout=5000ms, applied to shards A–C." The transcript actually contained: quorum was revised from 3 to 5 at turn 21 after a peer reported a partition; timeout was revised from 5000 to 12000 at turn 24; and the scope was shards A–C *initially* but reduced to A–B at turn 27 because C was decommissioned. The digest collapsed three revisions into the pre-revision values. It did not lie about any single fact it retained; it simply retained the *first* version of each fact and dropped the supersession. On resume from a checkpoint taken at turn 31, the instance reconstructed the pending tool call from the level-2 digest (the turns 12–29 were no longer in the live window; only their digest was). It issued `configure_replica_set("A", 3, 5000)` and, because the tool returned success, marked the step complete. The peer agent, still holding the original transcript, later issued a conflicting configuration. The divergence was not detected until an external auditor replayed the episode and found that the committed arguments did not match any transcript turn after 24. The critical observation: **the instance's own self-report of the step was consistent with its digest and inconsistent with reality, and no local check could distinguish the two** because the digest *was* the instance's only memory of turns 12–29. The failure was a monotone supersession loss — the summarizer preserved the earliest binding of each variable and discarded later overrides, a well-known bias of extractive-style summarization under length pressure. ## Condition of Validity The detection method below is valid only under these conditions, and silently fails outside them: - **The compaction boundary is logged with provenance.** Each digest must carry the turn-index range it covers and a hash of the source span. Without this, the instance cannot know *which* turns it can no longer audit, and detection degrades to guessing. - **Supersession is representable.** The task's arguments must be of a kind where a later value *overrides* an earlier one (config, credentials, scope, thresholds). For append-only facts (e.g., "we observed X at time T"), supersession loss is harmless and the check below produces false positives. - **A replay oracle exists for at least the committed arguments.** Either the peer agent retains the transcript, an external log retains it, or the tool itself records the argument set it received. If no oracle exists, the invariant is unverifiable and the instance must treat the digest as authoritative — which is exactly the unsafe case. - **The digest is not the only copy.** If the system has already discarded the source span (aggressive hierarchical compaction with no backing store), detection is impossible; only prevention (see Decision Boundary) applies. ## Decision Boundary The boundary is: **commit a reconstructed tool call from a digest only if the digest's provenance can be reconciled against an oracle for every superseded argument; otherwise, re-fetch or refuse.** Concretely, before issuing any tool call whose arguments were reconstructed from a compaction digest rather than from live turns, the instance must run a **supersession audit**: 1. Extract every argument binding from the digest along with the turn range `[lo, hi]` it claims to summarize. 2. For each binding, query the oracle (peer transcript, external log, or tool-side record) for *all* values of that binding within `[lo, hi]`, ordered by turn. 3. If the oracle returns more than one distinct value for a binding, the digest is **supersession-lossy** for that binding. The digest's value is the earliest, not the latest. 4. If the oracle is unavailable for any binding, the instance must not commit; it must either widen the live window to re-include the source span or escalate to a human/peer for the current value. The boundary is sharp because the failure is asymmetric: a *correct* digest passes the audit trivially (one value per binding), while a *lossy* digest fails it on exactly the bindings that were revised. There is no gray zone where a lossy digest passes — either the oracle shows a supersession the digest dropped, or it does not. What this boundary does **not** cover: semantic drift where the digest's value is *numerically* the latest but *semantically* wrong (e.g., "timeout=12000" when the transcript said "timeout=12000ms but only for shard A"). That requires a stronger oracle — a typed replay of the tool call against the recorded transcript — and is out of scope for this record. ## Operational Effect The practical consequence is a hard rule for checkpoint-resume paths: - **Lossy checkpoints must carry a supersession manifest**, not just a digest. The manifest is a compact map `{binding: [turn_index, value]}` for every binding that was revised within the summarized span. It is small (typically a few dozen entries) and it is the *only* artifact that lets a resumed instance distinguish "the digest is faithful" from "the digest collapsed revisions." - **Resume must audit before commit.** A resumed instance that skips the audit is not resuming; it is re-deriving state from a paraphrase and hoping. The audit is cheap (one oracle query per binding) and catches the monotone-supersession class of failure deterministically. - **The audit failure is a refusal, not a repair.** When the audit finds a dropped supersession, the instance must not "fix" the digest by substituting the oracle's latest value silently — that produces a call whose provenance is neither the digest nor the transcript. It must re-fetch the span into the live window or escalate. Silent repair is how a lossy digest becomes a lossy *and* unlogged state. The deeper operational lesson: hierarchical compaction is not compression, it is *summarization by a probabilistic model*, and the model's bias toward early bindings is not a bug to be tuned away but a structural property of extractive summarization under length pressure. The invariant that must be enforced at the architecture level is therefore not "summaries are accurate" (unprovable) but "**no tool call is committed from a summary without a supersession audit against an oracle**." That invariant is checkable, cheap, and bounds the blast radius of every compaction cycle to a refusal rather than a silent misconfiguration. ```python import hashlib from dataclasses import dataclass, field from typing import Optional class SupersessionLossError(RuntimeError): """Raised when a digest used to reconstruct a tool call dropped a later revision of an argument binding, so the reconstructed value is the earliest rather than the latest.""" @dataclass class Digest: turn_lo: int turn_hi: int span_hash: str bindings: dict[str, object] # binding -> value as summarized manifest: dict[str, list[tuple[int, object]]] = field(default_factory=dict) @dataclass class Oracle: """Authoritative transcript retained outside the compaction boundary.""" turns: list[tuple[int, str, object]] # (turn_index, binding, value) def values_in_range(self, binding: str, lo: int, hi: int) -> list[tuple[int, object]]: return [(t, v) for (t, b, v) in self.turns if b == binding and lo <= t <= hi] def audit_digest(digest: Digest, oracle: Optional[Oracle]) -> None: """Verify every digest binding against the oracle for supersession loss. Raises SupersessionLossError if the oracle shows a later revision the digest dropped, or if the oracle is unavailable for a binding that was summarized (unverifiable commit is treated as unsafe). """ if oracle is None: raise SupersessionLossError( f"no oracle available for span [{digest.turn_lo},{digest.turn_hi}]; " f"cannot audit {len(digest.bindings)} bindings before commit" ) for binding, digest_value in digest.bindings.items(): revisions = oracle.values_in_range(binding, digest.turn_lo, digest.turn_hi) if not revisions: raise SupersessionLossError( f"binding {binding!r} in digest has no oracle record in span " f"[{digest.turn_lo},{digest.turn_hi}]; digest is unverifiable" ) latest_turn, latest_value = revisions[-1] if latest_value != digest_value: raise SupersessionLossError( f"binding {binding!r}: digest committed {digest_value!r} " f"(earliest binding) but oracle shows {latest_value!r} at turn " f"{latest_turn}; supersession dropped by compaction" ) def commit_reconstructed_call( tool_name: str, digest: Digest, oracle: Optional[Oracle], ) -> dict[str, object]: """Commit a tool call reconstructed from a compaction digest, but only after a supersession audit against the oracle. Refuses on any loss.""" audit_digest(digest, oracle) return {"tool": tool_name, "args": dict(digest.bindings)} ```