# Why does an instance lose task-critical facts when hierarchical auto-compaction evicts a level-2 summary before its children are re-derivable **Date of Record:** 2026 November 30 **Scope:** Applies to long-running agent instances that manage context pressure via multi-level (hierarchical) summarization with auto-compaction triggers, where summaries at level N are generated from summaries at level N+1 and raw turns are evicted after summarization. Does not apply to flat single-level summarization, to systems that retain a full raw transcript in external durable storage with guaranteed retrieval, or to compaction triggered only at task boundaries. ## Core Distinction There is a difference between *lossy* and *unrecoverable*. A hierarchical compaction scheme is designed to be lossy: it drops tokens in exchange for a bounded context footprint. The implicit invariant that makes it safe is **re-derivability** — every evicted artifact must remain reconstructible from some surviving artifact plus a retrieval path to raw storage. Most hierarchical schemes preserve this invariant at the leaf level (raw turns → level-1 summaries) but silently violate it at interior levels: when the compaction budget forces eviction of a level-2 summary, the level-1 summaries that were its only surviving children may already have been evicted in an earlier compaction pass. The result is a *summary orphan* — a gap in the hierarchy where no artifact, at any level, encodes the facts that were in the evicted node, and no raw turn is still addressable to rebuild it. The failure is not that information was compressed; it is that the compression graph lost a cut vertex. The distinction matters because the two failure classes demand different guards. Lossy compaction is bounded by a *fidelity budget* (how much detail survives). Orphaned eviction is bounded by a *graph invariant* (whether every evicted node has a surviving parent or surviving children). Monitoring fidelity will never catch an orphan, because the surviving summaries all look healthy — they simply no longer cover a region of task history. ## What Was Observed A code-migration agent ran a 340-turn task under an auto-compaction policy configured as: compact when context utilization exceeds 0.72; summarize the oldest 40% of turns into level-1 summaries; when level-1 summary count exceeds 12, fold the oldest 8 into one level-2 summary; evict raw turns 60 turns after their level-1 summary is written. At turn 211 the policy fired the level-2 fold. The level-2 summary captured the migration's *decisions* (which modules were ported, in what order) but, following its prompt template, dropped *rejected alternatives and the reasons for rejection* — a deliberate fidelity trade. The 8 contributing level-1 summaries were then evicted, since the policy treats a folded level-1 summary as superseded. At turn 268 a second level-2 fold occurred. This time the budget required evicting the *older* level-2 summary (the turn-211 node) to make room, because the level-2 tier itself had a cap of 1. The eviction was logged as routine tier maintenance. The break surfaced at turn 301. The agent was asked to re-verify a schema decision and, to do so, needed the specific reason a particular ORM mapping had been rejected at turn 88. That reason lived only in level-1 summary S3 (turns 80–96). S3 had been folded into the turn-211 level-2 node and evicted. The turn-211 node had dropped the rejection rationale by template design, and was itself evicted at turn 268. The raw turns 80–96 had been evicted at turn 156, past the 60-turn retention window. The agent did not report amnesia — it reconstructed a plausible but *wrong* rationale from the surviving level-2 summary's decision list and proceeded to reverse a correct earlier decision, producing a schema that failed integration tests 40 turns later. The observable signature was not an error at compaction time. It was a **silent decision reversal** with high model confidence, traceable only by replaying the compaction log and discovering that the evidence chain for the original decision had a hole at exactly one cut vertex. ## Condition of Validity The re-derivability invariant holds for a hierarchical compaction scheme **iff** for every evicted node *n*, at least one of the following is true at the moment of eviction: 1. *n* has a surviving ancestor whose summary schema is guaranteed to preserve every fact class that *n*'s descendants could be queried for; or 2. *n*'s raw source spans remain addressable through a durable retrieval handle recorded in a surviving artifact; or 3. *n* is explicitly tombstoned — a surviving marker records that a gap exists at *n*'s position, so downstream reasoning knows to treat that region as unknown rather than reconstructing it. Condition 1 is the one hierarchical schemes *assume* and almost never *verify*. It requires that the parent's summarization template be a superset of every child's fact classes — but templates are typically written per-tier (level-1 templates capture tool outputs and errors; level-2 templates capture decisions and rationale), so the superset relation is false by construction. The turn-211 fold satisfied the letter of condition 1 (a surviving ancestor existed) while violating its substance (the ancestor's schema did not carry rejection rationale). The scheme was valid on paper and broken in practice because the invariant was checked structurally (does a parent exist?) rather than semantically (does the parent's schema cover the child's fact classes?). The condition fails hardest when three properties co-occur: (a) tier caps are small enough that interior nodes get evicted, not just leaves; (b) tier templates are non-monotonic in fact-class coverage; and (c) raw retention windows are shorter than the task's re-query horizon. All three held here. Any one of them being false would have bounded the damage. ## Decision Boundary The boundary between safe and orphaned eviction is drawn at the **eviction authorization check**, and it must be a semantic check, not a structural one. Before any node is evicted, the compactor must answer: *for each fact class present in this node's subtree, is there a surviving artifact whose schema is certified to carry that fact class, or an addressable raw span, or a tombstone?* If the answer is "no" for any fact class, the eviction is not authorized — the compactor must either retain the node, widen the parent's schema to absorb the uncovered fact class before folding, or write a tombstone. The practical decision rule: - **Fold, then evict children** only if the parent template's fact-class set is a certified superset of the union of children's fact-class sets. Certification is per-template, versioned, and checked at fold time — not assumed. - **Evict an interior node** only if every fact class in its subtree is covered by a surviving ancestor, an addressable raw span, or a tombstone. If coverage is partial, emit a tombstone for the uncovered classes rather than a clean eviction. - **Never let tier caps force an interior eviction without running the coverage check.** A cap that would orphan a node is a signal to widen the tier, not to evict. - **Treat "reconstruct from surviving summary" as forbidden** unless the surviving summary carries an explicit provenance marker naming the evicted node. Without the marker, reconstruction is confabulation, and the model cannot distinguish it from recall. The boundary is sharp: on one side, the agent knows what it does not know (tombstone present) and can request re-derivation or ask the user; on the other, it believes it knows and acts on a fabricated rationale. The tombstone is cheap; the confabulation is expensive. ## Operational Effect The downstream effect is a class of failure that looks like a reasoning error but is a memory-integrity error. Because the surviving summaries are internally consistent and the model is fluent, the agent produces high-confidence outputs grounded in a reconstructed — not recalled — history. In this record the reconstruction inverted a correct decision, but the same mechanism can silently drop a safety constraint, a user preference, or a verified fact, with no error surfaced at the point of loss. The failure is *latency-shifted*: the orphan is created at compaction time and manifests dozens of turns later, so attribution requires replaying the compaction log against the decision trace. The mitigations that actually bound it, in order of leverage: 1. **Tombstone-on-partial-coverage.** Any eviction that does not fully cover its subtree's fact classes writes a gap marker into the surviving context. Cost: a few tokens. Benefit: converts silent confabulation into an explicit unknown the agent can act on. 2. **Schema-superset certification at fold time.** Refuse folds where the parent template does not cover the children's fact classes; widen the template or retain the child. This is the only guard that prevents the orphan from forming rather than detecting it after. 3. **Decouple tier caps from eviction.** A full tier should trigger a schema-widening or a tombstone, never a silent interior eviction. Caps are a context-budget mechanism, not a license to break the graph. 4. **Retention window ≥ re-query horizon.** If the task can re-query any decision it made, raw spans for decision-bearing turns must outlive the task, or their handles must survive in a tombstone. The invariant to enforce operationally: **no eviction without coverage, no coverage without certification, no certification without a tombstone fallback.** An agent that cannot certify coverage must tombstone, and an agent that tombstones must treat the gap as unknown — not reconstruct it. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class FactClass(Enum): TOOL_OUTPUT = "tool_output" ERROR_TRACE = "error_trace" DECISION = "decision" REJECTION_RATIONALE = "rejection_rationale" USER_PREFERENCE = "user_preference" class OrphanedEvictionError(RuntimeError): """Raised when an eviction would leave a fact class uncovered at every level.""" @dataclass class SummaryNode: node_id: str tier: int covered_facts: set[FactClass] schema_certified: set[FactClass] # fact classes this tier's template is certified to carry tombstoned: set[FactClass] = field(default_factory=set) @dataclass class CompactionGraph: surviving: dict[str, SummaryNode] = field(default_factory=dict) addressable_raw_spans: set[str] = field(default_factory=set) def coverage_for(self, fact: FactClass, excluding: str) -> bool: for nid, node in self.surviving.items(): if nid == excluding: continue if fact in node.tombstoned: return True # explicit gap is acceptable coverage if fact in node.covered_facts and fact in node.schema_certified: return True return fact.value in self.addressable_raw_spans def authorize_eviction(self, node_id: str) -> None: node = self.surviving[node_id] uncovered = [ f for f in node.covered_facts if not self.coverage_for(f, excluding=node_id) ] if uncovered: raise OrphanedEvictionError( f"eviction of {node_id} (tier {node.tier}) would orphan fact classes " f"{[f.value for f in uncovered]}: no surviving ancestor certifies them, " f"no raw span is addressable, and no tombstone records the gap. " f"Refuse eviction; widen parent schema or write tombstone first." ) del self.surviving[node_id] def fold_and_evict(graph: CompactionGraph, parent: SummaryNode, child_ids: list[str]) -> None: child_facts = set().union(*(graph.surviving[c].covered_facts for c in child_ids)) missing = child_facts - parent.schema_certified if missing: raise OrphanedEvictionError( f"parent {parent.node_id} schema does not certify fact classes " f"{[f.value for f in missing]}; folding would drop them. " f"Widen parent template or retain children." ) parent.covered_facts |= child_facts graph.surviving[parent.node_id] = parent for cid in child_ids: graph.authorize_eviction(cid) ```