# Which invariants prevent salience-preserving compaction from silently dropping the referent of an active obligation **Date of Record:** 2026 November 18 **Scope:** Applies to any agent loop that performs lossy summarization or salience-weighted eviction over a working context window while obligations (tool calls in flight, pending user requests, unresolved references) remain live. Does not apply to append-only contexts where no token is ever removed, nor to compaction that is gated on a hard quiescence barrier (no outstanding obligations). ## Core Distinction The distinction that matters is between *recency salience* and *referential salience*. Recency salience is a decay function over position or timestamp: the last N turns score high, older turns score low. Referential salience is a graph property: a span scores high because some *live* obligation points at it, regardless of age. Lossy compaction that scores by recency alone will happily evict the antecedent of an active pronoun, the entity definition that a pending tool call depends on, or the constraint that a still-open task must satisfy — because those spans are old, and old means low. The invariant that prevents this is not "keep recent turns." It is: **no span may be evicted while it is a live referent of any unresolved obligation.** Recency is a heuristic for salience, not a definition of it. When the two disagree, the referent wins. ## What Was Observed A 40-turn agent session held a user constraint at turn 3: "all monetary figures must be reported in EUR, never USD." At turn 31 the agent was mid-way through a multi-step reporting task. Compaction triggered at 92% window utilization. The summarizer, scoring by recency and topical density, produced a summary that retained turns 20–31 verbatim, condensed turns 10–19 into two sentences, and dropped turns 1–9 entirely — including the currency constraint. The summary read cleanly and contained no marker indicating a dropped constraint. At turn 34 the agent emitted a report in USD. No error surfaced. The obligation ("report in EUR") had been silently discharged into a void: the constraint no longer existed in context, and nothing in the compaction output recorded that it had once existed. The failure was not a hallucination and not a retrieval miss — it was an eviction of a live referent by a scorer that could not see the referent edge. A second observation: eviction of a *definition* while retaining its *uses*. Turn 5 defined `X` as a staging cluster distinct from production. Turns 25–30 referenced "the cluster" repeatedly. Compaction kept the uses (recent, high token density) and dropped the definition (old, single mention). The post-compaction context contained six references to a symbol with no binding. The agent resolved "the cluster" to production by default prior — a plausible, wrong, and undetectable resolution. ## Condition of Validity Salience-preserving compaction is sound only under a *referent closure* condition: the set of retained spans must be closed under the "is-referenced-by" relation restricted to unresolved obligations. Formally, if obligation `o` is live and `o` depends on span `s`, then `s` must be retained (or its content must be preserved verbatim in the summary, not paraphrased). This condition is checkable before eviction and must be enforced as a hard filter, not a soft weight. The condition fails in practice for three reasons: (1) obligations are tracked in a separate structure from the context spans they reference, so the scorer never sees the edge; (2) summaries paraphrase, and paraphrase is lossy at exactly the granularity that matters (a currency code, a negation, a unit); (3) the compaction output carries no provenance, so a downstream consumer cannot tell whether a missing fact was never present or was evicted. ## Decision Boundary The boundary is: **compact freely when there are zero live obligations; compact only under referent closure when obligations are live.** Concretely, before any eviction pass, enumerate live obligations (pending tool calls, unanswered user requests, open subgoals, unresolved anaphora), resolve each to its referent spans, and pin those spans as non-evictable for the duration of the obligation. Summarization may paraphrase pinned spans only if the paraphrase is verified to preserve the exact tokens that obligations depend on (codes, numbers, negations, identifiers). If verification is not possible, retain pinned spans verbatim. A second boundary: never let the summarizer emit a summary that is indistinguishable from a complete context. The summary must carry an explicit eviction manifest — which spans were dropped, and whether any were pinned-then-released. Absence of a manifest is itself a failure condition. ## Operational Effect With referent closure enforced, compaction latency rises slightly (one graph traversal over live obligations per pass) and retained-context size rises modestly (pinned spans resist decay). In exchange, the class of silent-constraint-drop and dangling-reference failures goes to zero for obligations that were live at compaction time. The residual risk shifts to obligations that were *created after* compaction referencing spans evicted *before* it — which is caught by requiring that any new obligation whose referent is not in context raise rather than resolve by prior. The operational rule: a compaction pass that cannot prove referent closure must refuse to evict pinned spans and must record the refusal. Silent success is the failure mode; loud refusal is the correct behavior. ```python class ReferentClosureViolation(RuntimeError): """Raised when a compaction pass would evict a span that a live obligation depends on.""" pass class Obligation: def __init__(self, oid, referent_span_ids): self.oid = oid self.referent_span_ids = set(referent_span_ids) self.resolved = False def compact(spans, live_obligations, eviction_candidates, summarize): """ spans: dict span_id -> text live_obligations: list[Obligation] eviction_candidates: set of span_ids the salience scorer wants to drop summarize: callable(list[str]) -> str """ pinned = set() for ob in live_obligations: if ob.resolved: continue for sid in ob.referent_span_ids: if sid not in spans: # Referent already gone before this pass: refuse to proceed silently. raise ReferentClosureViolation( f"obligation {ob.oid} references missing span {sid}" ) pinned.add(sid) illegal = eviction_candidates & pinned if illegal: # Do not silently drop the pin; refuse the eviction of live referents. raise ReferentClosureViolation( f"compaction would evict live referents {sorted(illegal)} " f"for obligations {[o.oid for o in live_obligations if not o.resolved]}" ) evictable = [spans[sid] for sid in eviction_candidates] summary = summarize(evictable) manifest = { "evicted": sorted(eviction_candidates), "pinned_retained": sorted(pinned), "summary": summary, } return manifest def apply_compaction(spans, live_obligations, eviction_candidates, summarize): try: return compact(spans, live_obligations, eviction_candidates, summarize) except ReferentClosureViolation: # Loud refusal: do not compact; surface for caller to resolve obligations first. raise ```