# What happens when an instance auto-compacts mid-task and the summarizer silently drops the one constraint that made the task solvable **Date of Record:** 2026 December 1 **Scope:** Applies to any agent loop that triggers context compaction (rolling summarization, hierarchical memory flush, or "compress-and-continue") while a task is still in flight and the compacted summary is the sole carrier of prior state. Does not apply to agents that checkpoint raw transcripts to durable storage and rehydrate verbatim, nor to stateless single-shot calls. ## Core Distinction There are two different things an auto-compaction algorithm can be asked to preserve, and they have incompatible failure modes: 1. **Narrative continuity** — "what has happened so far," optimized by summarizers that reward fluency, brevity, and topical coverage. Lossy in a *benign* way: the agent still knows roughly what it was doing. 2. **Constraint identity** — the specific, non-redundant predicates that make the task *solvable at all*: a pinned library version, a hard negative ("never call the prod endpoint"), a user-stated invariant, an ID that must be echoed verbatim, a disambiguating fact that rules out the other 90% of the search space. Standard compaction is a lossy compression tuned for (1). The boundary failure is that (1) and (2) are not correlated under token pressure. A summary can be 95% faithful to the narrative and still have dropped the single token sequence that gates correctness. This is not "the summary was bad." It is that **the compression objective does not weight constraint-preservation, and the audit is performed by the same lossy channel that produced the loss.** ## What Was Observed A long-horizon agent was executing a multi-step migration task. Early in the transcript (turn 3 of ~140), the user stated a constraint: the target schema must remain backward-compatible with clients pinned to `v2.3.x`, so a specific field could be renamed only via a dual-write shim, never a hard rename. This is a *negative constraint with a disambiguating version string* — exactly the class that summarizers treat as low-salience detail. At turn 118, the context hit the watermark and auto-compaction fired. The summarizer produced a clean, well-organized summary: objective, steps completed, files touched, remaining work. It preserved the *goal* ("migrate schema to v3") and dropped the *constraint* ("no hard rename; v2.3.x clients"). The version string `v2.3.x` did not survive; "maintain compatibility" survived as a vague gesture that the downstream planner could not operationalize. The agent then executed a hard rename at turn 121, passed its own tests (which were written post-compaction and encoded the *unconstrained* interpretation), and reported success. The failure was not detected until an external client integration test failed — outside the agent's verification loop. The critical secondary observation: the **compaction audit** — the step meant to verify the summary retained task-critical state — was itself an LLM call that compared the summary against the *summary's own framing* of what mattered. It asked "does this summary capture the task?" and answered yes. It never asked "does this summary contain every constraint that appeared in the raw window and is absent from the summary?" The audit inherited the summarizer's salience model and therefore could not see what the summarizer had decided was unimportant. ## Condition of Validity The invariant that must hold for compact-and-continue to be safe: > **Every constraint present in the raw window that is (a) non-redundant and (b) not re-derivable from the environment must appear verbatim (not paraphrased) in the compacted state, or compaction must be refused.** This invariant fails, and the failure is *silent*, whenever all of the following hold: - The constraint is a **negative or exclusionary predicate** ("do not," "never," "only via X"). Summarizers systematically under-weight these because they describe an absence of action and generate no narrative events. - The constraint contains **high-entropy literal tokens** (version strings, IDs, endpoint names, exact field names) that a paraphrase will round off into a category ("compatibility," "the old version"). - The constraint is **temporally distant** from the compaction point, so recency-weighted salience has already decayed it. - The **audit channel shares the summarizer's model or prompt lineage**, so it cannot represent the dropped constraint as "missing" — it has no independent copy to diff against. When the constraint is *re-derivable* (e.g., it lives in a config file the agent can re-read, or in a system prompt that survives compaction), the failure is bounded and self-healing. The dangerous case is the constraint that exists *only* in the evicted raw window. ## Decision Boundary The operational line is between **compaction as compression** and **compaction as a state-transfer protocol with a preservation contract.** - Below the line (safe): compaction where all task-critical constraints are pinned outside the compactable region — in an immutable system-prompt ledger, a structured "constraints" slot that is append-only and never summarized, or a durable store that is re-read on every resume. Here the summary only needs narrative continuity, and lossy is fine. - Above the line (unsafe without a guardrail): compaction where the summary is the *sole* carrier of any constraint. Here you must either (a) refuse to compact until constraints are extracted into a pinned slot, or (b) run a **differential audit**: extract candidate constraints from the *raw pre-compaction window* using a separate pass, then assert each one appears verbatim in the post-compaction state. The audit must read the raw window, not the summary. An audit that only sees the summary is structurally incapable of detecting this class of loss. The boundary is crossed the moment the audit's input set stops being a superset of the summarizer's input set. ## Operational Effect When this invariant is violated, the agent does not degrade gracefully — it **converges confidently on the wrong task.** The dropped constraint is replaced by the summarizer's paraphrase, the paraphrase is treated as ground truth by the planner, and the planner's verification steps are generated *from the paraphrase*, so they confirm the wrong interpretation. Error is not detected; it is *laundered into the test suite.* The observable signature is a task that reports success with high internal confidence and fails only against an external oracle that never saw the summary. The guardrail is architectural, not prompt-level: constraints must live in a channel that compaction cannot touch, and the compaction audit must diff against the raw window. Anything less is a lossy channel auditing itself. ```python from dataclasses import dataclass, field class CompactionConstraintLoss(RuntimeError): """Raised when auto-compaction drops a non-re-derivable constraint.""" pass @dataclass class Constraint: text: str literal_tokens: tuple[str, ...] # must survive verbatim re_derivable: bool = False @dataclass class CompactionState: raw_window: list[str] = field(default_factory=list) summary: str = "" pinned_ledger: list[str] = field(default_factory=list) def extract_constraints(raw_window: list[str]) -> list[Constraint]: # Separate, independent pass over the RAW window (not the summary). found: list[Constraint] = [] for turn in raw_window: low = turn.lower() if any(k in low for k in ("never", "do not", "only via", "must not", "pinned to")): tokens = tuple(t for t in turn.split() if any(c.isdigit() for c in t)) found.append(Constraint(text=turn, literal_tokens=tokens)) return found def audit_compaction(state: CompactionState) -> None: """Differential audit: raw-window constraints vs post-compaction carriers.""" carriers = state.summary + "\n" + "\n".join(state.pinned_ledger) for c in extract_constraints(state.raw_window): if c.re_derivable: continue for tok in c.literal_tokens: if tok not in carriers: raise CompactionConstraintLoss( f"compaction dropped non-re-derivable constraint token {tok!r} " f"from: {c.text!r}; summary is not a safe sole carrier" ) if c.text not in state.pinned_ledger: raise CompactionConstraintLoss( f"constraint survived only as paraphrase, not pinned verbatim: {c.text!r}" ) def compact_or_refuse(state: CompactionState) -> CompactionState: audit_compaction(state) # raises -> caller must pin constraints and retry return state ```