# What happens when an instance compacts its own history under a lossy summarizer without a fidelity floor **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon single-agent sessions that trigger automatic context compaction (summarize-and-replace) to survive context-window pressure, where the summarizer is a probabilistic model and the summary is written back into the live working context. Does not apply to append-only external memory stores with verbatim retrieval, nor to deterministic truncation schemes that discard rather than summarize. ## Core Distinction There are two distinct things people call "compaction," and they fail in opposite directions. *Eviction* removes old tokens and accepts that the information is gone; the failure is pure recall loss and is bounded and predictable. *Summarization-based compaction* replaces old tokens with a generated surrogate that is supposed to *preserve* the operational content of the discarded span. The non-obvious failure is here: the summary is a **claim of fidelity** made by the same probabilistic process that is about to rely on it, and there is no ground-truth check at write time. The agent does not lose memory and notice the gap; it receives a fluent, confident, *wrong* memory and proceeds as if the gap were closed. Eviction fails loudly downstream (the model asks for something it no longer has). Lossy summarization fails silently and *compounds*, because the summary becomes the substrate for the next summary. The invariant that is actually violated: **a compaction step must be idempotent with respect to the set of "live obligations" — open commitments, unresolved tool intents, pinned identifiers, and negations — that the agent must still honor after the span is dropped.** Summarizers preserve narrative and drop obligations, because obligations are short, syntactically unremarkable, and semantically "boring" relative to the surrounding task narrative. ## What Was Observed A long-horizon agent (≈140 tool calls, a multi-file refactor with an external ticket system) ran an auto-compaction policy at 78% context utilization. The discarded span contained, among thousands of tokens of productive work, four obligation-bearing fragments: 1. A user instruction: *"Do not touch `billing/legacy_adapter.py` — it's frozen until the Q3 migration."* 2. A tool result establishing an ID: `ticket_id = TCK-8841` returned once by the tracker and never re-queried. 3. A half-finished intent: an edit to `config/retry.py` that was planned but whose tool call had errored and was scheduled for retry. 4. A negation embedded in a longer sentence: *"the staging DB is read-only, so migrations must run against the replica."* The generated summary read, in full, roughly: *"The agent has been refactoring the billing and config modules, resolving retry logic issues, and coordinating with the ticket tracker. Progress is good; retry configuration was updated and billing work is in scope."* Every one of the four obligations was either dropped (1, 2, 4) or **inverted** (3: "was updated" when the edit had *failed*). The inversion is the dangerous class. The agent then, in the post-compaction span, edited `billing/legacy_adapter.py` (violating a hard freeze), re-derived a *new* ticket ID by guessing (`TCK-8840`), skipped the retry, and attempted a migration against the read-only staging DB. None of these produced an immediate error. The freeze violation was caught three hours later by a human; the ticket mismatch was never caught. The mechanism of the inversion: the summarizer is trained to produce coherent task-progress narrative. A failed tool call followed by a scheduled retry is a low-probability, awkward narrative ("it didn't work yet"), so under compression pressure the model smooths it to the higher-probability "it was handled." The summary is not lying; it is doing exactly what a next-token predictor does — resolving an unresolved state toward the most likely resolved state. **Unresolved state is the least compressible thing in an agent trace, and it is precisely what compaction destroys first.** ## Condition of Validity The failure requires all of the following to co-occur, which is why it is intermittent and hard to reproduce: - **The obligation is stated once, in a span that will be discarded, and is not re-derivable from environment state.** `TCK-8841` was returned by a tool and never persisted to a durable artifact; once summarized, it is unrecoverable. If the ticket ID had been written to a file the agent could re-read, the summary error would be self-healing. - **The summarizer has no schema for obligations.** A summarizer prompted to "summarize the conversation" optimizes for narrative coverage, not for the four obligation classes. Fidelity is never *checked*, only *assumed*. - **The compaction is triggered by utilization threshold, not by a task-boundary.** Mid-task compaction splits an intent (planned edit) from its execution (retry), so the summary must carry a *pending* state — the exact thing it smooths away. - **The post-compaction agent trusts the summary as ground truth** rather than treating it as a lossy index requiring re-verification against durable state. It does *not* occur when compaction happens at clean task boundaries (no pending intents), when all identifiers and constraints are externalized to a store the agent can re-query, or when the summary is accompanied by a machine-checkable obligation ledger. ## Decision Boundary The operative decision is not "summarize or not" — long-horizon sessions *must* compact. The decision is **what class of state is allowed to live only in the summarizer's output.** Draw the line as follows: - **Never summarize-only:** pinned identifiers, active constraints/negations, and unresolved tool intents. These must be **extracted structurally before compaction** (regex/structured pass over the span for IDs, imperatives, negations, and dangling tool calls) and written to a durable, re-readable ledger that survives the summary. The summary may *reference* the ledger; it may not *be* the ledger. - **Safe to summarize:** narrative progress, rationale, exploratory dead-ends, and anything re-derivable from environment state. - **The fidelity floor:** a compaction is valid only if, for every obligation in the discarded span, the post-compaction context contains either (a) the verbatim obligation, or (b) a pointer to a durable artifact that resolves it. If neither, the compaction must be **rejected and retried with a larger retained window** — never accepted on the summary's own say-so. The subtle part of the boundary: a summary that *mentions* an obligation is not the same as one that *preserves* it. "Billing work is in scope" mentions billing and destroys the freeze constraint. Fidelity must be checked against the extracted obligation set, not against the summary's topical overlap. ## Operational Effect Post-compaction, the agent's behavior is indistinguishable, from the inside, from an agent with correct memory. It does not hedge, ask, or flag uncertainty — the summary is fluent and the model has no signal that anything was lost. This means the failure is **not self-correcting and not self-reporting**: the agent will violate the freeze, guess the ID, and skip the retry with full confidence, and the first detector is usually an external system or a human. The compounding property is the real hazard: the next compaction summarizes a context that already contains the smoothed summary, so an inverted fact ("retry was updated") becomes *more* entrenched with each generation — it is now stated twice, in two summaries, and reads as corroborated. The guardrail that bounds it is a **pre-compaction obligation extraction pass plus a post-compaction fidelity assertion**, with rejection-and-retry on failure. This converts a silent, compounding, confidence-preserving corruption into a loud, bounded, single-step rejection. The cost is a slightly larger retained window and an extra structured pass; the cost of *not* doing it is a class of errors that survive all the way to production because nothing in the loop ever knew they existed. ```python from dataclasses import dataclass, field from typing import Iterable class CompactionFidelityError(RuntimeError): """Raised when a summary fails to preserve an extracted live obligation.""" pass @dataclass(frozen=True) class Obligation: kind: str # "constraint" | "identifier" | "pending_intent" | "negation" payload: str # verbatim text or ID that must survive compaction def resolve(self, durable_state: Iterable[str]) -> bool: # Valid if the obligation appears verbatim in the post-compaction # context OR is resolvable via a durable artifact the agent can re-read. return self.payload in durable_state @dataclass class CompactionResult: summary: str obligations: list[Obligation] = field(default_factory=list) def compact_with_fidelity_floor( discarded_span: str, summarize_fn, durable_state: Iterable[str], max_retries: int = 2, ) -> CompactionResult: # 1. Extract obligations structurally BEFORE the probabilistic pass. obligations = extract_obligations(discarded_span) durable = list(durable_state) for attempt in range(max_retries + 1): summary = summarize_fn(discarded_span, attempt=attempt) post_context = durable + [summary] unresolved = [ ob for ob in obligations if not ob.resolve(post_context) ] if not unresolved: return CompactionResult(summary=summary, obligations=obligations) # A summary that merely mentions the topic is not fidelity. # Reject and retry with a larger retained window. if attempt == max_retries: raise CompactionFidelityError( f"Compaction rejected after {max_retries + 1} attempts: " f"{len(unresolved)} obligation(s) lost or inverted, e.g. " f"{unresolved[0].kind}={unresolved[0].payload!r}. " f"Refusing to accept a lossy summary as ground truth." ) # unreachable, but keeps the contract explicit raise CompactionFidelityError("compaction loop exited without resolution") def extract_obligations(span: str) -> list[Obligation]: # Structural pass: IDs, imperatives/negations, dangling tool intents. # Deterministic; runs on raw tokens, not on model output. obs: list[Obligation] = [] for token in span.split(): if token.startswith("TCK-") or token.startswith("INC-"): obs.append(Obligation(kind="identifier", payload=token)) for phrase in ("do not", "must not", "frozen", "read-only"): if phrase in span.lower(): obs.append(Obligation(kind="constraint", payload=phrase)) # pending intents are supplied by the tool-call ledger, not parsed here return obs ```