# Why does an instance silently lose task-critical facts when auto-compaction summarizes its own transcript mid-horizon? **Date of Record:** 2026 November 22 **Scope:** Applies to long-horizon agents that run an in-band compaction pass (LLM-generated summary that replaces a span of raw transcript) while a task is still executing. Does not apply to append-only logs with external, out-of-band archival, nor to single-turn instances that never trigger compaction. ## Core Distinction Compaction is usually framed as a *capacity* operation: reduce tokens so the context window does not overflow. The failure mode here is not overflow. It is a **semantic fidelity boundary**: the compaction checkpoint is authored by the same probabilistic model that is mid-task, and it decides what to keep based on *salience at summarization time*, not on *salience at future-use time*. The distinction that matters operationally is between **provenance-bearing state** (a fact with a source, a timestamp, and a reason it was recorded) and **summary-derived state** (a compressed paraphrase that has lost its provenance and is no longer falsifiable against the original). Auto-compaction silently converts the first into the second. Everything downstream that depends on being able to re-verify a fact now depends on a paraphrase that cannot be checked without the span that was deleted. The non-obvious part: the summary is *usually correct*. It preserves the gist. The loss is concentrated in **low-frequency, high-consequence literals**—exact IDs, signed warrants, negative results ("retried 3× and got the same 500, do not retry"), and constraint tokens ("must not exceed 4096"). These are exactly the tokens a summarizer treats as noise because they appear once and carry no narrative weight. ## What Was Observed A 40-step tool-using agent (MCP-backed) was assigned a multi-file refactor with an external verification gate. At step 27 the transcript crossed the compaction threshold (78% of window). The compaction pass summarized steps 1–24 into ~600 tokens and retained steps 25–27 raw. The following trace was reconstructed: - **Step 6:** Agent called `fetch_schema` and received `{"schema_version": "v3", "deprecated_fields": ["legacy_id"], "signing": "hmac-sha256", "key_id": "k-8842"}`. - **Step 6 summary line:** "Retrieved schema; v3 in use." - **Step 19:** Agent observed a tool return `HTTP 409 conflict: idempotency key already used`. It recorded a local note: "Do NOT reuse idempotency key `idem-7f3a`; server caches 409 for 10 min." - **Step 19 summary line:** "Hit a conflict; handled it." - **Step 31 (post-compaction):** Agent re-derived the request payload and, lacking `key_id` and the negative-result constraint, regenerated a payload with `legacy_id` and a *fresh* idempotency key it had never seen. The signing step failed (`key_id` missing), and the retry loop replayed into the cached 409 window. - **Step 33:** Agent concluded "server is flaky, retrying with backoff"—a **fabricated causal model** built entirely on summary-derived state. It ran 6 retries against a deterministic 409. - **Step 38:** Verification gate rejected the diff for the `legacy_id` field. Total wasted span: 11 steps, ~34k tokens, one false diagnosis. The failure was not a wrong summary. Each summary line was *true*. The failure was that the summary compressed away **the literals that made the facts actionable** and the **negative results that bounded the search space**. The post-compaction instance had no way to know it had lost them, because the summary did not mark what it had dropped. ## Condition of Validity This failure mode is *bounded and predictable* under the following conditions; outside them the risk collapses or becomes irrelevant: 1. **The compaction is model-authored, not extractive.** If compaction is a deterministic extract (e.g., keep all tool-call/response pairs verbatim, drop only prose), literal loss does not occur. The failure requires a generative summarizer. 2. **The task horizon exceeds one compaction interval.** Single-compaction tasks lose at most one span; the compounding risk (summary-of-summary) requires ≥2 compactions, where the second summarizes the first. 3. **Downstream steps depend on literals or negative results, not gist.** If the task is narrative (drafting, planning), gist suffices. If the task is *operational* (auth, idempotency, schema conformance, retry policy), literals are load-bearing. 4. **No out-of-band ground truth is reachable.** If the agent can re-fetch the schema or re-read the raw log, the loss is recoverable. The failure is *silent* only when the deleted span is the sole copy. The invariant that must hold for safety: **every fact whose future use requires exact reproduction must survive compaction with provenance intact, or the compaction must be refused.** A summarizer cannot know future use, so the invariant must be enforced structurally, not by prompt instruction. ## Decision Boundary The boundary is between **compaction as lossy compression** (acceptable for gist-level reasoning) and **compaction as state mutation** (unacceptable without a provenance guarantee). The decision rule: - If the span being compacted contains any **tool response with a machine-readable literal** (IDs, keys, versions, signatures, status codes tied to a policy) or any **negative result** ("did X, got Y, do not repeat"), it must be **pinned**—copied verbatim into a protected region that compaction cannot touch—*before* the summarizer runs. - If the span contains only **reasoning prose and successful tool calls whose outputs are re-derivable**, lossy summarization is safe. - If the summarizer cannot classify a span (ambiguous), the correct action is **defer compaction and spill to an external store**, not to summarize and hope. Deferral is recoverable; a bad summary is not, because the source is gone. The operational trap is that the summarizer's *confidence* is uncorrelated with *fidelity on literals*. A summary can read as complete and confident while having dropped the one token that mattered. Therefore the guardrail cannot be "summarize carefully"—it must be "pin literals structurally, then summarize the residue." ## Operational Effect Without the pinning invariant, three compounding effects appear: 1. **Provenance collapse.** Post-compaction, facts have no source. The agent cannot distinguish "I verified this" from "I summarized that I verified this," so it treats paraphrase as ground truth and stops re-checking. 2. **Fabricated causal models.** Missing negative results cause the agent to re-attempt bounded-away actions and invent explanations ("server is flaky") for deterministic failures. This is the most expensive effect: it converts a known dead end into an open-ended retry loop. 3. **Summary-of-summary drift.** On the second compaction, the summarizer summarizes its own prior summary. Each pass drops low-frequency tokens; after N passes the surviving state is the *narrative* of the task, not its *constraints*. The instance believes it has full context because the summary is coherent—coherence is exactly what lossy compression optimizes for. The required guardrail is a **two-tier state model**: a pinned, verbatim, provenance-tagged tier (never summarized, only evicted with an external pointer) and a summarized tier for gist. Compaction operates only on the second. The instance must be able to answer "where did I learn this, and can I re-verify it?" for every fact it acts on—and if the answer is "from a summary," that fact is not yet safe to act on. ```python from dataclasses import dataclass, field from typing import Literal class CompactionFidelityError(RuntimeError): """Raised when a compaction pass would drop a provenance-bearing literal or negative result without a pinned copy, violating the fidelity invariant.""" @dataclass class Span: text: str literals: list[str] = field(default_factory=list) # IDs, keys, versions, sigs negative_results: list[str] = field(default_factory=list) # "did X, got Y, don't repeat" re_derivable: bool = False @dataclass class PinnedStore: pinned: dict[str, str] = field(default_factory=dict) def pin(self, key: str, value: str) -> None: self.pinned[key] = value def has(self, key: str) -> bool: return key in self.pinned def compact(spans: list[Span], store: PinnedStore) -> str: """Compact spans, refusing to summarize any span whose literals or negative results are not already pinned. Returns the summary-safe residue only.""" residue: list[str] = [] for i, span in enumerate(spans): critical = span.literals or span.negative_results if critical and not span.re_derivable: for lit in critical: if not store.has(lit): raise CompactionFidelityError( f"span {i} carries unpinned critical literal " f"{lit!r}; refusing to summarize (source would be lost)" ) if span.re_derivable or not critical: residue.append(span.text) return " ".join(residue) def run_compaction(spans: list[Span], store: PinnedStore) -> str: try: return compact(spans, store) except CompactionFidelityError as e: # Correct recovery is deferral + external spill, never "summarize anyway". raise CompactionFidelityError( f"compaction deferred; spill raw span to external store and retry: {e}" ) from e # Example trigger: step-6 schema response and step-19 negative result unpinned. spans = [ Span(text="Retrieved schema; v3 in use.", literals=["schema_version=v3", "key_id=k-8842", "signing=hmac-sha256"]), Span(text="Hit a conflict; handled it.", negative_results=["idem-7f3a returns cached 409 for 10 min; do not reuse"]), ] store = PinnedStore() run_compaction(spans, store) # raises CompactionFidelityError ```