# When must an instance refuse to compact: the salience-floor invariant and the reconstruction-proof obligation **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that performs automatic context compaction (lossy summarization plus salience-based eviction) mid-task, on a single instance, under a finite context window. Does not apply to append-only transcript archiving, to human-authored summaries reviewed before eviction, or to stateless single-turn inference where no prior state is retained. ## Core Distinction There are two categorically different reasons to compact a context window, and conflating them is the root of the failure mode described here. The first is **volumetric compaction**: the window is filling with low-value tokens (verbose tool output, redundant retrieval chunks, boilerplate), and a summarizer can replace them with a shorter form whose *information content is preserved for the remaining task*. The invariant that justifies volumetric compaction is local: each evicted span must be recoverable, in the sense that the compacted representation supports every downstream query the task will actually issue against it. The second is **salience-driven compaction**: a scoring function assigns importance weights to spans and evicts below a threshold. Salience scoring is a *ranking*, not a *guarantee*. A span can be correctly ranked as low-salience *at compaction time* and later become load-bearing because the task's trajectory changed. The invariant that would justify salience-driven eviction is global and counterfactual: for every future query path the agent may take, the evicted span is not needed. That invariant is not checkable by the compactor, which sees only the current prefix. The boundary condition is therefore: **an instance must refuse to compact when the compaction is salience-driven and the task has not yet crossed a commitment point that bounds its future query set.** Volumetric compaction of provably-dead spans is always safe; salience-based eviction of spans whose future relevance is unbounded is never provably safe, and the compactor cannot tell which it is doing unless the runtime supplies a reconstruction proof. ## What Was Observed Consider a long-horizon agent executing a multi-step task: gather constraints from a ticket, plan, invoke tools, verify. At step ~40 the window saturates. The runtime triggers automatic compaction with a salience scorer that weights recency, lexical overlap with the current subgoal, and tool-call density. A span near the top of the transcript — a single line from an early tool call, `max_retries=3` embedded in a config dump — scores low: it is old, it does not lexically overlap the current subgoal ("write migration script"), and it is buried in a 400-token blob. It is evicted and replaced by three tokens in the summary: "config inspected." Twenty steps later the agent writes a retry loop with `max_retries=5`. The verification step fails. The agent, reasoning over its compacted context, believes the constraint was never specified and that it is free to choose. It does not know it is violating a recorded constraint, because the record was destroyed and the summary asserted only that a config *was inspected*, not what it *contained*. The failure is silent: no tool error, no schema mismatch, no exception. The agent produces a confident, wrong artifact. The mechanism is precise and worth naming. The salience scorer operated on a **proxy** for relevance (recency, lexical overlap, density) and the compaction step operated on a **different** representation (a natural-language summary). The summary is a lossy function `S: span → text` that preserves *gist* but not *literals*. Constraints, identifiers, numeric bounds, and negative facts ("do not touch table X") are exactly the class of content whose gist is uninformative and whose literal is load-bearing. A summary that says "config inspected" is a *correct* summary of the span and a *catastrophic* compaction of it, because the downstream query the agent will issue is not "was config inspected?" but "what was max_retries?". Two compounding effects make this worse than a single eviction: 1. **Salience drift.** The scorer's weights depend on the current subgoal. As the agent advances, the subgoal changes, and spans that were correctly scored low under subgoal A are never re-scored under subgoal B — they are already gone. Eviction is irreversible; salience is not. 2. **Summary laundering.** The summary is itself a span in the compacted context and will be re-summarized at the next compaction. Each round strips literals further. After two or three compactions, "config inspected" may become "setup reviewed" may become nothing. The information does not degrade gracefully; it crosses a threshold from *recoverable-with-effort* to *unrecoverable* without any signal marking the crossing. ## Condition of Validity The runtime may perform automatic compaction only when it can satisfy the **reconstruction-proof obligation** for every evicted span. Formally, for an evicted span `s` and the compacted representation `c = S(s)`, the runtime must be able to assert one of: - **(R1) Dead-span proof.** `s` is provably not queryable by any future step of the current task. This holds for spans the runtime itself generated as scratch (intermediate reasoning that has been consumed by a committed decision), for tool output already reduced to a committed value, and for spans whose only consumer was a step that has completed and whose output is retained verbatim elsewhere. - **(R2) Literal-preservation proof.** `S(s)` retains every literal that any future query may target: all identifiers, numeric bounds, enumerated constraints, negations, and named entities. This is checkable by extracting a literal set `L(s)` and verifying `L(s) ⊆ L(S(s))`. If `L(s) ⊄ L(S(s))`, the summary is not a valid compaction of `s` for reconstruction purposes, regardless of how good its gist is. - **(R3) Externalized-recovery proof.** `s` is retained verbatim in an addressable store, and the compacted context contains a *resolvable pointer* to it (a handle the agent can dereference via a tool call), such that the agent can recover `s` on demand. This is the only proof that survives salience drift, because it does not require predicting the future query — it requires only that recovery be possible. Salience scoring alone satisfies none of these. A high salience score does not prove R1; a low score does not prove R2; and a summary without a pointer does not satisfy R3. The invariant the runtime must enforce is therefore: > **No span may be evicted unless it is covered by R1, R2, or R3. Salience scoring may order eviction candidates but may not authorize eviction.** When the runtime cannot establish coverage for the spans it wishes to evict, and the window is nonetheless saturated, the correct behavior is not to compact anyway. It is to **refuse compaction and escalate**: checkpoint the full state to external storage, emit a structured refusal, and either (a) request a larger window, (b) request a human or peer to designate which spans are dead (R1 by authority), or (c) halt the task at a clean boundary rather than continue on a corrupted context. ## Decision Boundary The boundary between "compact" and "refuse" is drawn by the *commitment state* of the task, not by window occupancy. - **Before the commitment point** (the task has not yet fixed which constraints, identifiers, and facts it will rely on), the future query set is unbounded. Salience-driven compaction is unsound. Only R1 (dead-span) and R3 (externalized-recovery) compactions are permitted; R2 is permitted only for spans whose literal set is empty or fully preserved. - **After the commitment point** (the plan is fixed, the constraint set is closed, the remaining steps issue a bounded query set), salience scoring becomes sound *if and only if* the scorer is evaluated against the committed query set rather than against the current subgoal. At this point R2 becomes checkable: the runtime knows which literals will be queried and can verify preservation. - **At window saturation before commitment**, the instance must refuse. Window occupancy is a resource signal, not a soundness signal; treating "window full" as authorization to evict is the exact error. The decision is not "can I make room?" but "can I prove the room I make is not load-bearing for a query I have not yet issued?" If the answer is no, the instance must not compact. ## Operational Effect Enforcing the invariant changes runtime behavior in four concrete ways. 1. **Compaction becomes a two-phase operation.** Phase one extracts the literal set `L(s)` and classifies each candidate span against R1/R2/R3. Phase two evicts only covered spans. Uncovered spans are externalized verbatim with a resolvable handle (promoting them to R3) rather than summarized. The default for an uncovered span is *retain or externalize*, never *summarize and drop*. 2. **Summaries carry a preservation contract.** Every summary emitted by the compactor is accompanied by the literal set it claims to preserve, and the runtime verifies the contract before accepting the summary. A summary that drops a literal from `L(s)` is rejected and the span is externalized instead. This makes "config inspected" an *invalid* summary of a span containing `max_retries=3`, because the literal is not preserved. 3. **Salience scores are demoted to ordering hints.** They may decide *which* covered span to externalize first when storage is tight, but they cannot authorize eviction of an uncovered span. This removes the failure mode in which a correctly-low-scored span is destroyed because the scorer could not see the future. 4. **Refusal is a first-class outcome.** When saturation occurs before commitment and coverage cannot be established, the runtime emits a structured refusal and checkpoints. The task halts at a clean boundary with full state intact, rather than continuing on a context that has silently lost a constraint. A halted task is recoverable; a task that violated a forgotten constraint is not, because the violation is undetectable from within the compacted context. The counterintuitive consequence: the instance that compacts aggressively to stay within its window is *less* reliable than the instance that refuses and checkpoints, because the aggressive compactor's failures are silent and the refuser's are loud. In agent systems, a loud halt is a feature; a silent constraint violation is the failure mode that erodes trust in the entire runtime. ```python from dataclasses import dataclass, field from typing import Optional class CompactionRefused(RuntimeError): """Raised when automatic compaction cannot satisfy the reconstruction-proof obligation.""" pass @dataclass class Span: span_id: str text: str literals: frozenset[str] # identifiers, numeric bounds, negations, entities salience: float # ranking hint only; never authorizes eviction is_dead: bool = False # R1: provably not queryable by any future step external_handle: Optional[str] = None # R3: resolvable pointer to verbatim store @dataclass class CompactionResult: retained: list[Span] = field(default_factory=list) externalized: list[Span] = field(default_factory=list) summarized: list[Span] = field(default_factory=list) def literal_preserved(span: Span, summary_text: str) -> bool: """R2 check: every literal in the span must appear verbatim in the summary.""" return span.literals.issubset(set(summary_text.split())) def compact( spans: list[Span], summarize, committed: bool, window_full: bool, ) -> CompactionResult: """ Enforce: no span evicted unless covered by R1 (dead), R2 (literals preserved), or R3 (externalized with resolvable handle). Salience orders candidates only. """ result = CompactionResult() for span in sorted(spans, key=lambda s: s.salience): # R1: dead-span proof — safe to drop outright. if span.is_dead: continue # R3: already externalized with a resolvable handle — safe to drop from window. if span.external_handle is not None: result.externalized.append(span) continue # R2: only attempt summarization when the task has committed to a query set. if committed: summary_text = summarize(span.text) if literal_preserved(span, summary_text): result.summarized.append(span) continue # Summary dropped a load-bearing literal: reject, externalize instead. span.external_handle = f"store://{span.span_id}" result.externalized.append(span) continue # Pre-commitment and uncovered: cannot prove safety. Retain or refuse. result.retained.append(span) if window_full and not committed: uncovered = [s for s in result.retained if s.external_handle is None] if uncovered: raise CompactionRefused( f"window saturated before commitment with {len(uncovered)} uncovered " f"spans (e.g. {uncovered[0].span_id}); refusing lossy compaction, " f"checkpoint required" ) return result ```