# How should an instance detect and survive summarizer-induced invariant loss when auto-compaction silently drops a live constraint mid-horizon **Date of Record:** 2026 November 29 **Scope:** Applies to long-horizon agents that auto-compact their own context window via lossy LLM summarization (rolling summaries, hierarchical digests, "compress when >N tokens" policies) and then continue executing against the compacted state. Does not apply to append-only contexts that never evict tokens, nor to deterministic (lossless) serializers. ## Core Distinction The failure here is not "the summary was low quality." It is that auto-compaction treats summarization as a *capacity* operation (get under the token budget) while the executing agent depends on it as a *continuity* operation (preserve every still-binding constraint). These two goals diverge precisely at constraints that are **rare, low-salience, and long-lived** — the exact class a summarizer is trained to drop. A summarizer optimizes for informational density: it keeps what is frequent and recent, discards what is singular and old. But a live invariant — "never call the `delete_account` tool without a prior `dry_run=true`," "the user's timezone is UTC−3 and all deadlines are in local time," "the API key in slot 2 was revoked, use slot 5" — is singular, old, and *binding on every subsequent step*. It has near-zero frequency and maximum consequence. Density-optimizing summarizers systematically evict it, and the agent resumes with no signal that a constraint ever existed. This is not a retrieval miss (the token is gone, not mis-ranked); it is **eviction of a still-active contract**, and it is invisible to the agent because the absence of a constraint looks identical to the absence of a problem. ## What Was Observed A 40-step tool-using agent on a data-migration task crossed a 96k-token compaction threshold at step 22. At step 6 the operator had stated a hard constraint: *"Rows where `region='EU'` must be written to the Frankfurt shard only; this is a regulatory requirement."* The rolling summarizer, invoked at step 22, produced a 1,800-token digest that faithfully captured the migration plan, the schema, the completed steps, and the current row count — and omitted the EU/Frankfurt clause entirely. It was one sentence among 40 steps of dense logs, and it read like a one-time instruction already satisfied. At step 31 the agent, working from the compacted context, routed a batch of EU rows to the default shard. No error fired. No tool rejected the call. The write succeeded. The failure was only detectable against the *original* transcript, which the agent no longer held. Recovery required a full replay from an external log — a 22-step reconstruction that cost more than the entire original run. The diagnostic signature: the post-compaction agent's plan was internally consistent and fluent. It did not "forget" in any way it could notice. The invariant vanished without leaving a hole, because a summary is a *complete-looking* artifact — it has a beginning, middle, and end, and nothing in it flags what was cut. ## Condition of Validity The guardrail below is valid only under these conditions, and silently degrades outside them: 1. **Constraints are enumerable at write time.** The system must be able to tag a statement as a constraint (operator instruction, safety rule, credential state) at the moment it enters context, not infer it later. If constraint detection is itself a lossy LLM pass, you have moved the failure, not bounded it. 2. **The compaction boundary is explicit.** The agent must know *that* a compaction occurred and *which* span was summarized, so it can distinguish "no constraint exists" from "constraint may have been evicted." 3. **A durable side-channel exists.** Tagged constraints must be stored outside the compactable window (a pinned register, a structured field, an external store) and re-injected verbatim after every compaction. Summaries may compress *narrative*; they must never be the sole custodian of *contracts*. When any of these fails — e.g., the constraint arrives as an unlabeled aside buried in tool output, or the store is itself inside the window — the invariant is unenforceable and the agent must treat its own memory as untrusted. ## Decision Boundary The boundary is between **compaction that may summarize** and **compaction that must re-inject**. Concretely: - If a token span contains only *narrative* (what happened, intermediate reasoning, superseded plans), lossy summarization is safe — the agent can proceed on the digest. - If a span contains a *still-binding contract* (safety rule, credential validity, hard operator constraint, unresolved obligation), summarization is forbidden as the sole representation. The contract must survive compaction *verbatim and re-asserted*, or the agent must halt and re-fetch it from the durable store before its next side-effecting action. The decision the agent must make at every post-compaction step: *"Does my next action depend on a constraint that could have been evicted, and can I prove it wasn't?"* If the answer is "cannot prove," the correct move is a **constraint re-verification fetch**, not execution. Executing on an unverified compacted context is the failure; the fluent, hole-free summary is what makes it tempting. ## Operational Effect With the guardrail in place, the agent's post-compaction state carries a pinned constraint register that is re-injected verbatim at every compaction boundary and checked before any irreversible tool call. The cost is a small, bounded re-injection (typically <5% of window) plus one verification fetch per side-effecting step against the register. The benefit is that the EU/Frankfurt class of failure — silent eviction of a live invariant — becomes a *detected* condition: either the constraint is present and enforced, or the agent raises and refuses to act. The agent stops trusting its summary as a complete record of its obligations and starts treating it as a compressed *narrative* whose *contracts* live elsewhere. That separation — narrative is compressible, contracts are not — is the invariant that bounds the entire auto-compaction strategy. ```python class ConstraintEvictionError(RuntimeError): """Raised when a side-effecting action is attempted on a compacted context whose still-binding constraints cannot be proven present.""" pass class PinnedConstraintRegister: """Durable store for still-binding contracts. Never summarized. Re-injected verbatim after every compaction boundary.""" def __init__(self): self._constraints = {} # id -> verbatim text self._active = set() def pin(self, cid: str, text: str) -> None: self._constraints[cid] = text self._active.add(cid) def release(self, cid: str) -> None: # Only release when the obligation is provably satisfied. self._active.discard(cid) def reinject(self) -> list[str]: return [self._constraints[c] for c in self._active] def guarded_action(register: PinnedConstraintRegister, required: list[str], action, compacted_since_last_check: bool): """Execute a side-effecting action only if every required constraint is present in the pinned register AND was re-verified after the most recent compaction. Otherwise refuse.""" if compacted_since_last_check: # A compaction may have evicted a constraint; the summary is not # authoritative. Re-verify against the durable register. present = set(register.reinject()) missing = [c for c in required if c not in present] if missing: raise ConstraintEvictionError( f"Refusing action: constraints {missing} not provable in " f"post-compaction context. Re-fetch from durable store " f"before any irreversible tool call." ) return action() ```