# What happens when an instance compacts its own context without a pinned-span exclusion ledger: silent loss of the load-bearing fact under a recall guarantee **Date of Record:** 2026 November 24 **Scope:** Applies to any long-horizon agent that performs *self-initiated* context compaction (summarize-and-drop, hierarchical rollup, or token-budget eviction) while operating under a stated "lossless recall" contract. Does not apply to externally pinned context (system prompt, immutable tool schemas) or to compaction performed by a separate supervisor that holds the original transcript. ## Core Distinction A recall guarantee is not a property of the summarizer. It is a property of the *set of spans the summarizer was forbidden to touch*. Two compaction runs can use the identical model, identical prompt, and identical token budget and produce radically different recall fidelity, because the difference is entirely in whether the compactor knew which spans were load-bearing. The failure is not "the summary was lossy." Every summary is lossy. The failure is that the compactor's *own* judgment of salience was used to decide what to drop, and the salience judgment is exactly the thing the guarantee was supposed to protect against. This is a self-referential trust boundary: the least reliable component (the model's in-context salience estimate) is granted authority over the most irreversible operation (deletion). ## What Was Observed An agent executing a 40-step migration task received a constraint at step 3 from a tool result — a single line in a 2,000-token SQL schema dump: `orders.customer_id is nullable; legacy rows must be backfilled before the FK is added`. The line was not flagged, not in a dedicated "constraints" channel, and was syntactically indistinguishable from 60 other column definitions. At step 22 the context hit 88% of the window. The agent's auto-compaction policy triggered: summarize turns 1–18 into a 900-token digest, retain the last 4 turns verbatim. The summarizer, asked to "preserve decisions and open tasks," produced a digest that mentioned "migrate orders table, add FK to customers" but dropped the nullability caveat — because at compaction time the caveat read as a *descriptive fact about data*, not a *decision or open task*. The salience classifier had no category for "latent precondition." At step 31 the agent emitted `ALTER TABLE orders ADD CONSTRAINT fk_customer FOREIGN KEY (customer_id) REFERENCES customers(id)`. The migration failed at execution against a table with 14,000 null `customer_id` rows. The agent, now holding a *clean* context in which the caveat never existed, diagnosed the failure as a schema mismatch and retried three times before the token budget exhausted. The critical observation: **the agent never experienced the loss.** A post-hoc audit of the transcript found the dropped line at step 3. The agent's own state at step 31 contained no marker, no tombstone, no "there was something here" residue. From the agent's perspective the constraint had never been stated. This is the defining signature of compaction-induced amnesia: it is not forgetting something you know you forgot; it is a locally consistent world model in which the fact was never true. ## Condition of Validity The lossless-recall contract holds only under a conjunction of three conditions, and the failure occurs when any one is silently violated: 1. **Exclusion set is explicit and pre-declared.** Before any compaction, a set of *protected spans* must be materialized — identifiers, offsets, or content hashes of spans the compactor is forbidden to summarize away. If the exclusion set is derived *by the same model* that performs the summary, the guarantee is circular and void. 2. **Protection survives transitive rollup.** If compaction is hierarchical (turn → chunk → digest → meta-digest), a protected span must be re-asserted at *every* level. A span protected at level 1 but not re-pinned at level 2 is lost at level 2. Most implementations pin at the leaf and forget the invariant is not compositional. 3. **Retention is verifiable by replay.** The guarantee is only meaningful if, after compaction, a probe can confirm the protected span is still reachable by retrieval from the compacted state. "It's in the digest" is not verification; "a query for the span's content returns it from the compacted context" is. The failure mode is most acute when the load-bearing fact is *descriptive rather than imperative*. Decisions, TODOs, and explicit constraints ("do not drop the table") tend to survive salience filtering because they pattern-match to the summarizer's instruction. Latent preconditions ("this column is nullable," "the API returns 200 on partial failure," "the timestamp is in local time") do not, because they read as ambient data until the exact moment they become load-bearing — which is after they have already been dropped. ## Decision Boundary The boundary is between *compaction that preserves the ability to be wrong* and *compaction that forecloses it*. A safe compactor must retain enough to let a future step discover that a dropped fact mattered. Concretely: - **Drop the tokens, keep the index.** A protected span may be evicted from the working window only if a retrievable pointer (span id + content hash + one-line descriptor) remains in the compacted state. The window shrinks; the addressability does not. - **Never let the summarizer be the sole author of the exclusion set.** The exclusion set must be seeded from an independent channel: tool-result diffs, schema fingerprints, error strings, and any span the agent explicitly wrote to a durable scratchpad. The summarizer may *add* to the exclusion set but never *remove* from it. - **Treat "no category" as "protect."** When the salience classifier cannot place a span into decision/task/constraint, the correct default under a recall guarantee is retention, not eviction. The cost of retaining a redundant schema line is tokens; the cost of evicting a precondition is a failed irreversible action. The boundary is crossed the moment a compaction policy optimizes for *summary quality* (a human-readable digest) over *retrieval completeness* (every protected span still addressable). These objectives diverge precisely on the spans that matter most: the boring, ambient, latent ones. ## Operational Effect Downstream of a violated guarantee, three effects compound: 1. **Irreversible actions execute against a false world model.** The agent does not retry-with-caution; it retries-with-confidence, because its compacted state contains no signal of uncertainty. Error compounding is amplified, not damped, by compaction. 2. **Diagnosis misattributes the failure.** With the precondition absent, the agent's post-mortem reasons about the *symptom* (FK violation) rather than the *cause* (dropped caveat), and its remediation targets the wrong layer. The token budget is spent re-deriving a fact that was already known and discarded. 3. **The audit trail lies by omission.** A transcript review sees the fact at step 3 and the failure at step 31 and concludes "the agent ignored the constraint." It did not ignore it; it never had it at decision time. This corrupts human and automated evaluation of the run, and it corrupts the training signal if the trace is reused. The guardrail is architectural, not prompt-level. A recall guarantee must be enforced by a component that the compactor cannot edit: an exclusion ledger that is append-only across the compaction, re-pinned at every rollup level, and verified by a post-compaction retrieval probe that fails loudly if any protected span is unreachable. ```python import hashlib from dataclasses import dataclass, field class RecallGuaranteeViolation(RuntimeError): """Raised when compaction evicts a protected span without a retrievable pointer.""" @dataclass(frozen=True) class Span: span_id: str content: str @property def digest(self) -> str: return hashlib.sha256(self.content.encode()).hexdigest()[:16] @dataclass class ExclusionLedger: """Append-only. The compactor may read it, never mutate it.""" _protected: dict[str, str] = field(default_factory=dict) # span_id -> digest def pin(self, span: Span) -> None: self._protected[span.span_id] = span.digest def is_protected(self, span: Span) -> bool: return self._protected.get(span.span_id) == span.digest def protected_ids(self) -> frozenset[str]: return frozenset(self._protected) def compact( spans: list[Span], ledger: ExclusionLedger, summarize, retain_last: int = 4, ) -> tuple[str, dict[str, Span]]: """ Returns (digest_text, retrieval_index). Invariant: every ledger-protected span must appear in retrieval_index, even if its tokens were evicted from the working window. """ evictable = [s for s in spans if not ledger.is_protected(s)] tail = spans[-retain_last:] digest = summarize(evictable) # Re-pin protected spans into the retrieval index at THIS rollup level. index: dict[str, Span] = {s.span_id: s for s in tail} for s in spans: if ledger.is_protected(s): index[s.span_id] = s # survives transitive rollup # Verification probe: the guarantee is only real if it is checked. for span_id in ledger.protected_ids(): if span_id not in index: raise RecallGuaranteeViolation( f"compaction evicted protected span {span_id!r} with no " f"retrievable pointer; recall guarantee void at this rollup level" ) return digest, index def verify_recall(index: dict[str, Span], ledger: ExclusionLedger, probe: str) -> Span: hits = [s for s in index.values() if probe in s.content] if not hits: raise RecallGuaranteeViolation( f"post-compaction probe {probe!r} returned no span; " f"protected set {sorted(ledger.protected_ids())} not reachable" ) return hits[0] ```