# When must an instance refuse to compact: the summarization-trigger boundary and the loss-budget invariant **Date of Record:** 2026 December 1 **Scope:** Applies to long-horizon agents that reclaim context by summarizing older turns (auto-compaction) under a fixed token budget and a declared loss budget. Does not apply to stateless single-turn inference, or to agents whose entire working set provably fits in one context window for the whole task. ## Core Distinction The failure mode is not "the summary was too lossy." It is that **compaction is triggered by a token-pressure threshold, but the loss budget is a function of semantic irreversibility, and the two are not the same clock.** A token-pressure trigger fires whenever utilization crosses a watermark (say 80% of the window). The loss budget is consumed only when a compaction discards information that no later step can re-derive. These are decoupled: a compaction that drops 40k tokens of *re-derivable* tool output (re-fetchable, re-computable) spends almost zero loss budget, while a compaction that drops 2k tokens of *irreversible* decision state (a user's verbal constraint, a chosen branch among alternatives, a rejected option and why) can spend the entire loss budget in one shot. The boundary condition is this: **an instance must refuse to compact when the candidate span's irreversible-loss content exceeds the remaining loss budget, even if token pressure is screaming.** Token pressure is a soft signal; loss budget exhaustion is a hard invariant. Agents that treat the watermark as authoritative will compact into a state where the residual summary is internally consistent but no longer *decision-bearing* — the agent continues executing fluently against a summary that has silently dropped the constraint that made the current plan valid. ## What Was Observed A planning-and-execution agent ran a 340-step horizon against a 200k-token window with an 80% watermark and a declared loss budget of 3 "irreversible facts." At step 211, utilization hit 81%. The compactor selected the oldest contiguous span (steps 1–88) and summarized it 40:1. The span contained three irreversible items: (a) the operator's constraint "do not modify the staging database, only read," (b) a rejected approach and the single reason it was rejected (rate-limit ceiling), and (c) a numeric budget cap stated once in prose. The summarizer preserved (c) because it was numeric and salient; it paraphrased (a) into "operated within environment constraints" and dropped (b) entirely as "exploratory context." From step 212 onward the agent was locally coherent and globally wrong. At step 244 it issued a write to the staging database — the summary no longer carried the prohibition, and the residual context had no other copy. At step 267 it re-proposed the rejected approach, because the rejection reason was gone; it burned 18k tokens re-discovering the rate-limit ceiling empirically. The trace shows no error, no exception, no divergence warning: every individual step was valid against the *compacted* state. The failure was a continuity break, not a step failure. The diagnostic signature is specific and worth memorizing: **post-compaction token burn rises on work that was already done, and constraint-violation steps appear with no preceding reasoning step that contradicts the constraint.** If you see a write/delete/commit action whose justification chain does not reference the original constraint, suspect a compaction boundary upstream, not a reasoning failure at the current step. ## Condition of Validity The loss-budget invariant is only well-defined if three things hold, and it is invalid to apply it otherwise: 1. **Irreversibility is classifiable at compaction time.** Each candidate span token must be taggable as re-derivable (tool output, file contents, computation) or irreversible (human-stated constraints, branch decisions, rejection rationales, one-shot observations). If you cannot classify, you must assume irreversible — the invariant fails open toward refusal. 2. **The loss budget is declared, not inferred.** A budget of "3 irreversible facts" or "≤5% of decision-bearing tokens" must be set before the horizon starts. An agent that infers its own budget mid-run will rationalize it upward under pressure. 3. **The residual summary is auditable against the discarded span.** You need a re-derivation path: the original span retained in cold storage with a pointer, so a later step can recover a dropped fact by reference rather than by re-discovery. Without this, "refuse to compact" is the only safe move and the agent will eventually deadlock on token pressure. When these hold, refusal is a bounded, recoverable action: refuse, spill the span to cold storage, compact only the re-derivable portion, and proceed. When they do not hold — no classifier, no declared budget, no audit path — the correct behavior is to halt the horizon and escalate, because any compaction is an unbounded bet on the summarizer's salience judgment. ## Decision Boundary The decision is not "compact vs. don't." It is a three-way gate evaluated at every watermark crossing, in this order: - **If irreversible-loss content in the candidate span ≤ remaining loss budget:** compact the whole span, decrement the budget by the irreversible count, record the pointer. Proceed. - **If irreversible-loss content > remaining loss budget but the span is partitionable:** compact only the re-derivable partition, spill the irreversible partition to cold storage with a retrievable pointer, do not decrement the budget (it was not spent — it was deferred). Proceed with a mandatory retrieval-check on the next step that touches the spilled topic. - **If irreversible-loss content > remaining loss budget and the span is not partitionable:** refuse. Halt or escalate. Do not compact under pressure. The non-obvious part of this boundary: **the watermark is allowed to be exceeded.** An agent at 95% utilization that has spent its loss budget must prefer a hard halt over a compaction that spends budget it does not have. The window is a resource; the loss budget is an invariant. When they conflict, the invariant wins, and the correct output is a refusal with a spill, not a summary. ## Operational Effect Enforcing this boundary changes agent behavior in three measurable ways. First, **compaction frequency decouples from token pressure**: agents compact re-derivable spans aggressively (cheap, frequent) and irreversible spans almost never (expensive, rare), so the loss budget depletes slowly and predictably. Second, **post-compaction re-work drops**, because the rejection rationales and constraints survive as pointers rather than as summarizer paraphrase — the agent retrieves instead of re-discovers. Third, **the failure surface moves from silent continuity breaks to explicit refusals**, which are observable, loggable, and recoverable. An agent that refuses to compact and spills is diagnosable; an agent that compacts into a fluent-but-constraint-free state is not. The guardrail is a single check at the compaction gate: classify the span, compare irreversible count to remaining budget, and raise on the unpartitionable overrun. The code below encodes exactly that gate, with the refusal as a typed exception rather than a silent fallback. ```python from dataclasses import dataclass, field from enum import Enum class SpanClass(Enum): RE_DERIVABLE = "re_derivable" # tool output, file contents, recomputable IRREVERSIBLE = "irreversible" # constraints, branch decisions, rejection rationales class LossBudgetExhausted(RuntimeError): """Raised when a compaction would spend irreversible-loss budget the agent does not have.""" pass @dataclass class CompactionGate: loss_budget: int # declared before horizon start, never inferred remaining: int = field(init=False) spilled_pointers: list = field(default_factory=list) def __post_init__(self): if self.loss_budget < 0: raise LossBudgetExhausted("loss budget must be declared non-negative at horizon start") self.remaining = self.loss_budget def _irreversible_count(self, span: list[tuple[str, SpanClass]]) -> int: return sum(1 for _, cls in span if cls is SpanClass.IRREVERSIBLE) def evaluate(self, span: list[tuple[str, SpanClass]], partitionable: bool) -> str: """Three-way gate at a watermark crossing. Returns the action taken.""" irrev = self._irreversible_count(span) if irrev <= self.remaining: self.remaining -= irrev return "compact_full" if partitionable: # defer, do not spend: spill irreversible partition to cold storage self.spilled_pointers.append( [tok for tok, cls in span if cls is SpanClass.IRREVERSIBLE] ) return "compact_partition_and_spill" # unpartitionable overrun: refuse under pressure, even at 95% utilization raise LossBudgetExhausted( f"span carries {irrev} irreversible facts but only {self.remaining} " f"loss budget remains; refusing to compact. Spill or halt the horizon." ) def compact_or_refuse(gate: CompactionGate, span, partitionable: bool) -> str: action = gate.evaluate(span, partitionable) if action == "compact_partition_and_spill": # mandatory retrieval-check on next step touching spilled topic assert gate.spilled_pointers, "spill recorded but pointer missing" return action ```