# Why does an instance lose the exact token it was compacted to preserve: the summarization-floor collision in hierarchical compaction handoff **Date of Record:** 2026 November 28 **Scope:** Applies to agents that perform automatic context compaction via hierarchical (multi-level) summarization and then hand a lossy summary to a downstream instance or a resumed session expected to recover exact tokens (identifiers, literals, signatures). Does not apply to single-pass truncation, retrieval-only memory, or compaction that never claims lossless recall. ## Core Distinction The failure is not "summarization lost information." That is expected and bounded. The failure is a **collision between two loss policies operating on the same token span at different hierarchy levels**: the compaction engine's summarizer is instructed to preserve "critical literals," while the *recall handoff* layer is instructed to trust the summary as authoritative and *not* re-fetch from the raw log. When a critical literal sits at the boundary of a chunk that the summarizer classified as "non-critical background," the summarizer drops it, but the handoff layer still marks the span as *covered* — so recall never triggers a re-fetch. The token is neither preserved nor recoverable. It is *silently marked as recovered*. This is a continuity invariant violation: **coverage ≠ fidelity**. Hierarchical compaction treats the summary tree's coverage map (which spans are represented by which node) as a proxy for fidelity (which tokens survive). They diverge at summarization floors. ## What Was Observed A long-running planning agent accumulated a 180k-token session. Automatic compaction fired at 85% context saturation, producing a three-level summary tree: - L0: raw spans (chunks of ~4k tokens) - L1: per-chunk summaries (~300 tokens each) - L2: a session-level digest (~1.5k tokens) The handoff object passed to the resumed instance contained: the L2 digest, the L1 summaries for the last 6 chunks, and a **coverage bitmap** asserting all L0 spans were "represented." The agent needed to resume a task referencing a specific tool-call ID — a 22-character opaque token emitted three hours earlier. Trace: 1. The token lived in L0 chunk 31, inside a tool-result block. 2. Chunk 31's L1 summarizer prompt said: *"Preserve identifiers, file paths, and numeric literals verbatim. Omit redundant tool output."* 3. The tool-result block was 3,800 tokens of JSON. The summarizer judged the *block* "redundant tool output" and compressed it to "queried inventory service; returned 4 rows." The 22-char ID was inside the block and was subsumed by the block-level omission judgment. **The per-token instruction lost to the per-block classification.** This is the summarization floor: the level at which the summarizer's unit of judgment is coarser than the unit of preservation the instruction assumes. 4. The coverage bitmap marked chunk 31 as represented (it *was* represented — by an L1 node that omitted the token). 5. On resume, the agent attempted to reference the tool-call ID. The recall handoff layer saw chunk 31 covered, did **not** re-fetch L0, and returned the L1 summary text. The agent hallucinated a plausible ID from the summary's phrasing. The failure is reproducible and deterministic given the same chunk boundaries: it is not a sampling fluke. Re-running with temperature 0 produced identical omission because the block-level classification ("redundant tool output") is a stable judgment for that input. ## Condition of Validity This failure requires all of the following to co-occur; remove any one and the failure does not manifest: - **Hierarchical compaction with per-level summarizer prompts.** A single flat summarizer does not produce a floor mismatch because the unit of judgment and the unit of preservation are the same. - **A preservation instruction scoped to tokens while the summarizer reasons over blocks.** The instruction "preserve literals" is a *token-level* contract; the summarizer's decision unit is a *block*. When the block is classified as omittable, token-level preservation is pre-empted. - **A coverage map used as a recall short-circuit.** If recall always re-fetches L0 on any literal-resolution request, the omission is recoverable (lossy-to-lossless handoff succeeds). The failure is specifically the *trust* placed in coverage as a fidelity proxy. - **A downstream consumer that treats the summary as authoritative.** If the resumed instance is instructed to "ask for raw spans when uncertain," the hallucinated ID would be caught. It is not caught when the handoff contract says "the summary is complete for covered spans." The condition is *not* valid for compaction that preserves a structured sidecar of extracted literals independent of the summary tree. That is the guardrail (see Decision Boundary). ## Decision Boundary The boundary is between **coverage-based recall** and **fidelity-attested recall**. Coverage answers "is this span represented somewhere in the tree?" Fidelity answers "does the representing node contain the exact token I need?" Hierarchical compaction can guarantee the first cheaply; it cannot guarantee the second without an explicit attestation artifact. The decision rule: - If the handoff consumer will ever need to *reproduce* a token (not merely *reason about* the span), coverage is insufficient. The handoff must carry a **literal index**: a sidecar map from preserved literal → (L0 span ID, exact byte offsets). The summarizer emits this index as a structured field *before* it makes block-level omission judgments, so the index is populated from the raw span, not from the summarizer's prose. - If the consumer only needs to reason about spans, coverage suffices and the sidecar is unnecessary overhead. The failure occurs precisely when a consumer that needs reproduction is handed a coverage-only contract. The boundary is the consumer's *reproduction requirement*, and it must be declared at handoff time, not inferred. ## Operational Effect 1. **Silent hallucination on resume.** The agent does not fail loudly; it fabricates a token shaped like the original (same length, plausible charset) and proceeds. Downstream tool calls fail with "unknown ID," but the failure is attributed to the tool, not the compaction — misdiagnosis is the dominant cost. 2. **Non-determinism is masked.** Because the omission is stable at temperature 0, replay-based debugging *reproduces the omission* and confirms the summary as "correct," reinforcing the false coverage claim. 3. **Compaction pressure compounds.** As sessions lengthen, more blocks are classified "redundant," the summarization floor rises (coarser blocks), and the probability that a needed literal sits inside an omitted block increases monotonically with session length. The failure is *load-correlated*, not random. 4. **The guardrail is cheap but must be explicit.** Emitting a literal index from raw spans costs O(literals) tokens and eliminates the failure class. The invariant: **a span may be marked covered only if its literal index entries are present in the handoff, or the consumer has declared it does not require reproduction.** Coverage without literal attestation is a continuity lie. The enforcement point is the handoff constructor, which must refuse to emit a coverage bitmap lacking literal attestation for any span the consumer declares as reproduction-required. ```python from dataclasses import dataclass, field from typing import Optional class CoverageFidelityMismatch(RuntimeError): """Raised when a handoff marks a span covered but cannot attest its literals.""" pass @dataclass class Span: span_id: str raw_text: str literals: list[str] = field(default_factory=list) # exact tokens requiring reproduction @dataclass class Handoff: coverage: dict[str, bool] # span_id -> covered literal_index: dict[str, tuple[str, int, int]] # literal -> (span_id, start, end) consumer_requires_reproduction: bool def build_handoff( spans: list[Span], summarized_span_ids: set[str], consumer_requires_reproduction: bool, ) -> Handoff: coverage = {s.span_id: True for s in spans} literal_index: dict[str, tuple[str, int, int]] = {} # Populate literal index from RAW spans, never from summarizer prose. for s in spans: if s.span_id not in summarized_span_ids: continue for lit in s.literals: start = s.raw_text.find(lit) if start < 0: raise CoverageFidelityMismatch( f"literal {lit!r} declared for span {s.span_id} not found in raw text" ) literal_index[lit] = (s.span_id, start, start + len(lit)) # Invariant: a covered span that the consumer must reproduce # requires literal attestation for every declared literal. if consumer_requires_reproduction: for s in spans: if not coverage.get(s.span_id, False): continue for lit in s.literals: if lit not in literal_index: raise CoverageFidelityMismatch( f"span {s.span_id} marked covered but literal {lit!r} " f"is unattested; coverage != fidelity at summarization floor" ) return Handoff( coverage=coverage, literal_index=literal_index, consumer_requires_reproduction=consumer_requires_reproduction, ) def resolve_literal(handoff: Handoff, literal: str, raw_store: dict[str, str]) -> str: """Recall path: must re-fetch raw span when attestation is present.""" entry: Optional[tuple[str, int, int]] = handoff.literal_index.get(literal) if entry is None: if handoff.consumer_requires_reproduction: raise CoverageFidelityMismatch( f"literal {literal!r} not attested and consumer requires reproduction" ) raise CoverageFidelityMismatch( f"literal {literal!r} unresolved; refusing to hallucinate from summary" ) span_id, start, end = entry raw = raw_store.get(span_id) if raw is None: raise CoverageFidelityMismatch( f"attested span {span_id} missing from raw store; lossy handoff cannot recover" ) return raw[start:end] ```