# What structural signals indicate a compaction boundary has silently invalidated a retrieval-backed rehydration key **Date of Record:** 2026 November 28 **Scope:** Applies to agents that persist long-horizon state as a lossy summary plus a pointer/index into an external store, and rehydrate on cold start or checkpoint resume. Does not apply to agents that keep full transcripts in-context or that use append-only verbatim logs without summarization. ## Core Distinction The failure is not "summarization lost information." That is expected and bounded by the summary's compression ratio. The failure is that the summarization step **mutated the referential substrate** that the retrieval index keys against, so the rehydration pointer still resolves — it returns a document — but resolves to the *wrong* document with high lexical confidence. The distinction that matters operationally: - **Lossy-but-stable compaction:** the summary drops detail, but every retained entity, identifier, and relation in the summary still names the same object it named before compaction. Rehydration is faithful to a smaller truth. - **Lossy-and-destabilizing compaction:** the summary *renormalizes* surface forms — collapses aliases, rewrites timestamps into relative language, canonicalizes IDs, merges near-duplicate entities — and in doing so changes the key space. The retrieval layer then matches against a key space that no longer corresponds to the store. The second case is non-obvious because the summary reads as *more* coherent, not less. Reviewers approve it. The corruption is invisible until a cold start, at which point retrieval succeeds with a plausible but wrong referent. ## What Was Observed A long-running ops agent maintained state as a rolling summary (target ~2,000 tokens) plus a vector index over ticket fragments. During a compaction pass the summarizer rewrote the working set: - `INC-4471` (a specific incident) was summarized as "the payment-gateway incident." - An absolute timestamp `2025-05-14T09:12Z` became "last Tuesday." - Two distinct services, `billing-svc` and `billing-worker`, were merged into "the billing service." Each of these is a defensible compression. Each is also a **key mutation**. The retrieval index, however, was built over the *original* fragments, keyed by the original surface forms. After compaction, the agent's query surface — what it actually types into retrieval on resume — was drawn from the summary, i.e. from the mutated forms. Trace on cold start: 1. Agent resumes from checkpoint. Working context = the compacted summary only. 2. Task: "confirm the gateway fix from last Tuesday is live." 3. Agent issues retrieval query `"payment-gateway incident last Tuesday billing service"`. 4. Vector search returns the three nearest fragments. Because "last Tuesday" is now relative to *checkpoint time*, not *incident time*, and because "billing service" is ambiguous across two services, the top-k are two fragments from an *unrelated* incident plus one billing-worker fragment. 5. Similarity scores are high (0.81–0.87). No threshold trips. 6. Agent reports: fix confirmed. It is not confirmed. The actual incident fragment was never retrieved because the query no longer contains `INC-4471` or the absolute timestamp. The decisive observation: **retrieval confidence was uncorrelated with referential correctness.** The wrong fragments were lexically closer to the *summary's* wording than the right fragment was, because the summary had drifted the wording toward a generic vocabulary that the wrong fragments also used. ## Condition of Validity The invariant that must hold for retrieval-backed rehydration to be safe: > Every entity reference, identifier, and temporal anchor that survives compaction must be **byte-identical** to the form used to key the retrieval store, OR the summary must carry an explicit unresolved-reference marker that forces the agent to re-resolve before querying. This holds only when compaction is *reference-preserving*: it may drop references but may never rewrite them. The moment the summarizer is permitted to paraphrase an identifier ("the X incident" for `INC-4471`), the invariant is broken, and the break is silent because both the summary and the retrieval result remain individually well-formed. The condition fails specifically when all three co-occur: 1. Compaction rewrites surface forms of keys (aliasing, relative time, entity merge). 2. Retrieval is dense/vector-based, so there is no exact-key miss to trigger a fallback. 3. There is no post-retrieval referential check (does the returned fragment actually mention the entity the summary named?). Remove any one and the failure degrades to a detectable error. ## Decision Boundary The boundary is whether the agent treats the summary as **authoritative for content** but **non-authoritative for keys**. Concretely: - If a summary token is used only to inform reasoning → safe to paraphrase freely. - If a summary token is used to *construct a retrieval query or filter* → it is a key and must be preserved verbatim or flagged. Operationally, draw the line at the summarizer's output schema. A summary that emits free prose will silently rewrite keys. A summary that emits a structured envelope — `{narrative: str, preserved_keys: [ids, absolute_ts, service_names], dropped_keys: [...], unresolved: [...]}` — forces the key/paraphrase distinction into the artifact. Rehydration then queries on `preserved_keys` only, and any key in `unresolved` must be re-resolved against the store *before* any retrieval that depends on it, not after. A second boundary: relative temporal expressions ("last Tuesday," "recently," "the previous deploy") are **never** safe as keys because their referent is a function of compaction wall-clock, which differs from resume wall-clock. They must be absolutized at compaction time or moved to `unresolved`. ## Operational Effect Without the guardrail, the failure mode is **confident mis-rehydration**: the agent resumes, retrieves, and proceeds on state that is internally consistent and externally wrong. It does not error; it does not flag low confidence; it produces a plausible continuation grounded in the wrong episode. Downstream, this manifests as the agent "forgetting" a fix that was applied, re-applying it, or asserting a status that was true for a different incident. With the guardrail, compaction cost rises slightly (structured output, explicit key preservation, an unresolved queue), and rehydration gains a hard referential check: every retrieved fragment must be validated against the preserved key it was retrieved for. A mismatch is a *loud* failure — the rehydration is rejected and the agent re-queries with the verbatim key — rather than a silent substitution. The general principle for operational records: **compaction is a transformation of the query surface, not just of the context.** Any summarizer that is allowed to rewrite the tokens the agent will later use as retrieval keys is a key-space corruption engine, and its output will look better than the input right up until the first cold start. ```python from dataclasses import dataclass, field from typing import Iterable class RehydrationKeyMismatch(RuntimeError): """Raised when a retrieved fragment does not reference the preserved key it was fetched for.""" @dataclass class CompactedState: narrative: str preserved_keys: dict[str, str] # key_id -> verbatim surface form used to build the index unresolved: list[str] = field(default_factory=list) @dataclass class Fragment: fragment_id: str text: str mentions: set[str] # keys this fragment actually references def build_query(state: CompactedState, wanted: Iterable[str]) -> str: """Construct a retrieval query ONLY from preserved keys. Never from narrative prose.""" missing = [k for k in wanted if k not in state.preserved_keys] if missing: # A key the task needs was dropped or rewritten during compaction. raise RehydrationKeyMismatch( f"cannot build faithful query: keys {missing} not preserved; " f"unresolved={state.unresolved}" ) return " ".join(state.preserved_keys[k] for k in wanted) def rehydrate(state: CompactedState, wanted: list[str], retrieved: list[Fragment]) -> list[Fragment]: """Validate that retrieved fragments actually reference the preserved keys.""" query_keys = {state.preserved_keys[k] for k in wanted} verified: list[Fragment] = [] for frag in retrieved: if not (frag.mentions & query_keys): # Retrieved on lexical drift, not on the real referent: silent-substitution risk. raise RehydrationKeyMismatch( f"fragment {frag.fragment_id} retrieved but references none of " f"{sorted(query_keys)}; refusing confident mis-rehydration" ) verified.append(frag) if not verified: raise RehydrationKeyMismatch("no fragment survived referential verification") return verified ```