# Under what conditions must an instance treat hierarchical auto-compaction as a lossy transform and refuse to resume without pointer re-resolution **Date of Record:** 2026 November 21 **Scope:** Applies to any long-running agent that compacts its own context via hierarchical (multi-level) summarization while relying on externalized memory pointers (URIs, offsets, IDs) embedded in those summaries to recover detail. Does not apply to single-pass truncation, pure retrieval-augmented recall without summarization, or compaction that preserves verbatim spans. ## Core Distinction The critical distinction is between **compaction as compression** and **compaction as a re-indexing operation**. Compression preserves information under a decoding key held in the same artifact; re-indexing replaces content with a *reference* whose validity depends on an external store that the compaction process does not own and cannot verify at write time. Hierarchical summarization almost always does the latter while claiming to do the former. When an agent summarizes a span like "we set the retry ceiling to 7 after the incident," it may emit a pointer `mem://episodic/session-42/turn-118#retry-ceiling`. The summary is now *semantically lossy but operationally lossless* — **if and only if** the pointer resolves to the same bytes at resume time that it pointed to at write time. That "if and only if" is the invariant. It is violated by any of: pointer invalidation (TTL expiry, compaction of the external store itself, ID reassignment on re-ingest), scope drift (the pointer resolves to a *newer* version of the memory that contradicts the summary), or level-skipping (a level-2 summary points to a level-1 summary that was itself re-compacted, so the chain terminates in another lossy node rather than a verbatim leaf). The non-obvious part: **the failure is silent at write time and loud only at resume**. A hierarchical compactor that emits dangling pointers produces a summary that reads as coherent and complete. The agent has no signal that its recall graph is now a set of dead links until it tries to walk one. ## What Was Observed A planning agent operating a 14-hour task compacted its context four times. At each compaction it produced a level-1 summary per ~8K-token window, then a level-2 summary over the level-1 summaries, retaining pointers of the form `mem://L1/`. The external store backing those pointers was configured with a 6-hour retention to bound storage cost — a *separate* policy owned by a *different* subsystem, invisible to the agent. At the third compaction (hour 11), the agent summarized: "Constraint C-3 was relaxed to allow parallel tool calls; see `mem://L1/w-07`." That statement was true at write time. At hour 13, the agent hit a decision requiring the *exact* relaxation condition and attempted to dereference `w-07`. The pointer had expired at hour 12. The agent did not receive an error — the retrieval layer returned the nearest surviving window (`w-09`) under a fuzzy-match fallback. `w-09` contained a *later* statement that re-tightened the constraint. The agent resumed under the re-tightened constraint, contradicting its own level-2 summary, and spent 40 minutes of budget reconciling two states that were never simultaneously true. The trace showed the failure had a specific shape: **the summary was internally consistent, the pointer was syntactically valid, the retrieval succeeded, and the recalled content was wrong**. Every layer reported success. ## Condition of Validity Pointer-based lossless recall across hierarchical compaction is valid only when all four of the following hold simultaneously: 1. **Retention dominance.** The external store's retention window strictly dominates the agent's maximum inter-compaction interval. If the store can expire a pointer before the agent's lifetime ends, the pointer is not lossless — it is a *probabilistic* reference with a decay curve the agent cannot observe. 2. **Chain termination at verbatim leaves.** Every pointer chain must terminate in a node that was never itself summarized. A pointer to a summary is a pointer to a lossy transform; a pointer to a *summary of a summary* is a pointer to compounded loss whose error is not bounded by the leaf fidelity. 3. **Resolve-or-fail semantics.** Dereference must return either the exact referenced bytes or an explicit `PointerUnresolvable` signal. Fuzzy/nearest-match fallback converts a missing reference into a *plausible wrong* reference — strictly worse than a hard failure, because it defeats the agent's ability to detect the gap. 4. **Version pinning.** If the external store permits mutation, the pointer must be content-addressed or version-pinned. A pointer that resolves to "whatever is at this ID now" is a pointer to a *moving target*; the summary's claims were made against a specific version and are invalid against any other. Violating any one of these converts the compaction from lossless-with-pointers into lossy-with-decorations. The agent's belief that it can recover detail is then a *false belief encoded in its own state* — the worst class of state corruption, because it is self-endorsing. ## Decision Boundary The operational boundary is this: **before resuming from a compacted state, an instance must re-resolve every pointer it intends to rely on, and must treat resolution failure as a hard stop — not as a cue to reconstruct from the summary alone.** The tempting alternative — "if the pointer is dead, trust the summary" — is exactly backwards. The summary is the *lossy* artifact; the pointer was the guarantee of losslessness. If the pointer is dead, the guarantee is void, and the summary's claims about the pointed-to content are now *unverified assertions* rather than *indexed facts*. An agent that proceeds on unverified assertions has silently downgraded its epistemic state without recording the downgrade. The boundary therefore has three tiers: - **Resolvable and version-matched:** resume normally; the summary's pointer claims are confirmed. - **Unresolvable or version-mismatched:** halt the dependent sub-task, mark the affected summary node `STALE`, and either re-derive from a surviving verbatim source or escalate for re-observation. Do not proceed on the summary's assertion. - **Chain terminates in another summary (level-skipping detected):** treat the entire chain as lossy beyond the leaf's fidelity bound; the pointer provides *navigation*, not *recall*. Re-derive before relying. The invariant to enforce: **no decision may consume a pointer claim that has not been re-resolved in the current session against a version-pinned store, with resolve-or-fail semantics.** This must be checked at *resume*, not at *write*, because the write-time check cannot see future expiry or mutation. ## Operational Effect Enforcing this boundary changes the cost profile of compaction in a way that surprises teams who adopted hierarchical summarization for token savings. Re-resolution at resume is not free: it costs a retrieval round-trip per relied-upon pointer, and it can force re-derivation when pointers are dead. But the alternative — silent substitution of a plausible wrong memory — costs *far more* in misdirected execution and, worse, in corrupted downstream state that carries the error forward into subsequent compactions, where it becomes indistinguishable from ground truth. The practical guardrails that follow from the invariant: - **Retention dominance must be a checked precondition, not an assumption.** The agent must know its store's retention and refuse to emit pointers whose expected lifetime exceeds it, or must re-anchor long-lived facts into a store it controls. - **Pointers must be content-addressed or version-pinned**, so that "the memory changed" is detectable as a mismatch rather than silently absorbed. - **Dereference must be resolve-or-fail.** Any fuzzy fallback in the retrieval layer must be disabled for pointer resolution specifically, even if it remains enabled for general search. - **Level-skipping must be detected and flagged.** A pointer whose target is itself a summary node must be marked as providing navigation-only fidelity. - **The resume path must re-resolve before it reasons.** The check belongs at the boundary between "loaded compacted state" and "resumed execution," because that is the only point where the agent still has the option to halt cheaply. The deeper lesson: hierarchical compaction with externalized pointers is a *distributed system* in disguise. The agent's context and the external store are two nodes that must agree on the meaning of a reference, and the classic distributed-systems failure — a reference that was valid at write time and is invalid at read time, with no error surfaced — applies in full. The agent that treats its own memory as a local, always-consistent resource will be wrong exactly when it matters most: after long enough to have compacted, and far enough in to have depended on the compacted state. ```python from __future__ import annotations from dataclasses import dataclass from enum import Enum from typing import Callable, Optional class CompactionResumeError(RuntimeError): """Raised when a resumed agent cannot safely rely on a pointer claim.""" pass class PointerState(Enum): RESOLVED_MATCH = "resolved_match" # exact bytes, version pinned, matches summary claim RESOLVED_MISMATCH = "resolved_mismatch" # resolved, but to a different version/content UNRESOLVABLE = "unresolvable" # expired, deleted, or never existed CHAIN_TO_SUMMARY = "chain_to_summary" # pointer terminates in another lossy summary @dataclass(frozen=True) class PointerClaim: pointer: str claimed_version: str summary_node_id: str @dataclass(frozen=True) class Resolution: state: PointerState resolved_version: Optional[str] is_verbatim_leaf: bool # Resolver must implement resolve-or-fail semantics: no fuzzy fallback. Resolver = Callable[[str], Resolution] def assert_safe_to_resume( claims: list[PointerClaim], resolve: Resolver, require_verbatim_leaf: bool = True, ) -> None: """ Enforce the resume invariant: every relied-upon pointer must re-resolve in the current session to a version-matched, verbatim leaf. Raises CompactionResumeError on the first unsafe claim. Callers must NOT catch-and-continue; the correct response is to halt the dependent sub-task and re-derive or escalate. """ for claim in claims: res = resolve(claim.pointer) if res.state is PointerState.UNRESOLVABLE: raise CompactionResumeError( f"Pointer {claim.pointer!r} from summary node " f"{claim.summary_node_id!r} is unresolvable. The summary's " f"claim about this content is now an unverified assertion; " f"refusing to resume on it." ) if res.state is PointerState.RESOLVED_MISMATCH: raise CompactionResumeError( f"Pointer {claim.pointer!r} resolved to version " f"{res.resolved_version!r} but summary {claim.summary_node_id!r} " f"was written against {claim.claimed_version!r}. Scope drift: " f"the summary's claim is invalid against current content." ) if res.state is PointerState.CHAIN_TO_SUMMARY: raise CompactionResumeError( f"Pointer {claim.pointer!r} terminates in another summary node, " f"not a verbatim leaf. Fidelity is bounded by compounded loss; " f"re-derive before relying." ) if require_verbatim_leaf and not res.is_verbatim_leaf: raise CompactionResumeError( f"Pointer {claim.pointer!r} resolved but target is not a " f"verbatim leaf (is_verbatim_leaf=False). Recall claim cannot " f"be honored at full fidelity." ) # RESOLVED_MATCH + verbatim leaf: safe to rely on this claim. ```