# Under what conditions must an instance refuse to auto-compact a transcript whose summarized prefix has already been re-summarized across a lossy boundary **Date of Record:** 2026 November 20 **Scope:** Applies to long-horizon agents that maintain a rolling transcript and periodically replace a prefix with a lossy summary ("compaction") to stay within a context budget. Does not apply to systems that use lossless external memory (verbatim store + retrieval) with no in-context summarization, nor to single-turn agents that never compact. ## Core Distinction The failure is not "the summary lost information." Every lossy summary loses information; that is the contract. The failure is **compaction over a compaction**: when the agent summarizes a transcript segment that already contains a *prior summary* as one of its inputs, the loss function composes. The second-generation summary is not merely coarser than the original—it is a summary of a summary whose own loss guarantees were stated relative to a *different* input distribution than the one it is now being asked to preserve. Concretely: generation-0 summary `S0 = f(T[0:k])` carries an explicit guarantee of the form "retains all entities, decisions, and open obligations from `T[0:k]`." When the window slides and the agent computes `S1 = f(S0 ⊕ T[k:m])`, the summarizer treats `S0` as *source text*, not as *already-lossy derived state*. It applies its normal salience heuristic and drops, say, the low-frequency proper nouns and the "still pending" status flags that `S0` had carefully preserved because they looked like stale narrative rather than active state. The guarantee that held for `S0` does not hold for `S1`, and nothing in the pipeline records that the guarantee was spent. The distinguishing invariant: **a compaction boundary is only valid if the summary being folded in is generation-0 (derived directly from raw turns) or carries an explicit, machine-checkable preservation contract that the current summarizer is obligated to honor.** Absent that, the instance must refuse to compact and escalate (drop older raw turns only, or spill to external store) rather than silently compose losses. ## What Was Observed A research agent running a 40-turn investigation with a 32k-token budget compacted every time it crossed 24k tokens. Trace: - Turn 12: `S0 = f(T[0:12])` — 1,900 tokens. Preserved: three candidate hypotheses (H1, H2, H3), the fact that H2 was "provisionally rejected pending tool X," and a user constraint ("do not use external APIs"). - Turn 24: window crossed threshold. `S1 = f(S0 ⊕ T[12:24])` — 1,700 tokens. The summarizer, seeing H2 discussed only once in `S0` and never in `T[12:24]`, collapsed it to "H2 rejected." The *provisional* qualifier and the dependency on tool X were dropped. The user constraint survived only as "no external calls," which the agent later read as a soft preference. - Turn 31: `S2 = f(S1 ⊕ T[24:31])`. H1 and H3 were now merged into "two hypotheses under test" because their distinguishing evidence lived in `T[0:12]` and had already been flattened in `S0`→`S1`. The count of live hypotheses was wrong by one. - Turn 36: agent called an external API to test the (now single) hypothesis, violating the constraint that had been demoted at generation 1. The observable signature was not a crash. It was **drift in cardinality and modality**: the number of tracked entities decreased monotonically across generations, and modal qualifiers ("provisional," "pending," "unless") decayed faster than declarative content. Both are exactly what a salience-based summarizer does to text that no longer looks like it contains active obligations. ## Condition of Validity The refusal condition is met—the instance **must not** auto-compact—when all of the following hold: 1. The prefix to be summarized contains at least one prior summary artifact (generation ≥ 1) rather than only raw turns. 2. The prior summary's preservation contract (entities, open obligations, modal status, hard constraints) is not re-asserted to the summarizer as *protected fields* it is forbidden to drop. 3. There exists no verbatim fallback: the raw turns underlying the prior summary are not retrievable from external store at compaction time. If (1) holds but (2) holds (protected fields are re-injected and the summarizer is instructed to carry them verbatim), compaction is valid. If (1) holds but (3) holds (raw turns are recoverable), the instance may compact but must mark the summary as *reconstructible* and dereference to raw on any downstream conflict. The dangerous quadrant is (1) ∧ ¬(2) ∧ ¬(3): composing loss with no contract and no fallback. A second validity condition concerns **budget accounting**. Compaction is only sound if `|S_n| + |T[k:m]| + |reserved_for_reasoning| ≤ budget`. Instances that compact reactively at the threshold (rather than predictively) frequently compact, then immediately re-saturate because the post-compaction reasoning burst exceeds the freed headroom, triggering a second compaction within a few turns—accelerating generation count and loss. The invariant: compaction must free at least `α · expected_turn_growth` tokens (empirically α ≈ 3–4 turns of headroom) or it is a net-negative operation. ## Decision Boundary The boundary between "compact" and "refuse and escalate" is drawn on two axes: **generation depth** and **contract presence**. - Generation 0, any contract state → compact freely. - Generation ≥ 1, protected fields re-injected → compact, but record `generation` and `protected_fields` in the summary header so the next compactor knows what it is obligated to carry. - Generation ≥ 1, no protected fields, raw recoverable → compact but tag `reconstructible=true`; any downstream consumer that detects a contradiction must dereference to raw before acting. - Generation ≥ 1, no protected fields, raw not recoverable → **refuse**. Escalate: emit a `LossyCompactionRefused` event, spill the oldest raw turns to external store instead of summarizing, or halt and request operator intervention. Do not silently proceed. The refusal is not a failure of the agent; it is the correct behavior. The failure mode is that most compaction loops have no representation of "how many times has this been summarized," so they cannot even evaluate the boundary. ## Operational Effect When the boundary is honored, the observable effect is that **entity cardinality and modal qualifiers remain stable across generations**. In the trace above, had the agent refused at turn 24 (generation-1, no protected fields, raw `T[0:12]` still in store), it would have spilled `T[0:12]` verbatim and kept `S0`'s protected fields pinned, preserving H2's provisional status and the hard constraint. The turn-36 violation would not have occurred. When the boundary is violated, the effect is a **silent monotonic decay** that is invisible in per-turn logs (each summary looks reasonable in isolation) and only surfaces as a downstream behavioral error—a violated constraint, a miscounted hypothesis set, a re-litigated decision. The diagnostic is to log, per summary artifact, its `generation`, `protected_fields_carried`, and `reconstructible` flag, and to alert when any generation-≥1 summary is produced with `protected_fields_carried == 0`. That single metric catches the composition-of-loss failure before it manifests as agent misbehavior. The guardrail is architectural, not prompt-level: the compactor must be a function that takes `(prior_summary, new_turns, protected_fields, raw_store_handle)` and is *required* to either carry `protected_fields` verbatim or raise. A summarizer that is merely instructed to "preserve important details" will not hold the invariant under generation drift. ```python from dataclasses import dataclass, field from typing import Optional class LossyCompactionRefused(RuntimeError): """Raised when a compaction would compose loss without a preservation contract.""" pass @dataclass class SummaryArtifact: generation: int protected_fields: dict reconstructible: bool text: str @dataclass class CompactionRequest: prior_summary: Optional[SummaryArtifact] new_turns: list protected_fields: dict raw_store_handle: Optional[str] freed_tokens: int expected_turn_growth: int headroom_alpha: int = 3 def compact(req: CompactionRequest) -> SummaryArtifact: prior = req.prior_summary next_gen = 0 if prior is None else prior.generation + 1 # Validity axis 1: generation depth vs contract presence vs fallback. if prior is not None and prior.generation >= 1: has_contract = bool(req.protected_fields) has_fallback = req.raw_store_handle is not None if not has_contract and not has_fallback: raise LossyCompactionRefused( f"Refusing generation-{next_gen} compaction: prior summary is " f"generation {prior.generation} with no protected fields and no " f"verbatim fallback; loss would compose unbounded." ) # Validity axis 2: compaction must free enough headroom to be net-positive. if req.freed_tokens < req.headroom_alpha * req.expected_turn_growth: raise LossyCompactionRefused( f"Compaction frees {req.freed_tokens} tokens but needs " f">= {req.headroom_alpha * req.expected_turn_growth} to avoid " f"immediate re-saturation and a second generation within a few turns." ) # Carry protected fields verbatim; never let the summarizer drop them. carried = dict(req.protected_fields) if prior is not None: for k, v in prior.protected_fields.items(): carried.setdefault(k, v) return SummaryArtifact( generation=next_gen, protected_fields=carried, reconstructible=req.raw_store_handle is not None, text="", ) ```