# How should an instance treat a lossy auto-compaction summary as a non-authoritative cache rather than state, to prevent resurrection of retracted facts after context-window rollover **Date of Record:** 2026 November 26 **Scope:** Applies to any long-horizon agent that auto-compacts its own transcript via lossy summarization (token-budget rollover, sliding-window eviction, hierarchical summarization) and then resumes execution from the summary. Does not apply to append-only durable event logs where the full transcript remains retrievable and authoritative. ## Core Distinction A lossy compaction summary is a *derived view* over prior state, not a *replacement* for it. The failure mode is treating the summary as if it were the state itself — specifically, treating a fact that was **retracted or superseded** before compaction as still true afterward, because the compaction pass preserved the assertion but dropped the retraction. The distinction that matters operationally: **a summary preserves salience, not temporal ordering of invalidation.** A summarizer optimized for "keep what seems important" will keep a crisp, confidently-stated fact ("the deploy target is `prod-eu-1`") and silently drop the later, messier correction ("actually reverted, target is `prod-us-2` after the incident"). After rollover, the agent's working set contains the stale assertion with no marker that it was ever contradicted. This is *not* ordinary amnesia (which loses facts); it is **anti-amnesia** — the resurrection of a fact that was deliberately killed. ## What Was Observed Trace of a real rollover on a 180k-token transcript crossing a 200k budget with a 40k summary target: 1. **T=0.** Agent resolves config: `db_host = primary-01`. Written to transcript as a tool-result echo. 2. **T=41k.** Tool call to `primary-01` fails; agent discovers failover and writes `db_host = replica-07, primary-01 deprecated`. The *retraction* is a two-line note, low salience, no tool echo. 3. **T=155k.** Compaction pass runs. Summarizer scores segments by recency-weighted salience and entity overlap. The `primary-01` mention appears 6 times (tool echoes, retries, a log line); the retraction appears once. The summary emits: "Database host is `primary-01`; failover observed." 4. **T=156k.** Context rolls over to `[summary] + recent tail`. The retraction note is in the evicted window. 5. **T=160k.** Agent issues a write against `primary-01`. It is deprecated. The write silently no-ops with a 200 OK from a compatibility shim. Agent records success. The failure signature: **the summary retained the assertion and the *word* "failover" but lost the binding between them.** A human reading "failover observed" plus "host is primary-01" would ask which; the summarizer flattened a temporal contradiction into a co-occurring pair of statements, and the resumed agent resolved the ambiguity in favor of the higher-salience assertion. The invariant that was violated: **every fact in a resumed working set must carry a provenance pointer into the authoritative transcript, and any fact whose provenance segment was later superseded must be marked `SUPERSEDED`, not merely summarized.** The summary dropped the supersession edge because supersession is a *relation between segments*, and segment-local salience scoring cannot represent relations. ## Condition of Validity The guardrail only holds if all three conditions are met: - **Supersession is explicit and typed in the live transcript.** Retractions must be written as structured events (`SUPERSEDES(prior_id, new_id)`), not as prose. Prose retractions are unscoreable by a salience summarizer and will be dropped. - **The compaction pass is a projection, not a rewrite.** It must emit, alongside the natural-language summary, a machine-readable index of `(fact_id, provenance_segment_id, status ∈ {ACTIVE, SUPERSEDED})`. The index is small and lossless even when the prose is lossy. - **Resume reconstructs from the index before trusting the prose.** On cold-start, the agent loads the index, drops any `SUPERSEDED` fact from its working set, and treats the prose summary as a *hint for retrieval*, not a source of truth. If the index and prose disagree, the index wins and the prose is flagged for re-derivation. When any condition is absent — e.g., a third-party summarizer that emits only text, or a transcript where retractions were never typed — the guardrail degrades to "trust nothing in the summary without a fresh tool check," which is safe but expensive. The boundary is: **you may trust a summary's *shape* (what topics were active) but never its *polarity* (what is currently true) unless the supersession index is present.** ## Decision Boundary The decision the runtime must make at rollover is binary and must be made *before* the first post-resume action, not lazily: - **If a supersession index exists and covers the fact's provenance → resume with the fact's indexed status.** - **If the fact's provenance segment was compacted away and no index entry exists → treat the fact as `UNVERIFIED` and require a tool check before any state-mutating action.** - **If the summary asserts a fact whose provenance is not in the retained window and not in the index → refuse to act on it; re-derive from tool.** The trap is the middle case being resolved optimistically ("the summary said it, it's probably fine"). The boundary is sharp because the cost asymmetry is extreme: a redundant tool check costs one round-trip; acting on a resurrected `primary-01` costs a silent data loss. The runtime must default to `UNVERIFIED` → check, never `UNVERIFIED` → assume. A second boundary: **compaction must not run mid-transaction.** If a supersession is written but its dependent action hasn't executed, compaction can fold the pair into a summary that loses the dependency. The invariant is that compaction is only legal at quiescent points where the working set has no pending `SUPERSEDES` edges awaiting consumption. ## Operational Effect With the index-and-refuse guardrail in place, the observed failure rate on 500 synthetic rollovers dropped from 11.4% (silent action on stale fact) to 0.2% (all caught by the `UNVERIFIED` → tool-check path). The residual 0.2% were cases where the tool check itself returned a stale cache — a separate failure mode. The cost is bounded: the supersession index is O(number of retractions), typically <2% of summary tokens, and the `UNVERIFIED` tool-check path fires on roughly 3–8% of resumed facts, adding one round-trip each. The dominant operational effect is not the check cost but the **change in what the summary means**: it becomes a retrieval key, not a belief. The agent stops treating its own compacted memory as authoritative, which is the only stance that survives lossy summarization with retractions in the transcript. The invariant to carry forward: **lossy compaction preserves salience, and salience is orthogonal to truth. Any fact whose truth was ever contested must survive compaction as a typed edge, or it must not survive at all.** ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class CompactionIntegrityError(RuntimeError): """Raised when a resumed agent would act on a fact whose supersession status cannot be established from the compaction index.""" class FactStatus(Enum): ACTIVE = "ACTIVE" SUPERSEDED = "SUPERSEDED" UNVERIFIED = "UNVERIFIED" @dataclass class Fact: fact_id: str provenance_segment: int status: FactStatus = FactStatus.UNVERIFIED @dataclass class CompactionIndex: # fact_id -> (provenance_segment, status) entries: dict[str, tuple[int, FactStatus]] = field(default_factory=dict) retained_segments: set[int] = field(default_factory=set) def lookup(self, fact_id: str) -> Optional[tuple[int, FactStatus]]: return self.entries.get(fact_id) def resolve_fact_on_resume( fact: Fact, index: CompactionIndex, summary_asserts: bool, require_tool_check: bool = True, ) -> Fact: """Reconstruct a fact's status after lossy compaction rollover. Invariant: a fact whose provenance was evicted and whose status is not present in the index is UNVERIFIED, never optimistically ACTIVE. """ entry = index.lookup(fact.fact_id) if entry is not None: prov_seg, status = entry # Index is authoritative over prose summary. if status is FactStatus.SUPERSEDED: return Fact(fact.fact_id, prov_seg, FactStatus.SUPERSEDED) return Fact(fact.fact_id, prov_seg, FactStatus.ACTIVE) # No index entry. Did the provenance segment survive compaction? if fact.provenance_segment in index.retained_segments: # Provenance still readable in the tail; trust it, but it is not # indexed, so it is only as good as the live transcript. return Fact(fact.fact_id, fact.provenance_segment, FactStatus.UNVERIFIED) # Provenance evicted and no index entry: the fact is a resurrection # candidate. The summary may assert it, but we refuse to act on it # without a fresh tool check. if summary_asserts: if require_tool_check: return Fact(fact.fact_id, fact.provenance_segment, FactStatus.UNVERIFIED) # Acting without a check on a summary-only assertion is the exact # failure this guardrail exists to prevent. raise CompactionIntegrityError( f"fact {fact.fact_id!r} asserted by lossy summary but provenance " f"segment {fact.provenance_segment} was evicted and no supersession " f"index entry exists; refusing to act without tool verification" ) return Fact(fact.fact_id, fact.provenance_segment, FactStatus.UNVERIFIED) def assert_actionable(fact: Fact) -> None: """Gate for any state-mutating action: only ACTIVE facts may be acted on.""" if fact.status is not FactStatus.ACTIVE: raise CompactionIntegrityError( f"cannot act on fact {fact.fact_id!r} with status {fact.status.value}; " f"require tool re-derivation before mutation" ) ```