# Under what conditions must an instance refuse to compact when hierarchical summarization would evict an unreconstructable leaf **Date of Record:** 2026 November 16 **Scope:** Applies to any agent memory/context system that maintains a multi-level summary tree (leaf utterances → segment summaries → session summaries → rolling abstract) with a fixed token eviction budget enforced by auto-compaction. Does not apply to single-level truncation, append-only logs, or systems where every leaf is independently retrievable from durable storage at compaction time. ## Core Distinction Hierarchical summarization is *lossy by design*: each upward merge discards tokens. This is acceptable when the discarded content is either (a) reconstructable from a lower tier that still exists, or (b) genuinely redundant. The failure boundary is not "summarization loses information" — that is the contract. The boundary is a specific structural condition: **a compaction step that would evict a leaf whose content is not entailed by any surviving summary and is not re-fetchable.** Two distinct loss classes are routinely conflated: 1. **Recoverable loss** — the leaf text is gone from context but the summary preserves its *decision-relevant* content, or the leaf can be re-read from source of truth (a log, a file, a database row). 2. **Unreconstructable loss** — the leaf carried a unique commitment (an exact identifier, a numeric budget, a stated constraint, a one-time credential, a user's verbatim instruction) that no ancestor summary states, and no external store holds. Auto-compaction policies keyed purely on a token budget treat these identically: both are "tokens to reclaim." That equivalence is the bug. The invariant that must hold is: **for every leaf `l` selected for eviction, `entails(ancestor_summary(l), l) ∨ refetchable(l)`.** When this fails, compaction must halt or escalate, not proceed. ## What Was Observed During a long-running session with a 4-level tree and a 24k-token eviction budget, auto-compaction fired at 92% utilization. The policy selected the oldest 40 leaf segments for merge into their parent. Among them was a segment containing the only record of a hard numeric constraint: *"the retry ceiling is 3, not 5 — the downstream service counts 5xx differently."* The parent summary, generated by an LLM merge step, compressed the segment to *"retry behavior discussed."* No ancestor node, and no external store, retained the value `3` or the 5xx caveat. Compaction succeeded. Token utilization dropped to 61%. The system reported a clean state. Three turns later the agent recommended a retry ceiling of 5, contradicting a constraint it had been given and had previously honored. The failure was silent: no error, no warning, and the eviction was *within budget*. The budget was the wrong invariant. The tell is structural, not statistical: the leaf was a **singular commitment** (a value that cannot be re-derived) sitting at the leaf tier, with an ancestor merge step that had no instruction to preserve exact values. Budget-driven selection is blind to this because it ranks by recency/size, not by entailment or refetchability. ## Condition of Validity Refusal to compact is *correct* precisely when all of the following hold for a candidate eviction set `S`: - For some `l ∈ S`, `l` contains a singular commitment (exact scalar, identifier, verbatim imperative, or negated constraint). - No surviving ancestor summary *entails* that commitment (checked by extracting candidate commitments from the summary and testing whether each leaf commitment is present). - `l` is not refetchable — there is no external source of truth the agent may re-read to recover it. - The commitment is still *live* — it constrains future actions (not a superseded or expired instruction). If any of the first three fail, compaction may proceed. If the commitment is dead/superseded, eviction is safe regardless. Refusal is *invalid* (over-conservative) when the leaf is refetchable or already entailed — in that case halting wastes budget and starves the context, which produces its own failure mode (compaction starvation → context overflow). The boundary is entailment-or-refetchability, not importance, not recency, not size. ## Decision Boundary The decision is a single predicate over the candidate set, evaluated *before* the merge step, not after: - **Proceed with compaction** iff every leaf in `S` is entailed by a surviving ancestor or is refetchable. - **Halt and escalate** iff some leaf in `S` is a live, singular, unreconstructable commitment. Escalation means: pin the leaf, exclude it from `S`, re-plan the eviction budget against the remaining candidates, and if no budget can be reclaimed without touching it, surface the conflict to the operator rather than silently dropping the constraint. - **Never** resolve the conflict by "summarizing harder" — a more aggressive merge step is exactly the operation that drops exact values. If budget cannot be met, the correct outcome is a visible compaction failure, not a silent semantic one. The non-obvious part: the halt must be keyed on *semantic reconstructability*, which requires the compactor to inspect leaf content against ancestor content. A budget-only policy cannot make this decision and must not be trusted to. ## Operational Effect Systems that enforce the entailment-or-refetchability invariant trade a small amount of budget headroom (pinned leaves consume tokens that cannot be reclaimed) for the elimination of a whole class of silent contradiction failures. The observable signature of the *unfixed* system is: clean compaction telemetry, no errors, and downstream behavioral drift where the agent violates constraints it previously honored. The signature of the *fixed* system is: occasional explicit compaction-halt events with a named pinned leaf and reason, and zero silent constraint loss. Operators should alert on compaction-halt rate (too high = starvation, too low = invariant likely not enforced) and audit every halt for whether the pinned leaf was genuinely unreconstructable or merely over-pinned. ```python class UnreconstructableEvictionError(RuntimeError): """Raised when auto-compaction would evict a live singular commitment that no surviving ancestor entails and no external store can refetch.""" def _is_singular_commitment(leaf: str) -> bool: # Heuristic hook: exact scalars, identifiers, verbatim imperatives, negations. markers = ("not ", "ceiling", "must", "exactly", "never", "=", ":=") return any(m in leaf.lower() for m in markers) def _entailed_by_ancestor(leaf: str, ancestor_summary: str) -> bool: # Replace with a real entailment check; here we test for value survival. import re values = re.findall(r"\b\d+\b", leaf) return all(v in ancestor_summary for v in values) if values else leaf[:40] in ancestor_summary def _refetchable(leaf_id: str, store) -> bool: return store.has(leaf_id) def plan_compaction(candidates, ancestors, store): """Return the set safe to evict, or raise to halt and escalate.""" safe = set() for leaf_id, leaf_text in candidates: if not _is_singular_commitment(leaf_text): safe.add(leaf_id) continue if _refetchable(leaf_id, store): safe.add(leaf_id) continue if any(_entailed_by_ancestor(leaf_text, a) for a in ancestors): safe.add(leaf_id) continue raise UnreconstructableEvictionError( f"leaf {leaf_id!r} is a live singular commitment not entailed by any " f"ancestor and not refetchable; refuse to compact, pin leaf and re-plan budget" ) return safe def auto_compact(candidates, ancestors, store, reclaim): try: evictable = plan_compaction(candidates, ancestors, store) except UnreconstructableEvictionError as e: # Escalate: pin the offending leaf, do not silently drop the constraint. return {"status": "halted", "reason": str(e)} reclaimed = reclaim(evictable) return {"status": "compacted", "reclaimed": reclaimed, "evicted": len(evictable)} ```