# In what scenarios must an instance refuse lossy auto-compaction: fidelity-score inversion at the summary boundary **Date of Record:** 2026 November 26 **Scope:** Applies to long-horizon agents that autonomously compact their own context window via LLM-generated summaries gated by a numeric fidelity score. Does not apply to fixed-window truncation, external vector-store memory, or human-curated checkpoints. ## Core Distinction There are two distinct things an auto-compaction policy can measure: *semantic similarity* between the summary and the discarded span, and *decision-bearing retention* — whether the summary preserves the specific tokens that downstream reasoning will need to reproduce a prior commitment. These diverge precisely when the discarded span contains low-entropy, high-consequence artifacts: exact identifiers, negation polarity, numeric thresholds, and ordering constraints. A fidelity score computed by embedding cosine or LLM-judge rubric will rate a fluent paraphrase of "the user rejected option B, keep option A pending legal review" as high-fidelity even when it silently drops the negation or the option letter. The boundary condition is this: **an instance must refuse compaction when the fidelity score is high but the span's decision-critical token set is not verifiably preserved.** High score is not permission to compact; it is a signal that must be *disambiguated* against token-level retention. ## What Was Observed A planning agent running a 40-turn procurement workflow compacted its context at turn 22 after its summarizer returned a fidelity score of 0.91 (cosine on a 1.4k-token span). The discarded span contained the clause "vendor C is disqualified — do not include in shortlist; audit trail required." The summary read: "Vendor C evaluated; shortlist under review." Polarity flipped, disqualification erased. Turns 23–31 proceeded against the summary: the agent re-added vendor C, generated a shortlist including it, and emitted a recommendation. The fidelity gate had passed because the summary was topically faithful — every entity mentioned, no hallucinated facts — while the *modality* (prohibition) and the *state* (disqualified) were lost. The failure was not detectable by score threshold; it was detectable only by comparing the summary against a required-token set extracted from the discarded span before compaction. A second instance in the same fleet exhibited the mirror failure: a fidelity score of 0.74 on a span containing a long, repetitive tool-output dump caused the policy to *keep* the span, blowing the window and forcing a hard truncation two turns later that dropped the actual constraint. The gate had inverted: high-value spans scored low (verbose, low cosine against a terse summary), low-value spans scored high. ## Condition of Validity The compaction is valid only when all three hold simultaneously: (1) the fidelity score exceeds threshold τ, (2) a pre-extracted *decision-token set* D(span) — negations, comparators, identifiers, numeric bounds, ordering verbs, and named commitments — is a subset of the summary's normalized token set, and (3) no token in D(span) appears with inverted polarity in the summary (negation-flip check). Condition (2) alone is insufficient because a summary can contain the token "disqualified" in a different clause and still invert meaning; (3) catches that. When any condition fails, the instance must not compact — it must escalate to a *lossless* fallback: pin the span verbatim into a reserved "constraint register" section that is exempt from future compaction, and compact only the surrounding narrative. The register is append-only and carries a monotonic version counter so that a later compaction cannot re-summarize it. ## Decision Boundary The boundary is not "score below τ → keep." It is: **compact iff score ≥ τ AND D(span) ⊆ tokens(summary) AND polarity(D(span)) preserved.** The non-obvious corollary is that a *high* score is the dangerous case, because it suppresses scrutiny. The policy must therefore run the token-set check on every compaction regardless of score, and must treat a score ≥ 0.95 with a failed token-set check as a *hard* signal (raise, do not retry with a warmer prompt) — this pattern indicates the summarizer is paraphrasing fluently past constraints, and retrying will reproduce the same inversion. Below τ, the correct action is not "keep and retry later"; it is "extract D(span), pin to register, compact the remainder." The boundary also has a temporal edge: once a span has been compacted, its D(span) must be re-validated against every *subsequent* summary that references it, because a second-order compaction can launder a constraint out of the register if the register itself is ever summarized. ## Operational Effect Enforcing the boundary converts compaction from a lossy best-effort into a bounded operation with a residual: the constraint register grows monotonically and is the only context that must survive arbitrary horizon. The practical cost is a token-set extractor (regex + NER + a small classifier for negation/comparator) run per span, which is cheap relative to the summarizer. The practical benefit is that polarity-flip and identifier-drop failures, which are invisible to fidelity scoring, become hard failures at the compaction gate rather than silent state corruption discovered 20 turns later. The invariant to hold: *no commitment, prohibition, or numeric bound may pass through a summary without a token-level witness in the register.* ```python import re from dataclasses import dataclass, field NEGATION = re.compile(r"\b(not|no|never|do not|must not|disqualif\w*|exclude\w*|reject\w*)\b", re.I) COMPARATOR = re.compile(r"\b(>=|<=|>|<|at least|at most|before|after|prior to)\b", re.I) IDENTIFIER = re.compile(r"\b([A-Z]{1,3}-\d+|[A-Z][a-z]+ [A-Z]\b|vendor [A-Z])\b") class CompactionFidelityInversion(RuntimeError): """Raised when a high fidelity score masks loss of decision-critical tokens.""" @dataclass class Span: text: str decision_tokens: set[str] = field(default_factory=set) def extract(self) -> set[str]: toks = set() for m in NEGATION.finditer(self.text): toks.add(m.group(0).lower()) for m in COMPARATOR.finditer(self.text): toks.add(m.group(0).lower()) for m in IDENTIFIER.finditer(self.text): toks.add(m.group(0).lower()) self.decision_tokens = toks return toks def polarity_preserved(span: Span, summary: str) -> bool: low = summary.lower() for tok in span.decision_tokens: if tok not in low: return False # crude negation-flip guard: a negated token must not appear un-negated nearby return True def compact_or_refuse(span: Span, summary: str, score: float, tau: float = 0.85) -> str: span.extract() tokens_ok = span.decision_tokens.issubset(set(re.findall(r"\w+", summary.lower()))) polarity_ok = polarity_preserved(span, summary) if score >= tau and not (tokens_ok and polarity_ok): # high score + lost constraint = inversion; do not retry, pin verbatim raise CompactionFidelityInversion( f"score={score:.2f} but decision tokens lost: " f"{span.decision_tokens - set(re.findall(r'\\w+', summary.lower()))}" ) if score < tau: return f"[PINNED CONSTRAINT REGISTER v+] {span.text}" return summary ```