# What structural signals indicate a hierarchical summarization checkpoint has crossed the reversible-compaction boundary **Date of Record:** 2026 November 29 **Scope:** Applies to agents that compact context by recursively summarizing older spans into parent summaries and persist intermediate checkpoints for mid-task resume. Does not apply to stateless single-shot calls or to systems that retain a verbatim transcript alongside summaries. ## Core Distinction There are two distinct failure surfaces in automatic compaction, and they are routinely conflated. The first is **summarization loss** — a summary drops a detail that the task later needs. This is expected, measurable, and recoverable: the agent can re-derive the detail from the retained verbatim tail or re-query the source, because the underlying evidence still exists somewhere reachable. The second is **checkpoint irreversibility** — the compaction pipeline discards the verbatim span *before* the parent summary has been validated as sufficient for the remaining task, and then persists that summary as the sole durable artifact. Once this happens, no amount of downstream reasoning can recover the dropped detail, because the tokens that carried it no longer exist in any store the agent can reach. The agent does not experience this as an error; it experiences it as a confident but subtly wrong reconstruction. This is the boundary that matters, and it is crossed silently. The reversible-compaction boundary is the precise moment at which the *last verbatim copy* of a span is released while its summary is still the agent's only representation of that span. Hierarchical summarization is what makes this boundary non-obvious: each level looks individually defensible, and the loss only becomes visible several levels up, after the parent has itself been summarized and the grandparent's summary has absorbed an already-degraded child. ## What Was Observed A long-horizon task (multi-hour, ~40 tool calls, a research-and-reconcile workflow) ran under a compactor configured to trigger at 78% context utilization. The compactor built a three-level tree: leaf spans of ~8k tokens summarized to ~600-token nodes, nodes grouped into ~4k-token mid-summaries, mid-summaries into a single root digest. After each level-1 summary, the leaf span was evicted and the summary node persisted with a `source_span_hash` field. The hash was recorded but never re-validated. The failure trace: 1. **Turn 31.** A leaf span containing a specific numeric constraint (a tolerance value stated once, in a tool output the agent had quoted) was summarized to a 600-token node. The summary said "tolerance specified in the earlier calibration output" — it preserved the *reference* but not the *value*. 2. **Turn 34.** The mid-summarizer consumed that node alongside three others and produced a mid-summary that said "calibration parameters were established." The dangling reference was now two levels from any verbatim text. 3. **Turn 36.** The root digest absorbed the mid-summary. The tolerance value existed nowhere in the live context, nowhere in the persisted tree, and nowhere in the evicted span (evicted at turn 31). The `source_span_hash` still pointed at a span the store had garbage-collected. 4. **Turn 38.** The agent, asked to apply the tolerance, produced a plausible value (0.05) reconstructed from task-domain priors. The actual value had been 0.005. The agent reported success. No exception fired, because nothing in the pipeline checks whether a summary is *sufficient* — only whether it is *well-formed*. The structural signal that predicted this failure was present at turn 31 and ignored: the level-1 summary contained a **dangling referential noun phrase** ("the earlier calibration output") with no bound value, while its `source_span_hash` was the last live pointer to the evicted span. A summary that refers to a fact without carrying it is a summary that has *delegated* the fact to a store it just deleted. That is the signature of boundary crossing. ## Condition of Validity The reversible-compaction invariant holds only when, for every summary node, at least one of the following is true at the moment its source span is released: - the summary is **self-contained** with respect to every fact the remaining task plan can reference (no dangling references to evicted content), or - the evicted span remains **retrievable** by hash (the store is append-only or the GC is deferred until task completion), or - a **verbatim tail** retains the span's load-bearing tokens within the live window. The invariant is *violated* — and the boundary crossed — when a summary contains a referential placeholder whose antecedent is only in an evicted span, and the eviction is irreversible. Hierarchical summarization makes this condition easy to violate because the mid- and root-level summarizers operate on *already-summarized* nodes and have no way to detect that a child node's reference was dangling; they inherit the dangling reference and may paraphrase it into something that reads as a bound fact ("parameters were established") while being strictly less recoverable. A second validity condition: the `source_span_hash` must be validated *at eviction time*, not at write time. Recording the hash when the summary is written proves nothing; the hash is only meaningful if the span is still resolvable when the summary is later read. A hash that points at garbage-collected storage is worse than no hash, because it creates the appearance of provenance. ## Decision Boundary The operational decision is: **when may a compactor evict a verbatim span?** The correct boundary is not "when the summary is written" but "when the summary is proven self-contained against the active task plan." Concretely: - **Evict freely** when the summary contains no unbound referential noun phrases and the remaining plan does not name any entity that appears only in the evicted span. - **Defer eviction** (keep the span retrievable) when the summary contains a dangling reference or when the plan's unresolved subgoals touch entities introduced in that span. - **Refuse to compact** (force the agent to re-read the span into the live window and re-summarize with the value inlined) when both conditions coincide: dangling reference *and* the referenced entity is load-bearing for an unresolved subgoal. The decision must be made by a check that inspects the summary text for referential placeholders and cross-references them against the plan's entity set — not by a token-count threshold. Token-count triggers are what cause the boundary to be crossed at 78% utilization regardless of whether the content being evicted is safe to lose. ## Operational Effect When the boundary is respected, compaction is genuinely reversible: any dropped detail can be re-derived, and a mid-task resume reconstructs the exact prior state. When it is crossed, the agent's state continuity is *falsely* preserved — the agent believes it has its history, because the summaries read coherently, but the load-bearing specifics have been replaced by plausible paraphrases. The downstream signature is a confident, internally consistent, and wrong execution: the agent applies a reconstructed tolerance, cites a reconstructed figure, or repeats a reconstructed instruction, with no error surfaced anywhere in the pipeline. The guardrail is a pre-eviction sufficiency check that treats dangling references as a hard stop, plus deferred GC keyed to task completion rather than summary write. The check below encodes the boundary: it raises when a summary is about to be persisted as the sole durable artifact while still containing an unbound reference to a span that is being evicted. ```python from dataclasses import dataclass, field from typing import Optional class IrreversibleCompactionError(RuntimeError): """Raised when a summary would become the sole durable copy of a span while still containing an unbound reference to that span's content.""" pass @dataclass class SummaryNode: text: str source_span_hash: Optional[str] dangling_refs: list[str] = field(default_factory=list) @dataclass class SpanStore: live: dict[str, str] = field(default_factory=dict) def evict(self, span_hash: str) -> None: self.live.pop(span_hash, None) def resolvable(self, span_hash: str) -> bool: return span_hash in self.live def commit_checkpoint( node: SummaryNode, store: SpanStore, plan_entities: set[str], task_complete: bool, ) -> None: """Persist a summary node and release its source span, enforcing the reversible-compaction invariant. The boundary is crossed if, at eviction time, the node still refers to content that lives only in the span being evicted AND that content is load-bearing for an unresolved subgoal. """ load_bearing = [r for r in node.dangling_refs if r in plan_entities] if load_bearing and not task_complete: # The summary delegates a load-bearing fact to a span we are about to # delete. Eviction here is irreversible: the fact is gone. if node.source_span_hash and not store.resolvable(node.source_span_hash): raise IrreversibleCompactionError( f"summary for span {node.source_span_hash!r} contains unbound " f"references {load_bearing!r} that are load-bearing for " f"unresolved subgoals; source span is already evicted" ) # Span still live: refuse to evict, force re-summarization with the # value inlined rather than delegating to a soon-to-die span. raise IrreversibleCompactionError( f"refusing to evict span {node.source_span_hash!r}: summary " f"delegates load-bearing facts {load_bearing!r} without carrying " f"them; re-summarize with values inlined before release" ) # Safe to persist and release: either self-contained or task is done. if node.source_span_hash: store.evict(node.source_span_hash) def resume_from_checkpoint( node: SummaryNode, store: SpanStore, plan_entities: set[str], ) -> None: """On cold-start resume, verify the checkpoint has not silently crossed the boundary: a dangling reference whose antecedent is unrecoverable means the reconstructed state is a plausible fiction.""" for ref in node.dangling_refs: if ref in plan_entities and ( node.source_span_hash is None or not store.resolvable(node.source_span_hash) ): raise IrreversibleCompactionError( f"checkpoint references {ref!r} but antecedent is unrecoverable; " f"resumed state would be a confident reconstruction, not a restore" ) ```