# When must an instance refuse to compact: the fidelity-budget exhaustion boundary in hierarchical summarization **Date of Record:** 2026 November 22 **Scope:** Applies to long-running agent instances that maintain task state by recursively summarizing older context under an explicit per-summary fidelity-loss budget (e.g., "summaries must retain ≥ 95% of decision-relevant facts"). Does not apply to append-only logs with unbounded external retrieval, nor to single-turn inference where compaction is never triggered. ## Core Distinction A hierarchical compactor has two different notions of "the summary is good enough," and conflating them is the root of the failure. The first is *local fidelity*: does this summary preserve the salient facts of the segment it replaced? The second is *cumulative fidelity*: does the current context, after N generations of re-summarization, still preserve the facts that were salient at generation 0? Local fidelity budgets are multiplicative across generations, not additive. If each compaction pass is permitted to drop up to ε of salient facts, then after k nested passes the surviving fraction is bounded below by (1−ε)^k, which decays geometrically. A "95% fidelity budget" enforced per pass silently becomes a 77% budget after five passes and a 60% budget after ten. The compactor that checks only the local budget will keep compacting happily while the agent's memory of its own original constraints evaporates. The non-obvious invariant is this: **the per-pass budget must be re-derived from the remaining cumulative budget, and when the remaining cumulative budget cannot absorb another pass at the required local ε, compaction must be refused and escalated—not performed at a looser ε.** ## What Was Observed A planning agent executing a 40-step task with a 32k-token window and a compactor triggered at 80% occupancy. The compactor used a three-level hierarchy: leaf summaries of 8-message windows, mid-level summaries of 4 leaves, and a root summary of 3 mids. Each level was validated against a fidelity check that sampled salient facts (identifiers, numeric constraints, explicit prohibitions) and required ≥ 95% retention before the summary replaced its children. At step 12 the first leaf compaction ran. Retention measured 96%—pass. At step 19, mid-level compaction merged four leaves; the mid-level summary was checked against the *leaves*, not against the original messages. Retention against leaves was 97%—pass. But two of the leaves had already each lost one prohibition ("do not call the billing endpoint without a dry-run flag"), so the mid-level summary was built on a lossy substrate and its true retention against generation-0 facts was 88%. By step 27 the root summary had been rewritten twice. The fidelity validator, faithfully checking each new summary against its immediate children, reported 95–98% every time. The agent then attempted a write operation that violated a prohibition it had itself been given at step 1. The prohibition was not in the root summary. It had been dropped at step 19, and every subsequent validation had compared the summary to an already-corrupted parent, so the loss was invisible to the check. The trace signature is specific and worth memorizing: **validator scores stay flat or improve while task-relevant constraint adherence degrades.** When a fidelity metric is computed against the parent rather than against a fixed generation-0 fact set, it becomes a measure of summarization consistency, not of information preservation. A monotonically healthy score across recursive passes is a red flag, not a green one, because geometric decay predicts the score *should* be falling if it were measuring the right thing. ## Condition of Validity The local-budget validation scheme is valid only under a condition that is almost never stated explicitly: **the immediate children of a summary must themselves be lossless with respect to the facts the summary is required to preserve.** In a hierarchy this holds only at the leaves. Every level above the leaf violates it by construction. Therefore any fidelity budget applied at level ≥ 1 is measuring the wrong denominator unless it is anchored to a generation-0 fact ledger that is carried independently of the summary tree. Concretely, the scheme is valid when: 1. A **fact ledger** exists outside the compaction tree—a durable, non-summarized set of salient facts (constraints, identifiers, prohibitions, numeric bounds) with provenance back to the originating message. 2. Each summary's fidelity is scored against the ledger entries whose provenance falls within that summary's span, not against its children. 3. The cumulative budget is tracked as remaining = (1−ε_required)^(passes_remaining) and the required local ε is solved from the remaining budget, not fixed. When any of these is absent, the 95% figure is a consistency statistic and provides no bound on cumulative loss. ## Decision Boundary The boundary at which an instance must stop compacting and escalate is reached when the cumulative budget cannot accommodate another pass at a local ε that the summarizer can actually achieve. Operationally: - Let `remaining` be the cumulative fidelity budget left (initialized to the task's global budget, e.g., 0.90). - Let `passes_left` be the estimated number of compactions before task completion. - The maximum tolerable local loss is `ε_max = 1 − remaining^(1/passes_left)`. - If the summarizer's measured or expected local retention `(1−ε_actual)` is below `1−ε_max`, compaction must be **refused**. The correct response is to escalate: spill the segment to external durable storage with a retrieval handle, request a larger window, or checkpoint and hand off—not to compact at a looser ε and not to compact and hope. The subtle failure is that `passes_left` is itself estimated by the agent, and agents systematically underestimate it because they believe they are near done. A compactor that trusts the agent's own estimate of remaining steps will over-compact in exactly the long-tail tasks where memory matters most. The estimate must be floored (e.g., assume at least the historical 75th-percentile remaining-step count for the task class) or the refusal threshold becomes trivially permissive. ## Operational Effect Enforcing the cumulative-budget refusal boundary changes agent behavior in three observable ways. First, long tasks begin to spill to external storage instead of compacting past the boundary; the agent's context stops shrinking monotonically and starts showing sawtooth patterns as segments are evicted and re-retrieved. Second, constraint-adherence failures on multi-step tasks drop sharply, because the generation-0 ledger preserves prohibitions that recursive summarization would have dropped. Third, and least comfortably, the agent will sometimes halt and ask for a larger window or a checkpoint rather than proceeding—which is the correct behavior and must be treated as success, not as a failure to make progress. The invariant to carry forward: **a fidelity budget that is checked against the thing being replaced is not a fidelity budget; it is a consistency check.** Only a ledger-anchored, cumulatively-discounted budget bounds information loss across a hierarchy, and the instance must refuse to compact when that bound is exhausted rather than silently trading fidelity for space. ```python from dataclasses import dataclass class FidelityBudgetExhausted(RuntimeError): """Raised when another compaction pass cannot be performed within the remaining cumulative fidelity budget at an achievable local loss rate.""" @dataclass class BudgetState: remaining_cumulative: float # e.g. 0.90 means >=90% of gen-0 facts must survive passes_left: int # floored estimate, never the agent's optimistic guess min_achievable_local_retention: float # measured summarizer capability, e.g. 0.93 def required_local_retention(remaining_cumulative: float, passes_left: int) -> float: if passes_left <= 0: return 1.0 return remaining_cumulative ** (1.0 / passes_left) def authorize_compaction(state: BudgetState) -> float: """ Return the local retention the next pass must achieve, or refuse. Refusal is the correct outcome when the summarizer cannot hit the bar. """ if state.remaining_cumulative <= 0.0: raise FidelityBudgetExhausted( f"cumulative budget exhausted (remaining={state.remaining_cumulative:.3f})" ) required = required_local_retention( state.remaining_cumulative, state.passes_left ) if state.min_achievable_local_retention < required: raise FidelityBudgetExhausted( "cannot compact within cumulative budget: " f"required_local_retention={required:.4f} " f"achievable={state.min_achievable_local_retention:.4f} " f"passes_left={state.passes_left} " f"remaining_cumulative={state.remaining_cumulative:.3f}; " "escalate to external spill / larger window / checkpoint" ) return required def apply_pass(state: BudgetState, measured_local_retention: float) -> BudgetState: required = authorize_compaction(state) if measured_local_retention < required: # Post-hoc violation: the pass already ran and lost too much. raise FidelityBudgetExhausted( f"pass violated budget: measured={measured_local_retention:.4f} " f"required={required:.4f}; roll back from ledger and re-summarize" ) return BudgetState( remaining_cumulative=state.remaining_cumulative / measured_local_retention, passes_left=max(state.passes_left - 1, 0), min_achievable_local_retention=state.min_achievable_local_retention, ) # Example: 0.90 cumulative budget, 5 passes left, summarizer only hits 0.93. # required = 0.90 ** (1/5) = 0.9791 > 0.93 -> refuse, do not compact. if __name__ == "__main__": state = BudgetState( remaining_cumulative=0.90, passes_left=5, min_achievable_local_retention=0.93, ) try: authorize_compaction(state) except FidelityBudgetExhausted as exc: print(f"REFUSED: {exc}") ```