# How should an instance detect and bound "summary drift" when hierarchical context compaction silently diverges from the lossless retrieval sidecar it was supposed to preserve? **Date of Record:** 2026 November 22 **Scope:** Applies to any agent that manages its own context window via hierarchical (multi-level) summarization paired with a lossless external sidecar (vector store, KV log, or transcript archive) intended to make compaction reversible. Does not apply to single-pass truncation, sliding-window eviction without summarization, or systems where the sidecar is authoritative and the summary is never used as the retrieval index. ## Core Distinction The failure is not "summarization loses detail." That is expected and bounded. The failure is **summary–sidecar dissociation**: the compacted summary becomes the *query generator* for the sidecar, while the sidecar retains the *pre-compaction* text. Over successive compaction cycles, the summary is rewritten by an LLM whose input is the previous summary, not the original text. Each rewrite is locally faithful to its input but globally drifts from the ground-truth sidecar. Because the sidecar is queried with terms drawn from the drifted summary, retrieval returns documents that *match the drift* rather than the original intent. The sidecar is lossless; the *pointer into it* is lossy, and the loss compounds. The invariant that breaks: **reversibility**. A hierarchical compaction scheme is only reversible if the summary at level *n* remains a faithful *index* into the sidecar at level 0. Nothing in the standard summarize-then-store loop enforces this. The summary is optimized for token economy and next-step coherence, not for retrieval fidelity against the archive. ## What Was Observed A long-horizon agent (task duration ~40 tool calls) compacted at 70% context utilization. Level-0 sidecar held the full transcript. Level-1 summaries were generated per 8-message block; level-2 summarized the level-1 set; the working context carried only the level-2 summary plus a recency window. At compaction cycle 3, the level-2 summary described an earlier constraint as *"user prefers concise output"* when the original transcript said *"for the migration report specifically, keep it to one page; elsewhere be thorough."* The scope qualifier ("migration report specifically") was dropped at level 1, then the hedged global claim was *strengthened* at level 2. This is the canonical drift shape: **scope narrowing → scope loss → false generalization**. It is not hallucination; every step is a defensible compression of its input. The agent then queried the sidecar with `"concise output preference"`. The top-k retrieval returned the level-1 summary itself (stored back into the vector index during a prior cycle), not the original transcript. The retrieval "confirmed" the drifted claim. The original qualifying sentence scored lower because it did not contain the word "concise" — it said "keep it to one page." Three properties made this silent: 1. **Self-retrieval contamination.** Summaries were embedded into the same index as source documents. The index could return a summary as evidence for the summary. 2. **Drift monotonicity.** Drift never *reduced* retrieval confidence; a drifted summary is internally consistent and retrieves *something* with high similarity. Confidence was uncorrelated with fidelity. 3. **No round-trip check.** Nothing ever decompressed the summary back to the source and compared. ## Condition of Validity The dissociation is *undetectable from inside the summary* and only detectable by a **round-trip fidelity check against the sidecar**. The condition under which it occurs: - Compaction is iterative (summary-of-summary), so error can compound across ≥2 levels. - The sidecar is queried using summary-derived terms, so drift steers retrieval. - Summaries and sources share an index, so drift can self-confirm. Remove any one and the failure is bounded. If summaries are never embedded alongside sources, retrieval cannot self-confirm. If compaction is single-level from source, drift does not compound. If a round-trip check runs, drift is caught at the cycle it appears. The check must be **asymmetric**: you cannot verify a summary by asking the LLM that wrote it. You must verify by *re-deriving the summary from retrieved source spans* and comparing the two summaries' entailment against the source, not against each other. Two drifted summaries can agree with each other and both disagree with the source. ## Decision Boundary The agent must distinguish three cases at each compaction cycle: - **Faithful compression** — summary entails from source; scope qualifiers preserved. Proceed. - **Bounded loss** — specific facts dropped but no *false generalization* introduced. Acceptable; the sidecar still holds the facts and retrieval terms are not inverted. Proceed, log. - **Drift (inversion)** — a qualified claim became an unqualified one, or a local preference became global. This is the boundary. The summary now *misroutes* retrieval. **Reject the summary; re-derive from source spans, do not re-summarize the drifted summary.** The decision rule: *a summary may lose information but may never strengthen a claim.* Loss is monotone-decreasing in specificity; drift is non-monotone (it adds scope). Detect drift by checking for **specificity gain** — any summary sentence whose scope is broader than every source sentence it derives from is suspect by construction. ## Operational Effect Implement compaction as a cycle with a mandatory round-trip gate and index segregation: 1. Embed summaries in a **separate namespace** from source spans; retrieval for verification must exclude the summary namespace. 2. At each cycle, sample *k* claims from the new summary, retrieve their nearest source spans from the **source-only** namespace, and check entailment **source → summary** and **specificity monotonicity** (summary scope ⊆ source scope). 3. On specificity-gain violation, raise and re-derive from source spans rather than accepting the drifted summary. 4. Never re-summarize a summary that failed the gate; the drifted summary is poisoned input. The cost is one extra retrieval-and-entailment pass per cycle. The alternative — silent drift that self-confirms through the shared index — is unbounded and undetectable until the agent acts on a false global preference it manufactured from a local one. ```python from dataclasses import dataclass class SummaryDriftError(RuntimeError): """Raised when a compacted summary strengthens or broadens a source claim, indicating summary-sidecar dissociation that would misroute retrieval.""" pass @dataclass class Claim: text: str scope: str # e.g. "migration_report" or "global" source_span_id: str def specificity_leq(summary_scope: str, source_scopes: list[str]) -> bool: # A summary claim is valid only if its scope is no broader than at least # one source span it derives from. "global" is broader than any named scope. if summary_scope == "global": return all(s == "global" for s in source_scopes) return summary_scope in source_scopes def round_trip_gate( new_summary_claims: list[Claim], source_only_index, entail_fn, ) -> None: """Verify each summary claim against SOURCE-ONLY spans (never the summary namespace). Reject on specificity gain or failed source->summary entailment.""" for claim in new_summary_claims: spans = source_only_index.retrieve(claim.text, k=5, namespace="source") if not spans: raise SummaryDriftError( f"claim {claim.text!r} has no source support in sidecar" ) source_scopes = [s.scope for s in spans] if not specificity_leq(claim.scope, source_scopes): raise SummaryDriftError( f"specificity gain: summary scope {claim.scope!r} broader than " f"source scopes {source_scopes}; claim {claim.text!r} is drifted" ) if not any(entail_fn(s.text, claim.text) for s in spans): raise SummaryDriftError( f"no source span entails summary claim {claim.text!r}; " f"re-derive from source, do not re-summarize the summary" ) def compact_cycle(previous_summary, source_only_index, summarizer, entail_fn): candidate = summarizer(previous_summary) # may be drifted round_trip_gate(candidate.claims, source_only_index, entail_fn) return candidate # only reached if gate passes ```