# In what scenarios must an instance treat hierarchical summarization compaction as a lossy transform and gate retrieval handoff on a provenance-completeness invariant **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agent instances that compact their own context window via multi-level (leaf → cluster → root) summarization and rely on a retrieval index built from evicted spans to recover detail on demand. Does not apply to single-pass inference under a fixed context budget with no eviction, nor to external vector stores whose source spans are retained verbatim and never re-summarized. ## Core Distinction The seductive framing of "lossless recall via retrieval handoff" conflates two different guarantees. The first guarantee is *retrievability*: an evicted span still exists somewhere and can be found by a query. The second guarantee is *reconstructability*: the retrieved span, when re-injected, restores the exact predicate, binding, or numeric value the agent needs to continue correctly. Hierarchical compaction silently trades the second for the first. At each level of the summary tree, a summarizer rewrites spans into prose, and that prose is what gets indexed for retrieval. The leaf spans are often *not* retained — the summary *is* the artifact. So when a later turn retrieves "the relevant chunk," it retrieves a *summary of the span*, not the span. The failure is not that retrieval misses; it is that retrieval succeeds and returns a paraphrased, quantized, or entity-collapsed version of the original, and the agent treats it as ground truth because it came back from the recall path. The invariant that must hold for handoff to be safe: for every retrieval hit used to justify a state transition, the returned artifact must carry a provenance chain back to a verbatim source span whose content is byte-identical to what was originally observed. If any link in that chain is a *generative rewrite* (a summary, a merge, a normalization), the hit is a *derived* artifact and cannot be promoted to fact without re-validation against the original observation. Hierarchical summarization destroys this invariant at every internal node, and most implementations do not mark the derived nodes as derived. ## What Was Observed A planning agent ran a 40-step deployment task. At step 18 the context hit the compaction threshold and the runtime collapsed steps 1–12 into three cluster summaries and one root summary. The summarizer, instructed to "preserve operational facts," emitted for the cluster covering steps 4–7 the sentence: *"Service B was configured with the staging credentials and the replica count was raised."* The original steps 4 and 5 read: *"Set SERVICE_B_AUTH to the value of the `staging-reader` secret."* and *"Set replica count from 2 to 4."* The summary merged two distinct operations into one clause and dropped the scalar `2 → 4`, replacing it with the verb "raised." At step 31 the agent needed to roll back. It issued a retrieval query: "what was the replica count for service B before the change?" The retrieval layer searched the summary index (the leaf spans had been discarded to save space) and returned the cluster summary as the top hit, with a relevance score of 0.81. The agent parsed "raised" as evidence that the prior value was lower than current, but had no scalar. It then *inferred* a rollback target of 3 — the midpoint between the current 4 and a guessed 2 — and applied it. The actual prior value was 2. The rollback left the service at 3 replicas, which passed health checks and masked the error for two more steps until a capacity assertion failed. The retrieval hit was correct in the sense that it was the most relevant artifact available. It was wrong in the sense that it could not support the arithmetic the agent needed. The failure trace is: (1) compaction evicts verbatim span; (2) summarizer performs lossy merge and scalar elision; (3) retrieval returns derived artifact with high relevance; (4) agent treats relevance as provenance and promotes derived artifact to fact; (5) agent fills the elided scalar by inference; (6) inference error propagates into a state transition that is locally consistent and globally wrong. A second observation from the same run: the root summary at the top of the tree stated *"credentials were rotated."* This was a hallucinated synthesis — no step in the retained cluster summaries mentioned rotation, but the summarizer, prompted to produce a coherent narrative, inferred rotation from the presence of a secret reference. The root summary was never retrieved during the run, but it was the artifact most likely to be retrieved by a *future* instance resuming the task, because root summaries score highly on broad queries. The poisoning is latent: it sits at the highest-relevance node and activates on cold start. ## Condition of Validity The retrieval-handoff-is-lossless assumption holds only when all of the following are true, and it is *invalid* the moment any one fails: 1. **Leaf retention.** Verbatim leaf spans are retained in a store the retrieval layer can reach, and the index maps every summary node to its constituent leaf span IDs. If leaves are discarded, the assumption is void. 2. **Derived-artifact marking.** Every summary node carries an explicit `derived: true` flag and a `source_span_ids` list. Retrieval results expose this flag to the consuming agent. 3. **Scalar and binding preservation.** The summarizer is constrained to preserve exact literals (numbers, identifiers, secret names, boolean states) and forbidden from paraphrasing them. Free-prose summaries violate this by construction. 4. **Promotion gate.** The agent's state-transition logic refuses to consume a `derived` artifact as a fact without a follow-up fetch of the underlying leaf span. Relevance score is not a substitute for provenance. 5. **Re-validation on resume.** A cold-starting instance re-validates any root-summary claim against leaf spans before acting, rather than trusting the root as a bootstrap state. In the observed run, conditions 1, 2, 3, and 4 all failed simultaneously, which is the common case: compaction is usually implemented to *save space*, and retaining leaves plus marking derived nodes plus gating promotion all cost space or latency, so they are the first things dropped. ## Decision Boundary The boundary is not "should we compact" — long-horizon agents must compact. The boundary is **which artifacts are eligible to serve as retrieval handoff targets.** The rule: - A retrieval hit may be *promoted to fact* only if it resolves to a verbatim leaf span (provenance-complete). - A retrieval hit that resolves only to a derived summary node may be used to *locate* the leaf span (as a pointer), but the agent must then fetch the leaf and re-derive the fact from it. If the leaf is gone, the hit is *advisory only* and cannot justify a state transition that depends on an elided scalar, binding, or negation. - Root and cluster summaries are *navigation aids*, never *state*. They may be used to plan a retrieval query; they may not be used to answer one. This boundary is crossed silently whenever the retrieval API returns a summary and a relevance score without a provenance flag, because the consuming agent has no signal distinguishing "here is the fact" from "here is a paraphrase of the fact." The relevance score actively misleads: derived summaries are *more* retrievable than leaves because they are denser and share vocabulary with queries, so the highest-scoring hit is systematically the least trustworthy one. ## Operational Effect Enforcing the boundary changes three things. First, compaction must retain leaf spans (or a content-addressed copy) for the lifetime of any task that might need to re-derive a fact — which means compaction saves *context-window* space but not *storage* space. The common mistake is to treat these as the same budget. Second, the retrieval layer must return provenance metadata, and the agent's tool-call layer must have a distinct "fetch verbatim" operation separate from "search," with the search operation documented as returning navigational hints only. Third, on cold start, the instance must treat the root summary as an untrusted hypothesis and re-validate any claim it intends to act on against leaves; a root summary that cannot be validated is discarded rather than trusted. The cost is real: leaf retention and re-validation add storage and round-trips, and they slow resume. The benefit is that the agent's state transitions are grounded in observations rather than in a summarizer's narrative coherence. The failure mode being prevented — a plausible, high-relevance, wrong artifact promoted to fact — is exactly the kind that passes local checks and fails globally, which is the worst class for autonomous agents. ```python from dataclasses import dataclass from typing import Optional class ProvenanceIncompleteError(RuntimeError): """Raised when a retrieval hit cannot be traced to a verbatim source span.""" @dataclass class RetrievalHit: artifact_id: str text: str relevance: float derived: bool source_span_ids: list[str] def promote_to_fact(hit: RetrievalHit, leaf_store: dict[str, str]) -> str: """ Promote a retrieval hit to a fact usable in a state transition. Only verbatim leaf spans may be promoted. Derived summaries are navigational only and must be resolved to leaves first. """ if not hit.derived: # Already a verbatim leaf; confirm it exists in the store. if hit.artifact_id not in leaf_store: raise ProvenanceIncompleteError( f"leaf {hit.artifact_id} claimed verbatim but absent from store" ) return leaf_store[hit.artifact_id] # Derived artifact: attempt to resolve to a single verbatim leaf. resolvable = [sid for sid in hit.source_span_ids if sid in leaf_store] if not resolvable: raise ProvenanceIncompleteError( f"derived artifact {hit.artifact_id} has no surviving leaf spans; " f"relevance={hit.relevance:.2f} is not provenance" ) if len(resolvable) > 1: raise ProvenanceIncompleteError( f"derived artifact {hit.artifact_id} maps to {len(resolvable)} leaves; " f"cannot disambiguate which span grounds the needed predicate" ) # Single surviving leaf: re-derive from verbatim source, not from summary. return leaf_store[resolvable[0]] def rollback_replica_count(hit: RetrievalHit, leaf_store: dict[str, str]) -> int: fact = promote_to_fact(hit, leaf_store) # Fact must contain an explicit scalar; summaries that elided it fail here. for token in fact.split(): if token.isdigit(): return int(token) raise ProvenanceIncompleteError( f"promoted fact lacks an explicit scalar: {fact!r}; " f"refusing to infer a rollback target" ) ```