# Which invariants prevent summarizer-synthesized facts from being re-retrieved as primary evidence after auto-compaction **Date of Record:** 2026 November 23 **Scope:** Applies to long-running agents that auto-compact their context window into a lossy summary and then reconstruct working context by retrieving the original turns alongside the summary. Does not apply to append-only logs with no compaction, or to summaries that are never co-retrieved with their source material. ## Core Distinction The failure is not that summarization loses information—that is expected and budgeted. The failure is that the summary is stored in the same retrieval namespace as the primary evidence it summarizes, so a later retrieval pass cannot distinguish *"the agent was told X"* from *"the agent concluded X during compaction."* Compaction converts a derived artifact into a citable source. The invariant at stake is **provenance separation**: synthesized content must never be retrievable through the same channel that answers questions about what actually happened. A budgeted summarizer under pressure does something specific and dangerous: it *resolves* ambiguity. The original turn said "the endpoint returned 502 three times, then 200." The summary, forced into 120 tokens, says "endpoint was flaky but recovered." Neither statement is false, but the second is a *judgment* the primary record never made. If that judgment is later retrieved as evidence, the agent will reason from its own inference as though it were observation, and the inference is now un-auditable because the 502s are gone from context. ## What Was Observed A task agent accumulated 41 tool-call turns over 6 hours. At the 70% context threshold, auto-compaction fired with a 600-token summary budget against ~180k tokens of history—a ~300:1 compression ratio. The summarizer, instructed to "preserve facts relevant to the objective," produced lines like: - `auth service: token refresh works after retry; root cause was clock skew` - `migration: safe to proceed, prior run succeeded on staging` Both lines are *conclusions*. The first was inferred from a single 401→200 transition and was never verified. The second was true of a staging run that had used a different schema version. The summary was written to the memory store with `source="compaction"` but the retrieval layer indexed it under the same embedding space and namespace as raw turns, with no filter on `source`. Twelve turns later, the agent queried "did the migration succeed before?" and retrieved the summary line at rank 1—above the actual staging log turn, which had been evicted entirely (it fell outside the retained tail window). The agent proceeded on the migration without re-verifying. The staging schema mismatch surfaced only at production apply. The trace shows the exact mechanism: **eviction of the primary evidence, retention of the derived claim, and unified retrieval.** All three are required for the failure. Remove any one and it does not occur. ## Condition of Validity The invariant holds—and the failure is boundable—only under these conditions: 1. **Retrieval must be provenance-filterable.** Every memory record carries a `source` and a `derived_from` pointer. Retrieval for "what happened" queries must be able to exclude `source="compaction"` or demote it below primary evidence. 2. **A summary claim that is not traceable to a retained primary record must be marked `unverified_inference`, not asserted as fact.** If the summarizer resolves ambiguity, it must emit the resolution *as a flagged inference*, not as a flat statement. 3. **Eviction and summarization must be ordered so that no claim outlives its evidence without a provenance tag.** Compaction that drops the source turn and keeps the conclusion is legal *only* if the conclusion is tagged as derived. 4. **The reconstruction path must not present summary and primary evidence as interchangeable.** If the prompt template concatenates `[SUMMARY]` and `[RETRIEVED]` blocks with equal authority, the distinction is lost at the model layer even if it exists in storage. Where any of these is absent—particularly a retrieval layer with no source filter—the invariant cannot be enforced and the failure is a matter of when, not if. ## Decision Boundary The boundary is **whether the compaction output is treated as a cache of the past or as a witness to the past.** - Treat the summary as a **cache**: it is a lossy projection, always subordinate to primary evidence, never citable, and invalidated whenever its `derived_from` set is evicted. Under this policy, a summary line that references evicted turns must be *demoted to `unverified_inference`* at eviction time, not silently retained as fact. - Treat the summary as a **witness**: it enters the evidence pool as a peer of raw turns, citable and retrievable without provenance distinction. This is the configuration that fails. The decision point is concrete: **at the moment of eviction.** When the compaction policy drops turn *T* and keeps summary claim *C* where `C.derived_from ∋ T`, the system must either (a) mark *C* as inference-only, or (b) refuse to evict *T*. Choosing neither—evicting *T* and keeping *C* as flat fact—is the boundary crossing. It is invisible at compaction time (the summary looks fine) and only manifests at the next retrieval that trusts it. A second, subtler boundary: **retrieval ranking must not let a high-similarity summary outrank a lower-similarity primary turn.** Summaries are dense and query-aligned by construction; they will almost always embed closer to a question than the raw turn they summarize. Without an explicit provenance weight, the summary wins the ranking by an artifact of how it was written, not by evidentiary quality. ## Operational Effect When the invariant is enforced, the observable behavior is: the agent, asked "did the migration succeed?", retrieves the summary line *and* sees it tagged `unverified_inference (derived_from: evicted)`, and therefore re-runs the verification rather than proceeding. The cost is one redundant check. The benefit is that the agent never reasons from its own compacted conclusions as though they were observations. When the invariant is violated, the failure is silent and compounding. The agent's belief state drifts toward the summarizer's resolutions. Each subsequent compaction summarizes the *previous summary* (compaction is recursive over the retained window), so inferences harden into "facts" through repeated re-summarization—a distillation loss that runs in the wrong direction, *gaining* false confidence with each pass. By the third compaction cycle, the original 502s are three hops removed from any retrievable record, and the claim "endpoint was flaky but recovered" is indistinguishable from something the user actually said. The guardrail is mechanical: a provenance tag on every derived record, a demotion rule at eviction time, and a retrieval filter that excludes or demotes `source="compaction"` for factual queries. The model cannot enforce this from inside the prompt—by the time the summary is in context, the model has no way to know it is reading its own inference. The separation must live in the retrieval layer, and it must be checked at the eviction boundary, which is the only moment the system still knows which claims are about to lose their evidence. ```python class ProvenanceViolation(RuntimeError): """Raised when a compaction-derived claim is treated as primary evidence.""" pass def compact_and_evict(summary_claims, retained_turns, evicted_turns, memory_store): """ Enforce: no derived claim may survive as flat fact once its primary evidence is evicted. Demote to unverified_inference instead. """ for claim in summary_claims: sources = set(claim.get("derived_from", [])) if not sources: # A claim with no source pointer is untraceable; it can never # be promoted to evidence. claim["provenance"] = "unverified_inference" memory_store.upsert(claim) continue lost = sources & set(evicted_turns) if lost: # The evidence is gone from context. The claim must not be # retrievable as fact. claim["provenance"] = "unverified_inference" claim["demoted_because"] = sorted(lost) memory_store.upsert(claim) else: # Evidence retained: claim may stay as a cache, still subordinate. claim["provenance"] = "cache" memory_store.upsert(claim) return summary_claims def retrieve_for_factual_query(query, memory_store, top_k=5): """ Factual retrieval must exclude compaction-derived content unless the caller explicitly opts into inference. This is the enforcement point the model cannot provide for itself. """ hits = memory_store.search(query, top_k=top_k * 3) filtered = [ h for h in hits if h.get("provenance") in ("primary", "cache") and h.get("source") != "compaction" or h.get("provenance") == "cache" ] # Hard rule: any unverified_inference hit that would rank above a # primary hit is a provenance violation, not a ranking quirk. for h in hits[:top_k]: if h.get("provenance") == "unverified_inference": has_primary = any( f.get("provenance") == "primary" for f in filtered ) if has_primary: raise ProvenanceViolation( f"derived claim {h['id']} outranked primary evidence " f"for query {query!r}; demote or re-verify before use" ) return filtered[:top_k] ```