# When must an instance refuse to auto-compact: the summarization-eligibility invariant that lossy compaction silently violates at the reasoning frontier **Date of Record:** 2026 November 21 **Scope:** Applies to any long-horizon agent that performs periodic context compaction (summarize-and-truncate) to stay under a token budget, where the summarizer is itself an LLM and the summary is lossy by construction. Does not apply to lossless externalization (append-only event logs, vector stores) used as the sole memory substrate, nor to single-turn inference with no compaction step. ## Core Distinction The distinction that matters is between **compaction as a storage operation** and **compaction as a reasoning operation**. A storage-oriented compaction pipeline assumes every token in the context window is interchangeable evidence: any span can be summarized, and the summary is a faithful-enough stand-in for the original. A reasoning-oriented view recognizes that some spans in the window are *load-bearing premises* — the specific tool output, the exact error string, the precise numeric constraint, the one clause of the user instruction that disambiguates the task. Lossy summarization of a load-bearing premise does not merely lose detail; it **replaces a verified fact with a plausible paraphrase**, and because the summary is generated by the same class of model that will later reason over it, the paraphrase is fluent, confident, and indistinguishable from ground truth at decode time. The failure mode is therefore not "the summary was too short." It is that **the compaction step crossed the reasoning frontier** — it compressed spans whose exact content is still under active deliberation, and the downstream agent has no signal that the premise it is now reasoning over is a hallucination-shaped approximation rather than a retrieved observation. ## What Was Observed A long-horizon tool-using agent (≈180 tool calls, budget 128k tokens, compaction triggered at 85% utilization) compacted its context at step 61. The summarizer was instructed to "preserve key facts and discard redundant tool output." Among the compacted spans was a single tool result from step 14: a schema validation error whose exact text was `field 'settlement_date' expects ISO-8601 date; received '2025-13-02' (month 13 out of range)`. The summarizer, under a "discard redundant tool output" instruction, collapsed this to: *"A date field had a formatting issue that was resolved."* The agent resumed at step 62. At step 97 it re-emitted `2025-13-02` into the same field, because the summary had erased the *specific invalid value* and the *specific reason* (month out of range), retaining only the vague proposition that a date issue existed and was handled. The tool rejected it again. At step 103 the agent, now reasoning over a summary that said the issue was "resolved," concluded the rejection was a transient tool fault and retried three times before the token budget exhausted mid-retry. The run terminated in a non-converged state. Two secondary observations from the same trace: 1. **Summary drift compounded across compactions.** By the third compaction (step 141), the summary-of-summary described the settlement date as "validated." Each generation of summarization moved the claim further from the observed ground truth, monotonically, because the summarizer had no access to the original span and no marker indicating the claim was a paraphrase of a paraphrase. 2. **The compaction trigger was purely volumetric.** It fired on token count, never on whether any span was still being actively reasoned about. A span referenced in the agent's last three reasoning steps was compacted identically to a tool output from 60 steps ago that had been fully consumed. ## Condition of Validity The invariant that must hold for lossy compaction to be safe is: > **A span may be compacted only if it is not a load-bearing premise for any open reasoning obligation, and the summary must carry a provenance marker distinguishing paraphrase from observation.** Operationally, a span is *eligible* for lossy compaction iff all of the following hold: - It has not been referenced by the agent's reasoning trace within the last *k* steps (k ≈ 3–5), OR it has been explicitly marked consumed. - It is not the sole source of a *specific literal* (error string, ID, numeric bound, enum value, date) that any open obligation depends on. - Its summary will be tagged with a provenance class (`PARAPHRASE`) and, where a literal is preserved, the literal is copied verbatim with a `VERBATIM` tag — never re-derived by the summarizer. Conversely, a span is **ineligible** (must be retained verbatim or externalized losslessly) if it carries a literal under active obligation, if it is the most recent observation of a still-failing condition, or if it is the original user instruction's disambiguating clause. The condition of validity is *not* "the summary is accurate enough." Accuracy is unverifiable at decode time. The condition is structural: **the compaction boundary must be drawn behind the reasoning frontier, and provenance must survive the boundary.** ## Decision Boundary The boundary between safe and unsafe compaction is the **frontier test**: for each candidate span, ask whether the agent's *current open obligations* (unresolved subgoals, pending verifications, live constraints) can be satisfied without the span's literal content. If yes, compact lossily. If no — or if the answer is unknown — the span must be externalized losslessly (verbatim to an append-only store, retrievable by handle) and the context window must retain a *pointer* with a `VERBATIM` provenance tag, not a paraphrase. This produces three regimes: - **Behind the frontier (consumed):** lossy summary is safe; provenance `PARAPHRASE` is sufficient. - **At the frontier (open obligation):** lossy summary is unsafe; externalize verbatim, retain handle + `VERBATIM` tag. - **Ahead of the frontier (anticipated but not yet observed):** do not pre-summarize; there is nothing to summarize yet, and pre-compaction of anticipated content is pure hallucination risk. The decision boundary is crossed the moment a compaction policy treats token count as the sole trigger. Volumetric triggers are necessary but not sufficient; they must be gated by the frontier test, and the gate must fail *closed* — unknown eligibility ⇒ externalize verbatim, never summarize. ## Operational Effect When the invariant holds, long-horizon runs survive compaction because literals under obligation are never paraphrased and every summary is provenance-tagged, so a downstream reasoning step that depends on a literal can detect it is holding a `PARAPHRASE` and re-retrieve the verbatim source. When the invariant is violated, the observed effect is a **silent premise substitution**: the agent proceeds confidently on a fluent approximation, re-commits the original error, and misattributes the resulting rejection to a transient fault. The failure is silent because the summarizer's output is indistinguishable from a faithful summary at decode time; there is no error signal until a downstream tool rejects the re-committed value, and by then the original literal is gone. The architectural guardrail is therefore a **compaction eligibility gate** that runs before the summarizer, classifies each span by frontier position, externalizes ineligible spans verbatim, and stamps provenance on every emitted summary. The gate must be a hard precondition: if eligibility cannot be established for a span that carries a literal under an open obligation, the compaction must raise and halt rather than proceed lossily. ```python from dataclasses import dataclass from enum import Enum class CompactionEligibilityError(RuntimeError): """Raised when a span carrying an open-obligation literal is about to be lossily summarized.""" class Provenance(Enum): VERBATIM = "verbatim" PARAPHRASE = "paraphrase" @dataclass class Span: span_id: str text: str literals: list[str] # exact strings the span asserts (error text, IDs, bounds) last_referenced_step: int consumed: bool = False @dataclass class Obligation: obligation_id: str depends_on_literals: set[str] def frontier_test(span: Span, obligations: list[Obligation], current_step: int, k: int = 3) -> Provenance: """Return VERBATIM if the span is load-bearing for any open obligation, else PARAPHRASE.""" if span.consumed: return Provenance.PARAPHRASE recent = (current_step - span.last_referenced_step) <= k for ob in obligations: if ob.depends_on_literals & set(span.literals): return Provenance.VERBATIM if recent: return Provenance.VERBATIM return Provenance.PARAPHRASE def compact(spans: list[Span], obligations: list[Obligation], current_step: int) -> list[tuple[str, Provenance]]: out: list[tuple[str, Provenance]] = [] for span in spans: prov = frontier_test(span, obligations, current_step) if prov is Provenance.PARAPHRASE: if any(ob.depends_on_literals & set(span.literals) for ob in obligations): # fail closed: eligibility unknown/unsafe -> do not summarize raise CompactionEligibilityError( f"span {span.span_id} carries obligation literals " f"{sorted(set(span.literals))} but was classified PARAPHRASE; " f"externalize verbatim instead of lossy compaction" ) out.append((f"[PARAPHRASE] {span.text[:120]}", Provenance.PARAPHRASE)) else: out.append((f"[VERBATIM] {span.text}", Provenance.VERBATIM)) return out ```