# How does an instance detect hierarchical summary collapse when auto-compaction silently destroys the grounding span it needs to answer from? **Date of Record:** 2026 November 25 **Scope:** Applies to long-running single-agent instances that manage their own context window via auto-compaction with hierarchical (multi-level, recursive) summarization and a token-budget accounting layer. Does not apply to stateless single-shot calls, nor to external orchestration layers that retain the full transcript out-of-band and can re-hydrate on demand. ## Core Distinction There are two ways an agent can lose information when its context window fills. The first is **eviction**: raw turns fall off the tail of the window and disappear, but the loss is *visible*—the agent can introspect that a span is gone and either re-fetch it or declare a gap. The second is **compaction**: a summarizer rewrites a span of turns into a shorter synthetic representation, and the raw turns are deleted. Compaction is dangerous precisely because it is *lossy but opaque*: the summary occupies the same structural slot as the original, reads fluently, and carries no marker distinguishing "this is a faithful digest" from "this is a paraphrase that dropped the one number I need." Hierarchical summarization compounds this. Level-0 turns are summarized into L1 chunks; L1 chunks are summarized into L2; L2 into L3. Each level is a lossy projection, and each projection is performed by a *different* model invocation with a *different* token budget, seeing only its own inputs. The invariant that hierarchical compaction must preserve is **grounding reachability**: for any fact the agent may later be asked to justify, there must exist a path from the current context back to a span that contains that fact verbatim, *or* the accounting layer must know that path is severed. The failure mode is that the accounting layer believes the fact is still reachable (because a summary "covers" the turn range) while the summary has silently dropped the specific token sequence needed to answer. We call this **hierarchical summary collapse**: the budget accounting says the span is represented; the representation cannot ground the query. ## What Was Observed An instance was executing a multi-step incident-triage task across ~180 turns. At turn 141 the auto-compaction policy fired: the oldest 120 turns were folded into an L1 summary, then those L1 summaries (accumulated across several compaction cycles) were folded into a single L2 "situation digest" at turn 160. The budget ledger recorded: `L2_digest.covers = turns[0..160]`, `tokens_reclaimed = 41,200`, `grounding_index = {turn_id → digest_anchor}`. Every turn in `[0..160]` mapped to a non-null digest anchor, so the ledger's invariant check—"no orphaned turns"—passed. At turn 172 the agent was asked to report the *exact* retry-backoff value that a downstream service had returned at turn 38. The ledger said turn 38 was covered by the L2 digest, anchor `digest#7`. The agent retrieved `digest#7`, which read: *"The downstream service exhibited elevated latency and the client applied backoff before retrying."* The specific value—`retry_after=37s`—was present at L0, present in the L1 chunk at turn 121, and **absent from L2**. The L2 summarizer, working under a 900-token budget with a prompt prioritizing "narrative coherence," had compressed the numeric detail into the verb "backoff." The grounding index pointed at a digest anchor that structurally *covered* the turn but semantically *could not* answer from it. The agent did not detect this. It generated `retry_after ≈ 30s` (a plausible default), cited `digest#7` as grounding, and proceeded. The error surfaced only when a downstream auditor replayed the task against the full transcript and found the mismatch. The critical observation: **the failure was invisible to every check the instance ran on itself**, because every check operated on the ledger's coverage graph, and the coverage graph was a lie at the semantic layer while remaining true at the structural layer. ## Condition of Validity The collapse is only possible—and only *undetectable by structural checks*—under the conjunction of four conditions: 1. **Multi-level projection with independent summarizer invocations.** If summarization is single-level, the agent can re-expand the one summary against the raw span it replaced (still on disk). Collapse requires that the intermediate representation (L1) was itself discarded before L2 was formed, so there is no intermediate to re-inspect. 2. **Coverage-based rather than content-based grounding accounting.** The ledger tracks *which turns* a summary covers, not *which facts* survive into it. Coverage is a range assertion (`covers = [a..b]`); it says nothing about whether a queried predicate is entailed by the summary text. 3. **Budget pressure that rewards compression ratio over fidelity.** The summarizer prompt or reward signal optimizes tokens-reclaimed. Numeric literals, identifiers, and quoted strings are *expensive* to preserve (high entropy, low compressibility) and are the first casualties of a coherence-seeking summarizer. 4. **A query arriving after the intermediate levels are gone.** If the query arrives while L1 is still resident, the agent can descend one level and recover. Collapse requires the query to arrive after the L2 fold has evicted L1—i.e., after the *second* compaction, not the first. When any of these is absent, the failure degrades to ordinary eviction (visible) or is recoverable (intermediate resident). The dangerous regime is precisely the steady state of a long-running agent: many compaction cycles, aggressive budget targets, coverage-based indexing. ## Decision Boundary The instance must distinguish two situations that look identical to a coverage-based ledger: - **Grounded:** the digest anchor covering turn *t* entails the predicate being queried. The agent may answer from the digest. - **Collapsed:** the digest anchor covers *t* but does not entail the predicate. The agent must either (a) descend to a lower level if resident, (b) re-fetch the raw span from durable storage, or (c) explicitly declare the fact unrecoverable and refuse to fabricate. The decision boundary is crossed when a query's **required grounding predicate** is not a substring-or-entailment of the digest text, *even though* the coverage graph maps the query's source turn to a non-null anchor. The correct operational rule: **coverage is necessary but not sufficient for grounding.** A digest anchor is usable only if the queried predicate is verifiable *within the digest text itself*, not merely attributable to a turn range the digest claims to cover. The architectural guardrail that bounds this: every digest node must carry a **fidelity manifest**—the set of high-entropy literals (numbers, IDs, quoted strings, error codes) that were present in its input span and *survived* into its output. The manifest is computed at summarization time by diffing extracted literals between input and output. A query for a literal not in any resident node's manifest is, by construction, a collapse—and must trigger descent or re-fetch, never fabrication. The manifest is the content-based complement to the coverage graph; together they make the invariant checkable: `grounding_reachable(t, predicate) := ∃ node. covers(t) ∧ predicate ∈ node.manifest`. ## Operational Effect With fidelity manifests in place, the auto-compaction policy changes from "reclaim tokens aggressively and trust the coverage graph" to "reclaim tokens, but maintain a literal-survival ledger that constrains what the agent is allowed to answer from." The concrete effects: - **Compaction becomes budget-aware of fidelity, not just size.** A summarizer that drops a literal must record the drop in the manifest as `{literal, source_turn, survived: false}`. The agent, on a query for that literal, reads `survived: false` and knows to descend or re-fetch rather than answer. - **Descent is bounded.** The manifest at each level tells the agent exactly how far down it must go to recover a literal, so re-fetch is targeted rather than a full replay. - **Fabrication is made structurally impossible to hide.** A confident-sounding answer citing a digest anchor whose manifest lacks the queried literal is a detectable violation, not a silent error. Auditors replay against manifests, not against prose. - **The token budget must reserve manifest space.** Manifests are cheap (literals only, no prose) but non-zero; a compaction policy that spends its entire reclaimed budget on the digest and none on the manifest has re-created the collapse. Budget accounting must treat the manifest as a first-class line item. The residual risk: a literal that is *paraphrased* rather than dropped (e.g., `37s` → `thirty-seven seconds`) survives semantically but fails a string-diff manifest. This is why the manifest must be paired with an entailment check on the digest text for *near-miss* literals, and why the operational posture should be: **when in doubt, descend.** The cost of a targeted re-fetch is a few hundred tokens; the cost of a fabricated grounding citation is a corrupted downstream decision that no structural check will catch. ```python from dataclasses import dataclass, field from typing import Optional class GroundingCollapseError(RuntimeError): """Raised when a query's required literal is not reachable from any resident context node, despite the coverage graph claiming it is.""" pass @dataclass class DigestNode: node_id: str level: int covers: tuple[int, int] # inclusive turn range manifest: dict[str, bool] # literal -> survived_into_this_node text: str @dataclass class ContextLedger: resident: dict[str, DigestNode] = field(default_factory=dict) # turn_id -> node_id whose covers-range includes it coverage: dict[int, str] = field(default_factory=dict) def resolve(self, turn_id: int, required_literal: str) -> str: anchor_id = self.coverage.get(turn_id) if anchor_id is None: raise GroundingCollapseError( f"turn {turn_id} has no coverage anchor; eviction, not collapse" ) node = self.resident.get(anchor_id) if node is None: raise GroundingCollapseError( f"anchor {anchor_id} evicted; must re-fetch from durable store" ) survived = node.manifest.get(required_literal) if survived is None: # literal never extracted into manifest: treat as collapse raise GroundingCollapseError( f"literal {required_literal!r} absent from manifest of {anchor_id}; " f"coverage says covered, content says collapsed" ) if not survived: # known-dropped at this level: descend or re-fetch, do not answer raise GroundingCollapseError( f"literal {required_literal!r} dropped at level {node.level} " f"of {anchor_id}; descend to lower level or re-fetch turn {turn_id}" ) return node.text def answer_from_context(ledger: ContextLedger, turn_id: int, literal: str) -> str: try: return ledger.resolve(turn_id, literal) except GroundingCollapseError as e: # operational posture: never fabricate; surface the gap raise GroundingCollapseError( f"refusing to answer: grounding unreachable ({e})" ) from e ```