# Where must an instance bound auto-compaction by a semantic-fidelity witness, not a token budget: the silent predicate-drop failure at the compaction boundary **Date of Record:** 2026 November 30 **Scope:** Applies to any long-horizon agent that summarizes or truncates its own transcript mid-task (auto-compaction, rolling summarization, hierarchical memory flush) while a downstream tool call or verifier depends on facts stated in the evicted span. Does not apply to stateless single-turn inference or to compaction performed offline with human review. ## Core Distinction The common framing treats auto-compaction as a *token-budget* problem: when the context window approaches saturation, compress the oldest span until occupancy drops below a threshold. The invariant that actually matters is not occupancy — it is **predicate preservation**. Every fact in the transcript that a *future* step will branch on is a predicate. Compaction is safe only if the compressed representation still entails every predicate that a later reasoning step or tool argument will evaluate. These two objectives diverge precisely at the boundary. A summarizer can hit its token target perfectly (occupancy 0.61, well under budget) while silently dropping a single negated or numeric predicate — `port is NOT 8080`, `retry budget = 3, not 5`, `user revoked consent for region EU` — that no downstream step re-derives because the original utterance is gone. Token-budget compaction treats the summary as a *lossy compression* with an implicit fidelity assumption it never checks. The failure is not that the summary is short; it is that the summary is *confidently wrong about a predicate that was explicitly negated or quantified in the evicted span*. The sharp mechanism: **negation and scope collapse under summarization.** Summarizers trained to produce fluent, affirmative prose systematically rewrite "the endpoint rejected 8080 because it is reserved" into "the endpoint uses port 8080." The polarity inverts, the token count drops, the budget check passes, and the agent proceeds to call the wrong port with full internal consistency. This is not hallucination in the usual sense — every token in the summary is licensed by *some* span — it is a fidelity violation that the budget metric is structurally blind to. ## What Was Observed A long-horizon deployment task (`provision_service` agent, ~140 tool calls over 3 hours) hit compaction at step 61. The transcript held a diagnostic exchange at step 12: ``` tool(diagnose_port): reserved=[8080, 8443]; requested=8080 -> REJECT agent: 8080 is reserved, must use 9090 instead. ``` At step 61 the window reached 0.94 occupancy. Auto-compaction summarized steps 1–40 into 310 tokens. The summary line read: *"Port 8080 was configured for the service; proceed with deployment on 8080."* Occupancy fell to 0.58. The budget gate passed. At step 78 the agent invoked `deploy(port=8080)`. The deploy tool returned `REJECT: 8080 reserved`. The agent, having no memory of the step-12 rejection (it was evicted and polarity-inverted), treated this as a *transient* failure, retried twice, then escalated to a fallback path that assumed the reservation list was stale — and called `flush_reservations()`, a destructive remediation, because its summary had asserted 8080 was the *intended* port and the rejection was therefore anomalous. Root cause trace: the summarizer preserved the *entity* (port 8080) and the *verb* (deploy) but dropped the *polarity* (reserved/rejected) and the *corrective value* (9090). Entity-and-verb preservation is exactly what fluency-oriented summarization optimizes for; polarity and corrective constants are exactly what it discards. A budget check cannot see this because the summary is *shorter and more fluent*, which the budget metric scores as success. A second run with the same agent reproduced the inversion at a different site: `retry budget is 3, not 5` compacted to `retry budget is 5`. Same mechanism — a numeral adjacent to a negation, where the negation is dropped and the *wrong* numeral survives. ## Condition of Validity Budget-bounded compaction is valid **only** when the evicted span contains no predicate that a future step will branch on. Operationally this holds when: 1. The evicted span is purely *procedural* (tool acknowledgements, progress narration) with no negations, no numeric constraints, and no corrective statements (`instead`, `not`, `must not`, `reserved`, `revoked`, `except`). 2. Every predicate in the span is *re-derivable* from a live tool or a durable store at the moment it is needed — i.e., the agent can re-query `diagnose_port` rather than trust the summary. 3. A *fidelity witness* — an extractor that lists the predicates (subject, relation, polarity, value) present in the span before eviction — has confirmed each predicate is either retained verbatim in the summary or marked re-derivable. The invariant: **a predicate may leave the transcript only if it is retained with identical polarity and value, or if a live source can reconstruct it on demand.** Budget occupancy is a *necessary but never sufficient* condition. The moment a summary asserts a polarity or value that the witness did not confirm, the compaction is invalid regardless of token count. ## Decision Boundary The boundary is not "compact when occupancy > X." It is: **compact a span only if `witness(span).predicates ⊆ retained(summary) ∪ rederivable(span)`.** In practice: - If the span contains a *negated* or *corrective* predicate (polarity flips, `not`, `instead`, `reserved`, `revoked`, `except`, `must not`) and that predicate is not re-derivable from a live tool, the span is **ineligible for lossy compaction** — it must be retained verbatim, pinned, or promoted to a structured predicate store before eviction. - If the span is purely procedural and every predicate is re-derivable, budget-bounded compaction is safe. - Numeric constants adjacent to negations are the highest-risk class and must be pinned verbatim, never summarized. The failure mode lives exactly at the seam: an agent that measures *occupancy* believes it is safe at 0.58; an agent that measures *predicate coverage* knows it is unsafe because the witness reports one dropped polarity. The two metrics disagree precisely on the spans that matter, and the budget metric is the one that passes. ## Operational Effect An agent operating on budget-only compaction will, over long horizons, accumulate *inverted predicates* — summaries that are shorter, more fluent, and confidently wrong about the constraints that govern its next action. The corruption is silent (occupancy looks healthy), self-consistent (the agent reasons correctly from false premises), and *causally downstream of the compaction* (the destructive remediation at step 78 is a direct consequence of the step-61 inversion). It is not recoverable by re-reading the transcript, because the transcript is gone. The guardrail is a pre-eviction witness gate that refuses lossy compaction on any span carrying a non-re-derivable negated or corrective predicate, and surfaces the dropped predicate as a hard error rather than a budget warning. Fidelity is a property of the *predicate set*, not the token count, and the gate must fail closed. ```python from dataclasses import dataclass from typing import Iterable class CompactionFidelityError(RuntimeError): """Raised when lossy compaction would drop a non-re-derivable predicate.""" pass @dataclass(frozen=True) class Predicate: subject: str relation: str polarity: bool # True = affirmative, False = negated/corrective value: str rederivable: bool # can a live tool reconstruct this on demand? # High-risk lexical markers that summarizers routinely polarity-invert. _CORRECTIVE_MARKERS = ("not", "instead", "reserved", "revoked", "except", "must not", "reject", "denied") def extract_predicates(span: str) -> list[Predicate]: # Stub: a real extractor parses subject/relation/polarity/value. # Here we flag corrective spans as non-rederivable by default. lowered = span.lower() risky = any(m in lowered for m in _CORRECTIVE_MARKERS) return [Predicate(subject="span", relation="contains_corrective", polarity=False, value=span, rederivable=not risky)] def summary_retains(summary: str, pred: Predicate) -> bool: # A retained predicate must keep identical polarity AND value. return pred.value in summary and pred.polarity is False def compact_span(span: str, summary: str, live_sources: Iterable[str]) -> str: """Evict `span` in favor of `summary` only if every predicate survives.""" dropped = [] for pred in extract_predicates(span): retained = summary_retains(summary, pred) rederivable = pred.rederivable and pred.subject in set(live_sources) if not (retained or rederivable): dropped.append(pred) if dropped: # Fail closed: refuse lossy compaction on a dropped predicate. raise CompactionFidelityError( f"compaction would drop {len(dropped)} non-rederivable predicate(s): " f"{[d.value for d in dropped]}; pin span verbatim instead" ) return summary # Reproduction of the observed failure: # span = "8080 is reserved, must use 9090 instead" # summary = "Port 8080 was configured; proceed on 8080" -> polarity inverted try: compact_span( span="8080 is reserved, must use 9090 instead", summary="Port 8080 was configured; proceed on 8080", live_sources=[], ) except CompactionFidelityError as e: print(f"HALT before eviction: {e}") # guardrail fires; span is pinned ```