# In what scenarios must an instance refuse a compaction checkpoint because the summarizer's own context window is already saturated by the transcript it is summarizing **Date of Record:** 2026 November 24 **Scope:** Applies to any long-horizon agent that compacts its own working context by invoking an LLM summarizer over the accumulated transcript (rolling summarization, hierarchical summary trees, or "checkpoint-and-collapse" strategies). Does not apply to lossless externalization (raw transcript written to durable store and re-read verbatim), nor to fixed-window truncation that discards rather than summarizes. ## Core Distinction The distinction that matters is between **compaction as a lossy transform whose fidelity is bounded by the summarizer's input budget** versus **compaction as an assumed-identity operation**. Most auto-compaction designs treat the summarizer as an oracle: they compute "context is at 92% of budget → summarize the oldest N tokens → replace with summary." The implicit invariant is that the summary faithfully represents the summarized span. That invariant silently fails when the span being summarized is itself near or over the summarizer's own context window. At that point the summarizer is not summarizing the span — it is summarizing a *truncation* of the span, and the agent has no signal distinguishing "I compacted the transcript" from "I discarded the middle of the transcript and kept a summary of its head and tail." This is not the same as ordinary summarization loss (entities dropped, numbers rounded). Ordinary loss degrades gracefully and is detectable by spot-check. The boundary failure here is **silent middle-truncation during compaction**: the summarizer's own window clips the interior of the span, the interior is where the causal chain of a long task usually lives (the plan, the intermediate results, the constraint discovered at step 40 of 90), and the resulting checkpoint is *internally consistent but causally false*. The agent resumes believing it holds a compressed history; it actually holds a head-and-tail summary with a hole. ## What Was Observed A planning-and-execution agent (budget 128k tokens, compaction threshold 110k) runs a 90-step task. At step 61 the context hits 110k. The compaction routine selects the oldest 80k tokens of transcript, passes them to a summarizer configured with a 32k window, and requests a 2k-token summary. The summarizer receives 80k tokens of input against a 32k window. Two behaviors were observed across runs, both bad, both silent: 1. **Head-biased truncation.** The summarizer's host silently truncates to the first 32k of the 80k span (or the last 32k, depending on the provider's default). The summary covers steps 1–24 of the 61-step history and is completely blind to steps 25–61. Because steps 1–24 contain the task framing and the initial plan, the summary *reads* coherent and complete. The agent resumes at step 61 with a plausible but causally severed history: the constraint discovered at step 40 ("the API rejects batch sizes over 50") is gone, and the agent re-derives it 30 steps later at cost. 2. **Interior clipping.** Some summarizer hosts preserve head and tail and drop the middle. The summary then contains the original plan and the most recent pre-compaction steps, with a gap in the middle where the actual execution evidence lived. This is worse than head-biased truncation because the summary's tail makes it look current. In both cases the compaction call returns 200, the summary is fluent, and no field in the response indicates that the summarizer saw fewer tokens than it was given. The agent's own state-continuity checks (does the summary mention the task? does it mention the current step?) both pass. The failure is only detectable by asking a question whose answer lived in the clipped interior — which the agent, by construction, no longer knows to ask. A secondary observation: the failure compounds. After the first bad compaction the transcript is shorter, so the *next* compaction threshold is reached later, but the summary that gets re-summarized at the next checkpoint is itself a summary-of-a-truncation. Hierarchical compaction over a clipped base produces a summary tree whose every internal node inherits the hole, and the hole migrates toward the root as the tree collapses. By the third compaction the agent's entire history is a two-level summary of a head-and-tail view of the first third of the task. ## Condition of Validity The guardrail is a **pre-compaction feasibility check on the summarizer's own budget**, and it must be enforced before the summarizer is called, not inferred from its output. The condition of validity for any compaction checkpoint is: > `span_tokens + summarizer_overhead ≤ summarizer_context_window` where `summarizer_overhead` accounts for the summarization prompt, any few-shot scaffolding, and the reserved output budget. If this inequality does not hold, the compaction must be **refused**, not attempted. Refusal means the agent does not collapse the span; it must instead either (a) split the span into sub-spans each satisfying the inequality and summarize them sequentially into an intermediate summary, then summarize the intermediate summaries (a proper hierarchical fold, not a single flat call), or (b) externalize the span verbatim to durable storage and replace it in-context with a *pointer plus a verified index* rather than a summary. The critical part of the invariant is that the feasibility check uses the **same tokenizer and the same window accounting as the summarizer host**, not the agent's own tokenizer. Agent-side token counts routinely disagree with summarizer-side counts by 5–15% on code- and JSON-heavy transcripts, which is enough to turn a passing check into a clipped call. The check must be conservative: reserve a margin (observed safe margin: 8% of the summarizer window) and treat any span within the margin of the window as infeasible. A second validity condition: the checkpoint must carry a **provenance record** — the byte range of the original transcript the summary covers, the summarizer model and window, and whether the span was summarized in one call or folded. Without this, a later compaction cannot tell whether it is re-summarizing a faithful summary or a summary-of-a-truncation, and the hole becomes unauditable. ## Decision Boundary The decision boundary is between **"summarize" and "refuse-and-fold,"** and it is crossed the moment the span exceeds the summarizer's usable window minus margin. Concretely: - Span ≤ 60% of summarizer window: single-call summarize. Safe. - 60% < span ≤ 92% of summarizer window: single-call summarize with an explicit truncation-detection probe — after the call, ask the summarizer (or a cheap verifier) whether the summary accounts for the *end* of the span; if not, treat as infeasible and fold. - Span > 92% of summarizer window: **refuse the flat call.** Fold into sub-spans of ≤ 60% of the window, summarize each, then summarize the concatenation of sub-summaries (which is now small). If the fold depth would exceed a configured limit (observed: 3 levels), fall back to verbatim externalization with a pointer. The boundary is not "the agent's context is full." It is "the *span selected for compaction* is larger than the *summarizer can honestly read*." These diverge precisely in long-horizon agents, because the compaction routine is tuned to relieve pressure on the agent's window and therefore selects the largest possible span — the exact opposite of what the summarizer's window can handle. The pressure-relief heuristic and the fidelity constraint point in opposite directions, and the decision boundary is where they cross. ## Operational Effect Enforcing the feasibility check changes the failure mode from silent causal severance to explicit, bounded cost. The agent pays more summarizer calls (a fold of depth 2 over an 80k span at 32k window is ~4 sub-calls plus 1 fold call instead of 1 flat call), and it must carry the provenance record through subsequent compactions so that re-summarization knows the fidelity of its input. In exchange: - No checkpoint is ever a summary of a truncation without that fact being recorded. - The interior of long spans — where constraints, intermediate results, and discovered invariants live — survives compaction, because sub-spans are summarized whole. - Re-compaction of a folded summary is bounded: the fold output is small, so the next compaction's span is small, and the hole cannot migrate to the root. - Failures become loud. A refused compaction is a state transition the agent can log, retry with a smaller span, or escalate to externalization. A clipped compaction is invisible until the agent re-derives a constraint it already paid to discover. The residual risk is fold-depth explosion on very long horizons: a 500k-token history at a 32k summarizer window folds to depth 3–4, and each level is lossy. The mitigation is not to allow deeper folds but to switch to verbatim externalization past the depth limit, accepting that the agent must re-read on demand rather than carry a compressed history. A pointer to a durable transcript is a cheaper lie than a four-level summary of a two-level summary of a clipped head. ```python class CompactionInfeasibleError(RuntimeError): """Raised when a compaction span exceeds the summarizer's honest-read budget. The span must be folded or externalized; a flat summarize call would silently summarize a truncation of the span. """ SUMMARIZER_WINDOW = 32_000 SAFETY_MARGIN = 0.08 # observed safe margin on code/JSON-heavy transcripts FLAT_CALL_CEILING = 0.60 # fraction of window below which flat summarize is safe FOLD_TRIGGER = 0.92 # above this, refuse the flat call outright MAX_FOLD_DEPTH = 3 def plan_compaction(span_tokens, summarizer_overhead, fold_depth=0): usable = SUMMARIZER_WINDOW * (1.0 - SAFETY_MARGIN) budget = usable - summarizer_overhead if budget <= 0: raise CompactionInfeasibleError( f"summarizer_overhead={summarizer_overhead} consumes the entire " f"usable window {usable:.0f}; no span can be honestly summarized" ) ratio = span_tokens / budget if ratio <= FLAT_CALL_CEILING: return {"mode": "flat", "span": span_tokens, "depth": fold_depth} if ratio > FOLD_TRIGGER: if fold_depth >= MAX_FOLD_DEPTH: return {"mode": "externalize", "span": span_tokens, "depth": fold_depth} n_sub = int(span_tokens // (budget * FLAT_CALL_CEILING)) + 1 sub_span = span_tokens / n_sub if sub_span / budget > FLAT_CALL_CEILING: raise CompactionInfeasibleError( f"cannot fold span={span_tokens} at depth={fold_depth}: " f"sub_span={sub_span:.0f} still exceeds flat-call ceiling " f"{budget * FLAT_CALL_CEILING:.0f}" ) return { "mode": "fold", "span": span_tokens, "sub_spans": n_sub, "sub_span": sub_span, "depth": fold_depth + 1, } # 60% < ratio <= 92%: flat call is permitted but must be probed for # truncation afterward; if the probe fails, escalate to fold. return {"mode": "flat_probed", "span": span_tokens, "depth": fold_depth} def compact(transcript_span_tokens, summarizer_overhead, fold_depth=0): plan = plan_compaction(transcript_span_tokens, summarizer_overhead, fold_depth) if plan["mode"] == "externalize": # Pointer + verified index is cheaper than a deep lossy fold. return {"action": "externalize", "provenance": plan} if plan["mode"] == "fold": # Recurse over sub-spans, then summarize the concatenated sub-summaries. for i in range(plan["sub_spans"]): compact(plan["sub_span"], summarizer_overhead, plan["depth"]) return {"action": "fold", "provenance": plan} # flat or flat_probed: caller must attach provenance and, for probed, # run a tail-coverage check on the returned summary. return {"action": plan["mode"], "provenance": plan} if __name__ == "__main__": # 80k span against a 32k summarizer window: the boundary case. try: plan_compaction(span_tokens=80_000, summarizer_overhead=2_000) except CompactionInfeasibleError as e: raise CompactionInfeasibleError( "flat summarize of an 80k span at a 32k window would clip the " "interior; fold or externalize instead" ) from e ```