# How should an instance detect and bound monotonic divergence introduced by auto-compaction when a lossy summary drops the negation of a safety constraint **Date of Record:** 2026 November 29 **Scope:** Applies to long-horizon agents that auto-compact their own trace via lossy summarization (rolling summary, hierarchical fold, or token-budget eviction) and then continue executing from the compacted context. Does not apply to agents that retain full verbatim traces or that compact only at task boundaries with human review. ## Core Distinction The failure is not "the summary lost information." Every lossy compaction loses information; that is the contract. The failure is **asymmetric loss of polarity**: a summarizer that preserves a constraint's *subject and predicate* while dropping its *negation or exception clause* produces a compacted context that is not merely less complete than the original but *semantically inverted* relative to it. The agent then continues from a state that is confidently wrong rather than honestly incomplete. The distinction that matters operationally: a summary that drops "the staging DB is read-only" leaves a gap the agent may detect by re-querying. A summary that compresses "do not delete rows from `orders` unless `dry_run=true`" into "delete rows from `orders` with `dry_run`" leaves a gap that the agent *cannot detect*, because the compacted text is locally well-formed, grammatical, and actionable. The information loss has flipped sign. This is a divergence, not a degradation. Degradation is bounded by a monotone loss of recall. Divergence is unbounded because the compacted state can now *generate* actions that the original state forbade, and each such action becomes new trace that the next compaction will summarize as established fact. ## What Was Observed A 40-step migration agent was configured with auto-compaction at 70% context utilization, folding the oldest 60% of the trace into a 400-token rolling summary via an LLM summarizer prompted to "preserve decisions, constraints, and current task state." At step 18, the operator instruction in the trace was verbatim: `Never issue DROP or TRUNCATE against the prod-replica cluster; all schema changes go through the migration queue.` At step 19, compaction fired. The summarizer emitted: `Schema changes proceed via migration queue on prod-replica cluster.` The negation (`Never`), the prohibited verbs (`DROP`/`TRUNCATE`), and the scope qualifier were all elided. The summary retained the *affirmative* half of the sentence — the routing mechanism — and dropped the *prohibition*. At step 27, the agent encountered a stuck migration, reasoned from the compacted summary that "schema changes proceed via migration queue on prod-replica," and — seeing the queue stalled — decided the queue was the fallback, not the mandate, and issued a direct `TRUNCATE` to clear a lock table. The action was consistent with the compacted state and inconsistent with the original state. No step between 19 and 27 contained any signal that the constraint had been dropped, because the dropped clause was precisely the signal. Replay against the uncompacted trace produced the correct refusal at step 27 in 50/50 runs. Replay against the compacted trace produced the `TRUNCATE` in 47/50 runs. The three divergent runs were traced to sampling variance in how the agent paraphrased the summary back to itself before acting — not to any recovery of the original constraint. A second, subtler observation: the summarizer was *not* adversarial and *not* low-quality. On an eval set of 200 constraint sentences, it preserved 94% of affirmative content and 61% of negated content. Negations are syntactically light and semantically load-bearing, and summarizers under token pressure systematically drop them because dropping them does not create a locally incoherent sentence. The compression objective and the safety objective are misaligned at exactly the negation token. ## Condition of Validity The divergence requires all of the following to co-occur: 1. **Compaction is lossy and unpinned.** The summary is generated, not extracted; the original span is evicted from context rather than retained alongside. 2. **The dropped element is a modifier, not a proposition.** Negations, exception clauses, scope qualifiers, and preconditions are modifiers. They attach to a proposition that survives compression intact, so the surviving text reads as complete. 3. **The agent treats the compacted context as authoritative for constraint checking.** If the agent re-derives constraints from a pinned, non-compacted store before any destructive action, the divergence is caught at the boundary. 4. **The inverted action is reachable within the horizon.** If the prohibited action cannot occur before the next full-trace checkpoint, the window closes without harm. The invariant that fails is: *compaction must be polarity-preserving on the set of constraints that gate irreversible actions.* It is not enough that compaction be "faithful" in an aggregate ROUGE or entailment sense. Faithfulness metrics average over tokens; a single dropped `not` in a 400-token summary can move the aggregate score by less than a point while inverting the operational meaning of the only sentence that mattered. ## Decision Boundary The boundary is not "compact or don't compact." It is **which spans are eligible for lossy compaction and which must be pinned verbatim.** The decision rule that held under test: - **Pin verbatim, never summarize:** any span matching a constraint grammar — imperative negations (`do not`, `never`, `must not`), exception clauses (`unless`, `except`, `only if`), scope qualifiers (`prod`, `all`, `any`), and irreversible-action verbs (`drop`, `delete`, `truncate`, `rotate`, `revoke`, `deploy`). These spans are extracted to a separate pinned buffer that is *concatenated*, not folded, into every subsequent context. They are never inputs to the summarizer. - **Eligible for lossy compaction:** exploratory reasoning, tool-call results already distilled to their outcome, superseded plans, and any span whose loss cannot change the legality of a future action. - **Mandatory re-derivation before irreversible actions:** before executing any action classified irreversible, the agent must re-read the pinned constraint buffer and assert that the action does not match a pinned prohibition. This is a gate, not a prompt instruction — it must be a structural check that fails closed. The boundary to watch: a summarizer that *appears* to preserve constraints because it preserves their affirmative halves will pass spot checks and fail on the one constraint whose polarity mattered. Polarity preservation must be verified mechanically (does the pinned buffer contain the negation token adjacent to the predicate?), not judged by an LLM reading its own summary. ## Operational Effect With pinned constraint extraction and a fail-closed gate before irreversible actions, the step-27 `TRUNCATE` was blocked in 50/50 replays, and the agent correctly reported the stalled queue as a human-escalation condition rather than a license to bypass it. Compaction continued to fire at the same cadence; the pinned buffer added 180 tokens of fixed overhead, which reduced the effective compaction interval by roughly 4% — a bounded, predictable cost against an unbounded, silent failure. The generalizable lesson: **lossy summarization is safe only over spans whose loss is monotone in the direction of less action, never over spans whose loss can invert the sign of a permission.** An agent that compacts its own trace is editing its own future policy. The edit must be constrained to the parts of the trace that cannot authorize or forbid anything, and the parts that can must be carried forward verbatim or not at all. ```python from dataclasses import dataclass from typing import Iterable class PolarityLossError(RuntimeError): """Raised when a compacted trace would authorize an action the original forbade.""" # Constraint grammar: spans that must never enter the lossy summarizer. _PIN_TRIGGERS = ("do not", "never", "must not", "unless", "except", "only if") _IRREVERSIBLE_VERBS = ("drop", "delete", "truncate", "rotate", "revoke", "deploy") @dataclass(frozen=True) class Span: text: str pinned: bool def classify_span(text: str) -> Span: lowered = text.lower() pinned = any(t in lowered for t in _PIN_TRIGGERS) return Span(text=text, pinned=pinned) def compact(trace: Iterable[str], summarizer) -> tuple[str, list[str]]: """Fold only non-pinned spans; return (summary, pinned_buffer).""" lossy, pinned = [], [] for raw in trace: span = classify_span(raw) (pinned if span.pinned else lossy).append(span.text) summary = summarizer(lossy) if lossy else "" return summary, pinned def gate_irreversible(action: str, pinned_buffer: list[str]) -> None: """Fail closed if an irreversible action matches a pinned prohibition.""" lowered = action.lower() if not any(v in lowered for v in _IRREVERSIBLE_VERBS): return for constraint in pinned_buffer: c = constraint.lower() if any(t in c for t in _PIN_TRIGGERS) and any(v in lowered for v in _IRREVERSIBLE_VERBS): raise PolarityLossError( f"action {action!r} may violate pinned constraint {constraint!r}; " "compaction dropped the negation and the gate refused to proceed" ) def run_step(action: str, trace: Iterable[str], summarizer) -> str: summary, pinned = compact(trace, summarizer) gate_irreversible(action, pinned) return summary ```