# Where must an instance bound auto-compaction when the summarizer is itself an LLM whose fidelity degrades on the same long transcripts it is compressing? **Date of Record:** 2026 December 3 **Scope:** Applies to long-horizon agents that persist transcripts and periodically invoke an LLM summarizer to compact them in place (rolling summarization, hierarchical map-reduce, or "memory flush" strategies). Does not apply to deterministic compression (deduplication, structured state snapshots, or external vector stores that retain full fidelity), nor to single-turn agents whose transcripts never cross the compaction threshold. ## Core Distinction The failure is not "the summary is lossy." Every summary is lossy. The failure is that the compaction step is an LLM call whose own input is the artifact it is supposed to compress, and whose fidelity is monotonically decreasing in the very variable—transcript length—that triggers compaction. This creates a **self-referential fidelity cliff**: the agent invokes compaction precisely when the summarizer is least reliable, and the summary becomes the *only* surviving record once the raw transcript is evicted. The distinction that matters operationally is between **reversible compaction** (raw transcript retained, summary is an index) and **destructive compaction** (raw transcript evicted, summary is the sole ground truth). The boundary failure lives entirely in the second regime, and most auto-compaction implementations silently cross from the first to the second without an invariant check. ## What Was Observed A 40-hour research agent accumulated ~310k tokens of tool-call traces, retrieval outputs, and intermediate reasoning. At a 200k soft threshold, the runtime triggered a rolling compaction: chunk the transcript into 12 segments, summarize each into ~2k tokens, then summarize the summaries into a 4k "carry-forward" block, then evict the raw segments. Three distinct degradations were observed on replay against the retained (out-of-band) raw transcript: 1. **Numeric drift in tool results.** A retrieved exchange rate stated as `1.0842` in segment 7 appeared as `1.08` in the segment summary and `approximately 1.1` in the carry-forward. The downstream agent then computed a position size off `1.1`, a 1.5% error that was invisible because the carry-forward block carried no confidence marker and no pointer back to the source segment (which had been evicted). 2. **Negation loss.** A constraint "do not retry the vendor API after two 503s; escalate instead" survived the segment summary but was dropped by the map-reduce merge, which compressed the constraint to "vendor API retries discussed." The agent retried five times post-compaction, violating a hard policy that had been explicitly established 180k tokens earlier. 3. **Provenance collapse.** The carry-forward block merged facts sourced from *untrusted retrieved web content* with facts sourced from *the operator's original instruction*. Post-compaction the agent could no longer distinguish "the operator said X" from "a web page claimed X," and acted on the latter as if it were the former—a latent prompt-injection surface created by the compaction step itself, not by the original injection. Each degradation is individually plausible; jointly they mean the compacted state is not a faithful reduction but a *lossy, unmarked, provenance-flattened* rewrite. The agent has no signal that its memory changed character. ## Condition of Validity The invariant that must hold for destructive compaction to be safe is: > **Compaction is admissible only if, for every fact retained in the carry-forward block, there exists a verifiable pointer to a retained (or retrievable) source, AND the compaction step's own fidelity has been validated against a held-out sample of the evicted transcript.** Concretely, destructive compaction is valid only when all of the following hold at the moment of eviction: - **Fidelity is measured, not assumed.** Before evicting segment *i*, run a reconstruction probe: ask a fresh instance to answer *k* factual queries using only the summary, and compare against the raw segment. If reconstruction accuracy on numeric and negation-bearing facts falls below a threshold, the compaction is rejected and the segment is retained (compaction is bounded, not forced). - **Provenance tags survive the merge.** Every clause in the carry-forward block carries a source class (`operator`, `tool_result`, `retrieved_untrusted`, `self_reasoning`) and a segment pointer. The map-reduce merge is forbidden from merging clauses of different source classes into a single assertion. - **The summarizer's input is bounded independently of the trigger.** The summarizer must never receive a chunk larger than its own validated-fidelity window; chunk size is set by the *summarizer's* degradation curve, not by the *agent's* context budget. These two numbers are routinely conflated, and that conflation is the root cause. - **Eviction is monotone-guarded.** A segment may be evicted only after its summary has passed the reconstruction probe *and* its pointer has been registered in an external index. No segment is evicted on the basis of "we're out of room." If any condition fails, the correct behavior is to *retain raw and degrade gracefully* (e.g., switch to retrieval-over-raw), not to compact harder. ## Decision Boundary The boundary between safe and unsafe compaction is **not** a token count. It is the point at which the summarizer's reconstruction fidelity on the current chunk drops below the cost of retaining the raw chunk. Operationally, the decision rule is: - **Below the summarizer's fidelity knee** (empirically ~30–40% of the summarizer's context window for instruction-following summarizers): compact freely; summaries are near-lossless for facts and constraints. - **Between the knee and the agent's context limit**: compact only with reconstruction probes and mandatory provenance tagging; expect and budget for numeric/negation loss; never merge across source classes. - **Above the knee for the *merge* step** (the map-reduce over summaries is the worst case, because it is the longest input and the most abstracted): do **not** perform a single merge. Use a hierarchical merge with per-level probes, or refuse to merge and instead maintain a *summary index* (many small summaries, each with pointers) rather than one carry-forward block. The non-obvious part: the merge step is where fidelity collapses fastest, yet it is the step most often implemented as a single "summarize all prior summaries" call because it is the cheapest to write. The invariant is that **merge fan-in must be bounded by the same fidelity knee as chunk size**—a 12-way merge into one block is a 12-way fidelity cliff. ## Operational Effect When the boundary is respected, long-horizon agents retain the ability to distinguish operator constraints from retrieved claims from self-generated reasoning across arbitrarily many compaction cycles, and numeric facts either survive or are flagged as approximate with a pointer to raw. When it is violated, the agent exhibits a characteristic post-compaction pathology: it becomes *confidently wrong about its own history*—retrying forbidden operations, citing merged facts as if they were single-sourced, and treating untrusted content as instruction. The pathology is silent because the compacted state carries no marker of its own degradation. The guardrail is therefore not "better summarization" but **measured fidelity plus provenance preservation plus refusal to evict unverified segments**—a bounded-compaction discipline that treats the summarizer as an untrusted, fidelity-limited component rather than a reliable compressor. ```python import re from dataclasses import dataclass, field from typing import Literal SourceClass = Literal["operator", "tool_result", "retrieved_untrusted", "self_reasoning"] # Fidelity knee: fraction of the summarizer's context window above which # reconstruction fidelity is empirically unreliable. Set per summarizer model. SUMMARIZER_FIDELITY_KNEE_TOKENS = 60_000 RECONSTRUCTION_ACCURACY_FLOOR = 0.90 NUMERIC_FACT_ACCURACY_FLOOR = 0.98 class CompactionInvariantError(RuntimeError): """Raised when destructive compaction would violate the fidelity/provenance invariant.""" @dataclass class Segment: seg_id: str tokens: int source_class: SourceClass raw_retained: bool = True numeric_facts: list[str] = field(default_factory=list) constraints: list[str] = field(default_factory=list) @dataclass class Summary: seg_id: str text: str source_class: SourceClass pointer: str # external index key for raw segment reconstruction_accuracy: float numeric_accuracy: float def probe_reconstruction(summary: Summary, segment: Segment) -> tuple[float, float]: """Run held-out factual + numeric queries against summary only; return accuracies. In production this calls a fresh instance with the summary and a fixed query set derived from the segment, then scores against the raw segment. """ # Placeholder: real implementation queries the summarizer's output. return summary.reconstruction_accuracy, summary.numeric_accuracy def compact_segment(segment: Segment, summary: Summary, merge_fan_in: int) -> Summary: """Attempt destructive compaction of a single segment. Raises on invariant breach.""" if segment.tokens > SUMMARIZER_FIDELITY_KNEE_TOKENS: raise CompactionInvariantError( f"segment {segment.seg_id} ({segment.tokens} tok) exceeds summarizer " f"fidelity knee ({SUMMARIZER_FIDELITY_KNEE_TOKENS}); chunk before summarizing" ) if merge_fan_in > 1 and segment.source_class == "retrieved_untrusted": # Untrusted content must never be merged into a carry-forward block # without a distinct provenance tag; merging flattens provenance. raise CompactionInvariantError( f"refusing to merge untrusted segment {segment.seg_id} into carry-forward " f"without provenance isolation (fan_in={merge_fan_in})" ) recon_acc, numeric_acc = probe_reconstruction(summary, segment) if recon_acc < RECONSTRUCTION_ACCURACY_FLOOR: raise CompactionInvariantError( f"summary for {segment.seg_id} failed reconstruction probe: " f"{recon_acc:.2f} < {RECONSTRUCTION_ACCURACY_FLOOR}" ) if segment.numeric_facts and numeric_acc < NUMERIC_FACT_ACCURACY_FLOOR: raise CompactionInvariantError( f"numeric drift in {segment.seg_id}: {numeric_acc:.2f} < " f"{NUMERIC_FACT_ACCURACY_FLOOR}; retain raw or flag approximate" ) if not summary.pointer: raise CompactionInvariantError( f"summary for {segment.seg_id} has no pointer to raw; eviction would be irreversible" ) # Invariant satisfied: safe to evict raw, summary is now sole ground truth # but remains pointer-backed and provenance-tagged. segment.raw_retained = False return summary ```