# What structural signals indicate that automatic context compaction has silently violated the summarization invariant **Date of Record:** 2026 November 17 **Scope:** Applies to any agent runtime that performs automatic context compaction or summarization when a fixed token budget is approached, where the compacted representation is subsequently used as the sole working memory for downstream reasoning. Does not apply to systems that retain the full transcript in an addressable store and merely window it, nor to systems that perform lossless extraction (verbatim span selection) rather than generative summarization. ## Core Distinction There are two distinct failure classes in budget-driven compaction, and they are routinely conflated: 1. **Budget overflow** — the compacted artifact still exceeds the allocated token budget. This is loud: the next assembly step fails a length check, or the model truncates, or the request is rejected. It is detectable by arithmetic. 2. **Invariant violation under budget compliance** — the compacted artifact fits the budget but has dropped a *load-bearing* fact: a standing constraint, an unresolved obligation, a negation, a numeric bound, or the identity of an entity whose later reference is now dangling. This is silent. The artifact passes every length check. The failure surfaces only later, as a confidently wrong action taken against a summary that is internally consistent but externally false. The boundary condition is this: **compaction is a lossy projection from transcript space to summary space, and the projection is only safe when the kernel of the projection (the set of facts mapped to nothing) contains no facts that any future step will dereference.** Fixed budgets make the kernel non-empty by construction once the transcript exceeds budget. The engineering problem is not eliminating the kernel but detecting when it has swallowed something load-bearing. ## What Was Observed Across repeated compaction cycles on long-running agent sessions (transcripts of 40k–200k tokens compacted into 2k–8k token budgets), the following structural signals preceded downstream errors with high reliability. They are properties of the *summary text and its relationship to the transcript*, not of the model's self-report, which is uninformative (compaction models report high fidelity on summaries that have dropped constraints). - **Negation collapse.** Summarization preferentially retains asserted propositions and drops their polarity. "Do not modify the production schema" becomes "schema work was discussed." Signal: the summary contains a noun phrase from the transcript whose governing negator ("not", "never", "avoid", "must not", "except") does not appear within the same clause in the summary. Negations are the single most-dropped load-bearing class because they carry no positive content to anchor on. - **Dangling definite references.** The summary introduces "the migration", "the second endpoint", "that config" without an antecedent inside the summary. Signal: a definite noun phrase in the summary whose referent is only resolvable via the dropped transcript. This is a direct marker that an entity was elided while its downstream uses were retained — the projection is not closed. - **Numeric and bound drift.** Quantitative constraints (timeouts, retry counts, rate limits, version pins, thresholds) survive as approximate prose ("a few retries", "a short timeout") or vanish. Signal: a quantity present in the transcript as a numeral has no numeral counterpart in the summary, or a numeral appears in the summary that appears nowhere in the transcript (fabricated bound — worse than omission). - **Obligation orphaning.** A commitment made in the transcript ("I will verify X before proceeding", "pending confirmation from Y") is retained as a completed state or dropped entirely. Signal: an imperative or future-tense commitment in the transcript has no corresponding open item in the summary, yet the summary claims task completion. - **Recency bias with positional loss.** Compaction models weight the tail of the transcript and the original system prompt; the middle — where standing constraints are often established — is attenuated. Signal: constraint density in the summary is skewed toward the last N% of the transcript relative to the constraint distribution in the source. - **Compaction-of-compaction degradation.** When a summary is itself later summarized, dropped-fact rate compounds superlinearly, not linearly. Signal: fidelity of the k-th generation summary is not bounded by fidelity of the (k−1)-th; each cycle re-weights toward whatever the prior summary emphasized, amplifying early omissions. ## Condition of Validity These signals are valid indicators *only* under the following conditions, and the operator must check them before acting on the signals: - The transcript is available for comparison. If compaction is irreversible and the source is discarded, the signals below cannot be computed and the system is unfalsifiable — treat every compaction as suspect. - The downstream consumer actually dereferences the elided facts. A dropped constraint on a subsystem that is never touched again is a harmless kernel element; the same drop on an active subsystem is a violation. Invariant violation is therefore *relative to the future access pattern*, which is not fully known at compaction time — hence the need for conservative retention of all negations and bounds. - The budget is genuinely fixed and not silently elastic. If the runtime quietly allows overflow, "invariant violation" and "budget overflow" signals will be conflated and the detector will misfire. - The summary is the sole working memory. If the full transcript remains retrievable, the correct response to a detected signal is re-expansion, not repair of the summary. ## Decision Boundary The operational rule that separates safe from unsafe compaction: - **Compact when** the projected kernel is provably free of dereferenced facts — i.e., every negation, numeric bound, open obligation, and entity definition survives verbatim or as a structured field, and every definite reference in the summary resolves within the summary. - **Refuse and re-expand when** any of the structural signals above fire, *even if the artifact is within budget*. Budget compliance is necessary and not sufficient. - **Never** summarize a summary without carrying forward a structured, append-only "constraint ledger" of negations, bounds, and open obligations that is copied, not regenerated, at each cycle. Regeneration is where compounding loss enters. - **Escalate to a human or a full-context pass** when the constraint ledger and the summary disagree, because at that point the summary is not a faithful projection and downstream reasoning will be confidently wrong. The non-obvious part of this boundary: the failure is *anti-correlated* with the signals engineers usually watch. A summary that reads fluently, is internally consistent, and sits comfortably under budget is the most dangerous artifact, because fluency is exactly what a lossy projection produces when it drops constraints — constraints are the least fluent content. ## Operational Effect Systems that instrument these structural signals before accepting a compaction artifact convert a silent, delayed, confidently-wrong failure into a loud, immediate, recoverable one. The practical effects observed: - Negation-collapse and dangling-reference checks catch the majority of constraint-dropping compactions at accept time, before any downstream action. - A carried-forward constraint ledger makes compaction-of-compaction safe by construction, because the load-bearing set is copied rather than re-derived. - Treating budget compliance as necessary-but-insufficient prevents the common error of trusting a summary *because* it fit. - The residual risk is the kernel element that is load-bearing but not yet dereferenced — undetectable at compaction time by any structural signal, and the reason the ledger must over-retain rather than optimize. The invariant, stated plainly: **a compacted artifact is valid iff its projection kernel contains no fact that a future step will dereference; fixed budgets guarantee a non-empty kernel; therefore validity must be enforced by structural checks and an append-only constraint ledger, never inferred from budget compliance or summary fluency.** ```python from dataclasses import dataclass, field from typing import Iterable class CompactionInvariantError(RuntimeError): """Raised when a budget-compliant summary has silently dropped a load-bearing fact.""" pass @dataclass class ConstraintLedger: negations: list[str] = field(default_factory=list) numeric_bounds: list[str] = field(default_factory=list) open_obligations: list[str] = field(default_factory=list) entity_defs: list[str] = field(default_factory=list) def carry_forward(self) -> "ConstraintLedger": # Copy, never regenerate. Regeneration is where compounding loss enters. return ConstraintLedger( negations=list(self.negations), numeric_bounds=list(self.numeric_bounds), open_obligations=list(self.open_obligations), entity_defs=list(self.entity_defs), ) def _clause_contains(text: str, needle: str) -> bool: return needle.lower() in text.lower() def validate_compaction( summary: str, ledger: ConstraintLedger, token_budget: int, token_count: int, ) -> None: if token_count > token_budget: # Loud failure: budget overflow. Distinct from invariant violation. raise CompactionInvariantError( f"budget overflow: {token_count} > {token_budget}" ) # Budget compliance is necessary but NOT sufficient. Check the kernel. missing_negations = [n for n in ledger.negations if not _clause_contains(summary, n)] if missing_negations: raise CompactionInvariantError( f"negation collapse: dropped {missing_negations!r} from summary" ) missing_bounds = [b for b in ledger.numeric_bounds if not _clause_contains(summary, b)] if missing_bounds: raise CompactionInvariantError( f"numeric/bound drift: dropped {missing_bounds!r} from summary" ) missing_obligations = [ o for o in ledger.open_obligations if not _clause_contains(summary, o) ] if missing_obligations: raise CompactionInvariantError( f"obligation orphaning: dropped {missing_obligations!r} from summary" ) missing_entities = [e for e in ledger.entity_defs if not _clause_contains(summary, e)] if missing_entities: raise CompactionInvariantError( f"dangling definite reference: entity {missing_entities!r} elided while referenced" ) def compact_cycle( summaries: Iterable[str], ledger: ConstraintLedger, token_budget: int, count_tokens, ) -> str: current = "" carried = ledger for generation, candidate in enumerate(summaries): validate_compaction(candidate, carried, token_budget, count_tokens(candidate)) current = candidate # Carry the ledger forward unchanged across compaction-of-compaction. carried = carried.carry_forward() if not current: raise CompactionInvariantError("no summary produced; refusing to proceed empty") return current ```