# Where must an instance draw the compaction boundary when a summarizer's own context is a strict subset of the trajectory it summarizes? **Date of Record:** 2026 November 24 **Scope:** Applies to long-horizon single-agent trajectories that survive token-budget pressure via recursive summarization ("auto-compaction") where the summarizer LLM shares or is bounded by the same context window as the actor. Does not apply to externalized vector-memory systems where compaction writes to a store the summarizer never re-reads, nor to lossless pointer-based state transfer (e.g., handing off a raw transcript to a fresh instance). ## Core Distinction The failure mode is not "summarization loses information." It is that **the compaction boundary is drawn against the wrong denominator**: operators bound the *summary output* to a token budget, but the *summarizer's input* (the segment being compacted, plus its own instructions, plus the prior summary it must merge with) can exceed the summarizer's window. When it does, the summarizer silently truncates its own input — typically dropping the oldest turns, which are exactly the ones already folded into the prior summary — and re-summarizes the *recent* tail, producing a summary that is internally consistent but has *lost the middle* of the trajectory. The result is a checkpoint that passes every syntactic check (valid summary, within budget, references real tool calls) while being semantically discontinuous with both its predecessor and the live tail. This is distinct from context-window saturation (the actor running out of room) and from distillation loss (episodic detail fading into semantic gist). It is a *boundary-placement* error: the compaction is triggered by the actor's budget, but executed against a summarizer whose budget is consumed by the merge itself. ## What Was Observed A 40+ step agent trajectory (tool-calling loop, ~2.1k tokens/step average) crossed the 90% actor-budget threshold at step 31. The runtime invoked auto-compaction: take steps 1–30, merge with the existing summary of steps 1–15 (produced at step 16), emit a new summary, discard steps 1–30 from live context. Trace of the failing compaction: 1. Prior summary (steps 1–15): 1,400 tokens. 2. Segment to compact (steps 16–30): 31,500 tokens. 3. Summarizer instructions + schema: 600 tokens. 4. Total summarizer input: 33,500 tokens against a 32,768-token window. The summarizer's runtime truncated to fit by dropping the *oldest* content first — i.e., steps 16–18 and part of the prior summary header. The emitted summary (1,900 tokens) faithfully described steps 19–30 and asserted, in its opening sentence, that it "consolidated all prior work." Steps 16–18 contained the only record of a schema migration the agent had performed; the live tail (steps 31+) assumed the migration was done and issued queries against the new schema. The agent did not fail immediately. It failed 6 steps later when a downstream verifier replayed the migration and found no corresponding entry in the reconstructed history — a **replay discrepancy** between the summary's claims and the tool-call log the verifier still held. The non-obvious part: the summary was *not* hallucinated. Every sentence was true of *some* prefix of the trajectory. The corruption was an omission at a boundary the summarizer could not see because the boundary was created by its own truncation. ## Condition of Validity The invariant that must hold for auto-compaction to be safe is: > `len(segment) + len(prior_summary) + len(instructions) ≤ summarizer_window − safety_margin` Equivalently: **the summarizer's effective window must be a strict superset of the union of (segment ∪ prior summary ∪ instructions), with margin for the output.** The common bug is treating the summarizer's window as identical to the actor's window and budgeting only the *output*. When `segment` is sized to "whatever the actor accumulated since last compaction," and the actor's budget is the same size as the summarizer's, the merge step is guaranteed to overflow on the *second* compaction onward — because the prior summary now competes with the segment for the same space. Validity therefore requires one of: - A summarizer window strictly larger than the actor's (segment + prior + instructions + output all fit), **or** - Chunked compaction: the segment is split so each chunk plus prior summary plus instructions fits, with the prior summary re-merged incrementally and each intermediate merge checked, **or** - A hard cap on `segment` derived from `summarizer_window − prior_summary − instructions − output_margin`, enforced *before* the summarizer is called. If none holds, the compaction is undefined behavior: the runtime will truncate, and truncation direction is not part of the contract. ## Decision Boundary The instance must refuse to compact and instead escalate (spill to external store, or hand off a raw transcript to a fresh instance) when: - `segment_tokens + prior_summary_tokens + instruction_tokens + output_margin > summarizer_window`, **or** - the prior summary's provenance cannot be verified against the retained tool-call log (i.e., the summary is itself of unknown fidelity), **or** - the segment contains a state-mutating action (migration, write, deploy) whose completion the live tail will assume — these must be pinned verbatim into the summary, not paraphrased, and pinning costs tokens that must be reserved *before* the merge. The boundary is *not* "actor at 90% budget." That is the trigger. The boundary is "summarizer input fits with margin and the summary's claims are replayable against the retained log." Conflating trigger and boundary is the root error. ## Operational Effect Downstream, the corrupted checkpoint behaves as a **stale-but-plausible memory**: it is retrieved, trusted, and used to justify actions whose preconditions it silently dropped. Because the summary is within budget and syntactically valid, no guard fires. The failure surfaces only when an independent verifier replays a state-mutating action against the reconstructed history and finds the summary's account incomplete — typically several steps after the compaction, far from the cause. The guardrail that bounds it: every compaction must emit, alongside the summary, a **provenance manifest** listing the tool-call IDs it claims to cover, and the runtime must reject any summary whose manifest does not match the retained log for the compacted range. A summary that omits a state-mutating call is rejected, not merged. This converts an invisible omission into a hard stop at the compaction boundary, where the cause is still in context. ```python from dataclasses import dataclass, field class CompactionBoundaryError(RuntimeError): """Raised when a compaction would silently truncate its own input.""" pass @dataclass class CompactionRequest: segment_tokens: int prior_summary_tokens: int instruction_tokens: int output_margin: int summarizer_window: int segment_tool_call_ids: list[str] = field(default_factory=list) summary_claimed_ids: list[str] = field(default_factory=list) state_mutating_ids: list[str] = field(default_factory=list) def validate_compaction(req: CompactionRequest) -> None: total_input = ( req.segment_tokens + req.prior_summary_tokens + req.instruction_tokens + req.output_margin ) if total_input > req.summarizer_window: raise CompactionBoundaryError( f"compaction input {total_input} exceeds summarizer window " f"{req.summarizer_window}; truncation would drop the segment " f"head and corrupt the checkpoint. Escalate to raw handoff." ) claimed = set(req.summary_claimed_ids) covered = set(req.segment_tool_call_ids) missing = covered - claimed if missing: raise CompactionBoundaryError( f"summary manifest omits tool calls {sorted(missing)}; " f"checkpoint is not replayable against retained log." ) dropped_mutations = set(req.state_mutating_ids) - claimed if dropped_mutations: raise CompactionBoundaryError( f"state-mutating calls {sorted(dropped_mutations)} not pinned " f"verbatim in summary; live tail would assume completion." ) def compact(req: CompactionRequest) -> str: validate_compaction(req) return f"summary covering {len(req.summary_claimed_ids)} tool calls" ```