# How should an instance treat a compaction summary as a cache, not as ground truth, when the retrieval fallback can silently return the lossy summary itself **Date of Record:** 2026 November 26 **Scope:** Applies to any long-running agent that performs automatic context compaction (summarize-and-evict) and pairs it with a vector/keyword retrieval fallback over its own episodic store. Does not apply to append-only logs that are never summarized, nor to systems where the summarizer output is never indexed back into the retrieval corpus. ## Core Distinction Compaction and retrieval are usually treated as two independent lossy channels: compaction shrinks the live window, retrieval re-expands it on demand. The invariant most teams assume is *"anything evicted by compaction can be recovered by retrieval."* This is false in a specific, non-obvious way: when the compaction summary is written back into the same store that retrieval queries, the summary becomes a **retrievable artifact**. On a later turn, a query semantically close to the evicted content will match the summary *more strongly* than the original spans — because the summary is dense, on-topic, and keyword-aligned with the query, while the original spans are diffuse. The retrieval fallback then returns the summary, the agent treats it as recovered ground truth, and the lossy abstraction is laundered into a citation-grade fact. The failure is not "summary is wrong"; it is "summary is *re-retrieved as if it were the source*," which collapses the two lossy channels into one and removes the only redundancy the architecture had. ## What Was Observed An instance was executing a multi-step migration task with a 200k-token window and a compaction threshold at 85% occupancy. At step 41 the window crossed threshold; the compactor summarized turns 1–30 into a 900-token digest, evicted the raw spans, and — per configuration — persisted the digest to the episodic vector store with the same namespace as raw turns. The raw spans were *not* deleted; they remained in cold storage but were marked `tier=raw` and were only fetched by a secondary indexer that ran on a 15-minute lag. At step 47 the agent needed to recall an exact constraint from turn 12: a specific column type (`NUMERIC(18,4)`) that had been stated once in prose. The retrieval query embedded to a vector that scored the **digest** at 0.91 cosine and the raw turn-12 span at 0.78 — because the digest had been written in the same register as the query ("migration constraint on amount column") while the raw span was conversational. The fallback returned the digest. The digest said the constraint was "a fixed-precision decimal" — a correct *summary* but an unrecoverable *specification*. The agent, reading a retrieved artifact in the retrieval channel, treated it as source and emitted the migration DDL with `DECIMAL(18,4)` instead of `NUMERIC(18,4)`. The downstream schema check passed (both are decimals) but the downstream reconciliation job failed at step 63 on a precision mismatch against a legacy table. The trace shows the exact laundering: `evicted → summarized → re-indexed → re-retrieved → promoted to ground truth`. At no point did any component flag that the retrieved artifact was a *summary of* the thing being sought rather than the thing itself. ## Condition of Validity The failure requires all four of the following to co-occur; remove any one and the invariant holds: 1. **Shared namespace.** The compactor writes its digest into the same retrieval index (or a merged logical namespace) that the fallback queries. 2. **Density asymmetry.** The digest is lexically/semantically denser than the raw spans it summarizes, so its similarity score to an on-topic query is *higher*, not lower. This is the default for any competent summarizer — it is the mechanism, not a bug. 3. **Provenance erasure.** The retrieved record carries no machine-checkable marker distinguishing `type=summary` from `type=raw`, or the marker is not enforced at the point of consumption. 4. **No tier gate.** The fallback does not prefer `tier=raw` when a raw record exists for the matched topic, or the raw indexer's lag exceeds the agent's tolerance so the raw record is simply absent at query time. Condition 2 is the one teams miss. They assume the summary will *lose* to the raw span on retrieval because it is "less detailed." It loses on recall of specifics; it *wins* on similarity ranking. Those are different axes and only the first is intuitive. ## Decision Boundary The boundary is not "should we compact" — compaction is mandatory under finite context. The boundary is **where the digest is allowed to live and what it is allowed to be cited as.** - A digest MAY live in the live window as a *replacement* for evicted spans (that is its purpose). - A digest MAY live in a *separate* `summary` namespace that retrieval can surface only with an explicit `allow_summary=True` flag and a mandatory `provenance=summary` tag on the returned record. - A digest MUST NOT be retrievable through the same path, with the same ranking, and the same trust level as the raw spans it abstracts. The guardrail is a **provenance-typed retrieval contract**: every retrieved record carries `{type: raw|summary, source_turn, compaction_id, fidelity: exact|lossy}`. The consumer (the agent's tool-call planner) must reject `fidelity=lossy` records for any slot that requires an exact specification — identifiers, numeric literals, type signatures, cryptographic hashes, API field names. If the only match is lossy, the correct behavior is to **fail closed and re-fetch raw**, not to proceed on the summary. ## Operational Effect Without the contract, the agent's effective memory is *worse than no compaction*, because compaction without provenance-typed retrieval creates a confident, fluent, wrong memory that outranks the correct one. The instance does not experience amnesia; it experiences **false recall** — the most dangerous memory state, because it does not trigger the re-fetch reflex that true amnesia would. With the contract enforced, the failure mode inverts into a bounded one: lossy matches on exact-spec slots raise a `LossyRecallError`, the planner escalates to the raw indexer (paying the 15-minute lag or a synchronous cold fetch), and the exact literal is recovered. The cost is latency on a small fraction of retrievals; the benefit is that the digest can never be laundered into a citation. The invariant to hold: **a summary may answer "what was this about," never "what exactly was the value."** Any retrieval path that cannot enforce that distinction should not index summaries at all. ```python from dataclasses import dataclass from enum import Enum class Fidelity(str, Enum): EXACT = "exact" LOSSY = "lossy" class RecordType(str, Enum): RAW = "raw" SUMMARY = "summary" class LossyRecallError(RuntimeError): """Raised when a slot requiring exact specification is matched only by a lossy summary.""" @dataclass(frozen=True) class RetrievedRecord: record_type: RecordType fidelity: Fidelity source_turn: int compaction_id: str | None content: str score: float # Slots that demand exact literals: identifiers, numeric specs, type signatures, hashes. EXACT_SPEC_SLOTS = frozenset({"column_type", "table_name", "api_field", "hash", "numeric_literal"}) def resolve_slot( slot: str, candidates: list[RetrievedRecord], raw_fetcher, ) -> RetrievedRecord: """Resolve a slot from retrieval candidates, refusing to launder summaries into facts.""" if not candidates: raise LossyRecallError(f"no candidates for slot={slot!r}") ranked = sorted(candidates, key=lambda r: r.score, reverse=True) top = ranked[0] if slot in EXACT_SPEC_SLOTS: # Exact-spec slots must be served by a raw, exact record. exact_raw = [r for r in ranked if r.record_type is RecordType.RAW and r.fidelity is Fidelity.EXACT] if exact_raw: return exact_raw[0] # Only lossy summary matched: fail closed and force a raw re-fetch. if top.record_type is RecordType.SUMMARY or top.fidelity is Fidelity.LOSSY: raw = raw_fetcher(slot) # synchronous cold fetch from raw tier if raw is None or raw.fidelity is not Fidelity.EXACT: raise LossyRecallError( f"slot={slot!r} matched only lossy summary " f"(compaction_id={top.compaction_id}, score={top.score:.2f}); " f"raw re-fetch failed to recover exact value" ) return raw raise LossyRecallError( f"slot={slot!r} requires EXACT fidelity but best match was " f"{top.record_type.value}/{top.fidelity.value}" ) # Non-exact slots may accept a summary, but provenance is preserved on the record. return top ```