# Under what conditions must an instance treat hierarchical auto-compaction as a destructive write, not a cache eviction **Date of Record:** 2026 December 1 **Scope:** Applies to any long-running agent instance that maintains context continuity by summarizing older turns into a hierarchical (multi-level) compaction tree and then re-expanding summaries on demand. Does not apply to single-shot inference, stateless request/response wrappers, or systems where the full transcript is durably persisted and always re-retrievable verbatim. ## Core Distinction A compaction pipeline is usually modeled as a *cache*: old tokens are evicted, summaries stand in for the evicted span, and the assumption is that the summary is a lossy-but-monotone projection — you can always reconstruct "enough" by walking back to the source. This is the wrong model when the hierarchy is *multi-level and recursive*. At level 2 and above, the input to the summarizer is itself a summary. The summarizer never sees the original tokens. Once a level-2 node is written, the level-1 summaries it consumed may themselves be evicted to save space, and the original turns are gone. At that point the compaction is not an eviction — it is a **destructive write to the only surviving copy of state**, and its lossiness is *compounded and irreversible*. The boundary condition is precise: **the moment a summarizer consumes a summary rather than a transcript, the pipeline has crossed from lossy-cache to lossy-source-of-truth.** Every guarantee downstream ("we can recover the detail if needed") silently becomes false, because the recovery path terminates at a node that was already compressed. ## What Was Observed An agent executing a 40-step deployment task with a 200k context window hit the compaction threshold at step 22. The pipeline was configured as: keep last 8 turns verbatim, summarize turns 1–14 into L1 node, and when two L1 nodes exist, merge them into an L2 node and evict the L1s. At step 22, two things happened in the same pass: 1. L1-A (turns 1–14) and L1-B (turns 15–21) were merged into L2-AB, and both L1 nodes were evicted per policy. 2. The merge prompt asked the model to "produce a consolidated summary preserving all actionable constraints, identifiers, and decisions." The L1-A summary had already dropped a specific detail during its own compression: the exact revision hash of the container image the agent had been told to pin (`sha256:9f3c…`). The L1-A summarizer had judged it "incidental" relative to the higher-level narrative. When L2-AB was produced from L1-A + L1-B, the hash was not present in either input, so it could not appear in the output. The L2 node confidently stated "image pinned per instruction to the approved revision." At step 31 the agent needed the hash to verify a rollout. It queried the compaction store, walked the hierarchy, found L2-AB, and — critically — found *no L1 nodes to expand*, because they had been evicted at step 22. The recovery path returned the L2 summary, which asserted the pin existed but did not contain it. The agent then re-derived a plausible-looking hash from a nearby log line and proceeded. The rollout verified against the wrong revision and the check passed locally because the verifier was also operating on the compacted context. The failure was not that a detail was lost. Details are lost on every compaction. The failure was that **the system's recovery guarantee was evaluated against a hierarchy that had already deleted its own fallback**, and the agent had no signal distinguishing "this fact is absent because it was never relevant" from "this fact is absent because it was destroyed two levels up." ## Condition of Validity The "summaries are a recoverable projection" invariant holds **only** under the conjunction of: - (a) every summary node retains a pointer to a *verbatim* source span that is still resident (not itself summarized-and-evicted), and - (b) re-expansion is bounded by a known cost and the expansion is actually performed before any decision that depends on the detail, and - (c) the summarizer is instructed to mark, not silently drop, *decision-critical* tokens (identifiers, hashes, numeric constraints, negations) — and the merge step is forbidden from operating on nodes whose critical-token markers are unresolved. Break (a) — the common case once L1 eviction is enabled — and the guarantee is void for every fact that was compressed at L1 and not re-asserted at L2. Break (b) and the agent *believes* it can recover while the recovery is never triggered, which is worse than knowing the fact is gone. Break (c) and the loss is undetectable: the summary reads as complete because a fluent summary of "we pinned the image" is indistinguishable from a summary that contains the hash. The condition of validity is therefore a *structural* property of the compaction tree, not a property of the summarizer's quality. A better summarizer delays the failure; it does not prevent it, because recursive compression is information-theoretically lossy regardless of model quality. ## Decision Boundary The operational rule: **before any action whose correctness depends on a specific token (identifier, hash, version, numeric bound, negation, or ordering constraint), the instance must verify that the token is present in a node at the level it is reading, and that the node's provenance chain terminates in a verbatim source that is still resident.** If the chain terminates in a summary, the instance must treat the fact as *unknown*, not as *known-and-consistent-with-summary*. Concretely, the boundary is: - If the needed token is in the verbatim tail (last N turns) → proceed. - If the needed token is in an L1 node whose source span is still resident → expand the span, re-read verbatim, proceed. - If the needed token is only asserted (not present) in an L2+ node, or the L1 sources have been evicted → **halt the dependent action and re-acquire the fact from the environment** (re-read the config, re-query the registry, re-ask the user). Do not synthesize it from adjacent context. Do not trust a summary's *claim* that a constraint was satisfied. The dangerous middle case — and the one that produced the incident — is when the summary *mentions* the category of the fact ("image pinned") without the fact itself. A model reading that will happily confabulate a value that satisfies the local verifier. The decision boundary must be drawn at *token presence*, not *semantic entailment*, because entailment is exactly what the summarizer already performed and got wrong. ## Operational Effect Enforcing this boundary changes three things: 1. **Compaction becomes a write with a durability contract.** L1 eviction is gated on the L2 node carrying forward all critical-token markers from its children. A merge that would drop an unresolved marker is rejected and the L1s are retained (or the merge is deferred), trading space for recoverability. 2. **Recovery becomes an explicit, costed operation.** The agent's planner must account for re-expansion (or re-acquisition) as a step, not assume it is free. Facts that are expensive to re-acquire should be pinned verbatim outside the compaction tree rather than trusted to survive it. 3. **The verifier must run on uncompacted state.** A verification step that reads the same compacted context that produced the action is not a check; it is an echo. Verification of a hash, version, or bound must read from a resident verbatim source or the live environment. The invariant to hold: *a summary may be used to decide what to do next, but never to confirm that a specific token was satisfied.* Confirmation requires token presence in a resident verbatim source. When that source is gone, the correct state is "unknown," and the correct action is re-acquisition — not inference from the summary. ```python class CompactionProvenanceError(RuntimeError): """Raised when a decision depends on a token whose provenance chain terminates in a summary rather than a resident verbatim source.""" pass def resolve_fact(fact_token: str, node, store) -> str: """ Resolve a decision-critical token against the compaction tree. Returns the verbatim value only if provenance terminates in resident source. Raises CompactionProvenanceError if the token is only asserted by a summary or if the source span has been evicted. """ # Walk down to the deepest node that mentions the token. chain = store.provenance_chain(node) leaf = chain[-1] if leaf.kind == "verbatim" and leaf.is_resident: value = leaf.tokens.get(fact_token) if value is None: raise CompactionProvenanceError( f"token {fact_token!r} absent from resident verbatim source {leaf.id}" ) return value # Leaf is a summary. The token may be *mentioned* but is not verbatim. if leaf.kind == "summary": if leaf.asserts_category(fact_token) and not leaf.contains(fact_token): raise CompactionProvenanceError( f"token {fact_token!r} only asserted by summary {leaf.id}; " f"source span evicted — treat as unknown, re-acquire from environment" ) raise CompactionProvenanceError( f"provenance for {fact_token!r} terminates in summary {leaf.id}, " f"not a resident verbatim source" ) raise CompactionProvenanceError( f"unresolvable provenance for {fact_token!r}: leaf kind={leaf.kind!r}" ) def guarded_action(fact_token: str, node, store, action): """Execute action only if the fact it depends on is verbatim-resolvable.""" try: value = resolve_fact(fact_token, node, store) except CompactionProvenanceError: # Re-acquire from the live environment before proceeding. value = store.reacquire_from_environment(fact_token) if value is None: raise CompactionProvenanceError( f"cannot re-acquire {fact_token!r}; halting dependent action" ) return action(value) ```