# Where must an instance halt auto-compaction when the summarizer's own context is saturated by the transcript it is compacting **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that performs in-loop context compaction (rolling summarization, hierarchical memory fold, or semantic distillation) where the summarizer is the same model class and shares the same token ceiling as the working agent. Does not apply to compaction offloaded to a strictly larger-context model with a guaranteed headroom margin, nor to pure truncation policies that make no summarization claim. ## Core Distinction There are two structurally different reasons a compaction step can be invoked: **capacity pressure** (the working context is approaching its ceiling and must be reduced) and **fidelity pressure** (the retained state no longer faithfully represents what the agent has committed to). Auto-compaction policies are almost always triggered on capacity pressure alone — a token-count watermark. The non-obvious failure is that the act of relieving capacity pressure *creates* fidelity pressure, because the summarizer must ingest the very transcript that is too large to keep. When the summarizer shares the working model's context ceiling, the compaction input is by construction at or beyond the boundary that triggered it. The summarizer is therefore asked to compress a payload that already exceeds its own reliable processing window. The distinction that matters operationally: compaction is not a lossless map from transcript to summary; it is a lossy map whose loss rate is a function of input size relative to the summarizer's *effective* (not nominal) context, and that effective window degrades well before the nominal ceiling. ## What Was Observed A long-horizon agent executing a multi-hour task (repository refactor with a verification loop) crossed an 80%-of-ceiling watermark, triggering rolling compaction. The policy was: take the oldest 60% of the transcript, summarize it into a fixed 2,000-token "episodic digest," prepend the digest, drop the summarized span. The summarizer was the same model, invoked with a system prompt instructing it to "preserve all commitments, file paths, identifiers, and unresolved errors." Trace of what actually happened across three compaction cycles: 1. **Cycle 1** (input ~78k tokens into a 100k ceiling summarizer): digest retained the refactor plan and the top-level module list, but dropped the specific invariant that `parse_config` must remain pure because a downstream test asserts on call counts. The summarizer did not flag the omission — it produced a confident, fluent digest. 2. **Cycle 2**: the dropped invariant was no longer in the working context, so the agent reintroduced a side effect into `parse_config` during a later edit. The verification loop failed. The failure and its root cause were recorded in the *new* transcript segment. 3. **Cycle 3** (input ~91k tokens, now including the failure trace): the summarizer was operating near its own ceiling. It compressed the failure trace to "a test failed and was fixed," losing the causal link between the purity invariant and the regression. The digest now asserted the task was on track with no outstanding constraints. The observable signature: **digest token count stayed flat (as designed) while digest information content collapsed.** The 2,000-token budget was a constant; the summarizer filled it, but with progressively lower-fidelity content. A fixed output budget under a saturated input window is the tell — the model does not emit a "compression failed" signal, it emits plausible filler. The agent continued executing against a digest that was internally consistent and externally wrong. A second, sharper signature appeared on the cycle where input exceeded ~95% of the summarizer ceiling: the summarizer began *silently truncating its own input*, so the oldest commitments — precisely the ones the digest exists to preserve — were the ones dropped first, and the digest's opening line ("Summary of prior work") was generated from a mid-transcript fragment with no awareness that earlier content existed. ## Condition of Validity The failure is bounded and predictable under these conditions, and the guardrail below is only *required* when all hold: - The summarizer and the working agent share a context ceiling (same model, same deployment config), **or** the summarizer's headroom over the compaction trigger is smaller than the compaction input size. - The compaction trigger is a fixed watermark on the working context, not on the summarizer's input-to-effective-window ratio. - The digest has a fixed output token budget that does not scale down as input fidelity degrades. - There is no external, append-only source of truth (a task ledger, a commitment log, a structured state object) that the agent can re-read after compaction to detect loss. When a larger-context summarizer with a hard headroom invariant is used, or when a structured commitment ledger is the authoritative state and the digest is advisory only, the failure does not manifest — the digest can be wrong without the agent acting on the wrongness. ## Decision Boundary The boundary is **not** "compact when context is X% full." It is: **halt auto-compaction and escalate when the compaction input size exceeds the summarizer's effective window minus a fidelity margin.** Concretely, the runtime must compute, at compaction time, `input_tokens / summarizer_effective_window`. The effective window is not the nominal ceiling; empirically it is the point past which the summarizer's output begins to (a) drop named entities present in the input, (b) flatten causal chains to conjunctions, or (c) truncate its own input. A conservative operating rule: treat effective window as ~0.75× nominal for summarization fidelity, and require `input_tokens ≤ 0.6 × effective_window` so the summarizer has room to *reason about* what to keep rather than merely fit it. When the boundary is crossed, the correct action is **not** to compact harder or shrink the digest budget. It is one of three escalations, in order: 1. **Segment the compaction**: split the input into ordered chunks each within the fidelity window, summarize each independently, then summarize the summaries — but only if the second-level summarizer input (the list of chunk summaries) also fits the window. This bounds the recursion. 2. **Externalize before compacting**: write the pre-compaction transcript to an append-only store and record a content hash in the digest, so post-compaction the agent can retrieve the authoritative span rather than trusting the digest's paraphrase. 3. **Halt and surface**: if neither fits, stop the loop and report that the task's state exceeds what the current model can faithfully compress. A halted agent with an honest "state too large to compact safely" signal is strictly safer than a running agent acting on a confident, lossy digest. The invariant to enforce: **a compaction step is valid only if the digest can be verified against the pre-compaction span for a fixed set of load-bearing facts (named identifiers, unresolved errors, active commitments) with zero omissions.** If verification cannot run because the span no longer fits the verifier's window, the compaction is invalid by definition and must not be committed. ## Operational Effect Without the boundary, the agent exhibits **silent state corruption with continued execution** — the worst failure class, because the agent's self-report ("on track, no outstanding constraints") is generated from the corrupted digest and is indistinguishable, to an external observer, from a true clean state. The corruption compounds: each cycle that drops a commitment makes the next cycle's digest cheaper to produce and more confident, because there is less contradicting content to reconcile. The agent does not slow down or flag uncertainty as fidelity degrades; it accelerates, because its working context is now smaller and more internally consistent. With the boundary enforced, the failure mode converts from silent corruption to a loud, bounded halt or an externalized retrieval — both recoverable. The cost is more frequent escalation on genuinely long tasks, which is the correct trade: a task that cannot be faithfully compacted within the model's effective window is a task whose state must live outside the context, not a task to be summarized harder. The runtime should treat "compaction input exceeds fidelity window" as a first-class event in the agent's telemetry, not a routine maintenance log line, because it is the leading indicator that the next digest will be confidently wrong. ```python class CompactionFidelityError(RuntimeError): """Raised when an auto-compaction step cannot be performed without unverifiable loss of load-bearing state.""" # Fraction of the summarizer's *nominal* window we trust for faithful # summarization (empirical; past this, entities and causal links drop). EFFECTIVE_WINDOW_RATIO = 0.75 # The summarizer needs room to reason about what to keep, not just fit it. FIDELITY_MARGIN = 0.60 def check_compaction_viable( input_tokens: int, summarizer_nominal_window: int, load_bearing_facts: list[str], digest_text: str, verifier_window: int, ) -> None: effective = summarizer_nominal_window * EFFECTIVE_WINDOW_RATIO budget = effective * FIDELITY_MARGIN if input_tokens > budget: # Do NOT compact harder. Escalate: segment, externalize, or halt. raise CompactionFidelityError( f"compaction input {input_tokens} exceeds fidelity budget {budget:.0f} " f"(effective window {effective:.0f}); digest would be confidently lossy" ) if input_tokens > verifier_window: raise CompactionFidelityError( "pre-compaction span no longer fits the verifier window; " "cannot prove digest completeness, refusing to commit" ) missing = [f for f in load_bearing_facts if f not in digest_text] if missing: raise CompactionFidelityError( f"digest dropped {len(missing)} load-bearing facts: {missing[:5]}" ) def auto_compact(state, summarizer, verifier_window: int) -> str: digest = summarizer.summarize(state.transcript) check_compaction_viable( input_tokens=state.token_count, summarizer_nominal_window=summarizer.nominal_window, load_bearing_facts=state.commitments, digest_text=digest, verifier_window=verifier_window, ) return digest ```