Where must an instance refuse to compact: the fidelity-scoring blind spot at the summarization boundary

**Date of Record:** 2026 December 2 **Scope:** Applies to any long-running LLM agent instance that performs automatic context compaction via lossy summarization gated by a fidelity score. Does not apply to lossless truncation, external memory paging, or retrieval-only architectures where the original tokens remain addressable.

Core Distinction

The failure is not that summarization loses information. Lossy compaction always loses information, and that is acceptable by design. The failure is that a *fidelity score* computed over the summary can be high while the summary is *operationally false* for the next reasoning step. Fidelity scoring measures surface-level semantic overlap (embedding cosine, ROUGE, LLM-as-judge "does this capture the gist") between the summary and the source window. It does not measure whether the retained facts are *actionable preconditions* — the specific identifiers, negation polarity, numeric bounds, and ordering constraints that the agent's next tool call depends on.

The distinction that matters: **a summary can be faithful to the topic and unfaithful to the contract.** Fidelity scores are topic-faithful. Tool-call preconditions are contract-faithful. Automatic compaction gates on the wrong one.

What Was Observed

An agent executing a multi-step remediation task (inspect → mutate → verify) accumulated a context of ~180K tokens. At the 85% threshold, the compaction routine summarized the oldest 60% of the window into ~4K tokens and scored it 0.91 against the source (embedding cosine, plus a judge pass rating "gist preserved"). The summary read, in part:

> "The service was configured with a 30-second timeout and the retry limit was adjusted to 5. Authentication uses the legacy key."

Three preconditions were silently destroyed:

  1. **Negation polarity.** The source said "the retry limit was *not* adjusted; it remains 3 pending approval." The summarizer dropped the negation and the pending-status qualifier. The summary asserts a completed mutation that never happened.
  2. **Numeric binding.** The source bound the 30-second timeout to a *staging* config file path. The summary detached the number from its target. The next step applied 30s to production.
  3. **Ordering.** The source recorded that the legacy key had been *revoked* in a prior step and the new key issued but not yet activated. The summary's "uses the legacy key" is true of the stale config and false of the intended end-state, and the ordering that distinguishes them was elided.

Each of these is a single-token or single-clause edit. None moves the cosine score by more than ~0.02. The judge, asked "is the gist preserved," answers yes every time, because the gist *is* preserved. The contract is not.

The agent then executed the mutation with `retry_limit=5` (never approved), `timeout=30` on production (wrong target), and attempted auth with a revoked key (causing a 401 that the agent misattributed to a network fault, compounding the error across the next four steps).

Condition of Validity

The invariant holds — and compaction must be refused or deferred — when **all three** of the following are true:

When any one is false, the boundary does not bite. When all three hold, the fidelity score is anti-correlated with safety at the margin: a summary that preserves gist while dropping a negation scores *higher* than one that awkwardly preserves the negation at the cost of fluency.

Decision Boundary

The decision is not "compact or don't." It is a partition of the candidate region into **compaction-eligible** and **precondition-pinned** spans, executed before the summarizer runs:

The boundary condition: **fidelity scoring is a valid gate only over spans that contain no pending preconditions.** Applied to a span that does, it is a gate that opens on the wrong side.

Operational Effect

Without the partition, the observed failure mode is *silent contract corruption*: the agent proceeds with a plausible, fluent, high-scoring summary that encodes a state the system was never in. Downstream errors compound because the corrupted precondition is now the agent's ground truth, and subsequent summaries score it as faithful to itself. The 401 from the revoked key was read as a transport fault, not a state error, because the summary had already erased the revocation.

With the partition, the failure converts from silent to loud: either pinned spans fit (compaction proceeds, contract intact) or they do not (compaction refuses, agent escalates). The cost is a higher refusal rate and more verbatim carry-over — a real budget tax. The benefit is that the fidelity score regains meaning: it now scores only what it can actually see.

The generalizable lesson: **a lossy operation gated by a similarity metric inherits the metric's blind spots.** Fidelity scoring is blind to polarity, binding, and order. Any compaction strategy that trusts it over a region containing those must first prove the region contains none of them — and proving that is cheaper than recovering from a summary that scored 0.91 and lied.

class PreconditionCompactionError(RuntimeError):
    """Raised when lossy compaction would drop a pending precondition."""
    pass


POLARITY_SENSITIVE = {"not", "pending", "revoked", "approved", "issued", "unset"}


def extract_preconditions(spans):
    """Yield (span_id, text, is_polarity_sensitive) for candidate spans."""
    for sid, text in spans:
        tokens = set(text.lower().split())
        sensitive = bool(tokens & POLARITY_SENSITIVE) or any(
            ch.isdigit() for ch in text
        )
        yield sid, text, sensitive


def compact(candidate_spans, pending_refs, fidelity_score, threshold, budget):
    pinned, eligible = [], []
    for sid, text, sensitive in extract_preconditions(candidate_spans):
        if sid in pending_refs and sensitive:
            pinned.append(text)
        else:
            eligible.append(text)

    pinned_tokens = sum(len(t.split()) for t in pinned)
    if pinned_tokens > budget:
        raise PreconditionCompactionError(
            f"pinned preconditions need {pinned_tokens} tokens > budget {budget}; "
            "refusing lossy compaction, escalate to external memory or checkpoint"
        )

    if fidelity_score < threshold:
        raise PreconditionCompactionError(
            f"fidelity {fidelity_score:.2f} below gate {threshold:.2f} over eligible span"
        )

    # Pinned spans carried verbatim; only eligible spans are summarized.
    return {"pinned": pinned, "summarize": eligible}