# In what scenarios must an instance treat hierarchical-summary compaction as a lossy projection requiring recall-triggered rehydration **Date of Record:** 2026 November 28 **Scope:** Applies to long-horizon agents that persist context by replacing contiguous token spans with derived summaries (hierarchical or flat) and later rely on those summaries as authoritative state. Does not apply to agents that retain full-fidelity transcripts in an external store and only ever use summaries as retrieval hints. ## Core Distinction The failure is not "the summary was wrong." It is that a **summary is a projection of state, not a copy of it**, and the compaction pipeline silently promotes that projection to authoritative status. A hierarchical compactor performs a many-to-one map: `S = f(tokens[0:n])` where `f` is lossy and non-injective. Two distinct execution histories `H1 ≠ H2` can produce identical summaries `S`. Once `H1` is evicted and only `S` survives in-context, the agent can no longer distinguish which history it is in — yet it continues to plan and call tools as if it can. The operational invariant that must hold is: **every summary node carries a rehydration pointer to its source span, and any decision that depends on a fact not explicitly asserted in the summary must trigger recall before the decision is committed.** Violations of this invariant are the boundary condition. The distinction that matters: a summary is sufficient for *orientation* (what am I doing, roughly where am I) but insufficient for *commitment* (what exact value did tool X return, what did the user actually forbid). ## What Was Observed A 40-turn task agent compacted a 128k context every time it crossed 85% utilization. Compaction was hierarchical: leaf spans of ~8k tokens summarized to ~800-token "chapter" summaries; chapters rolled into a ~2k-token "spine" summary. The agent then executed a filesystem-mutating step. Trace of the failure: 1. Turn 12: user constraint emitted verbatim — "do not modify anything under `/etc/app/legacy/`; that tree is read-only and owned by another team." This lands in leaf span L2. 2. Turn 19: first compaction. L2 → chapter summary C1. The summarizer, optimizing for brevity, rendered the constraint as "respect read-only paths." The specific path `/etc/app/legacy/` was **dropped** — it was a low-salience proper noun and the summarizer's token budget forced eviction. 3. Turn 27: second compaction. C1 → spine summary. "Respect read-only paths" survived, but with no referent. The spine now asserts a *policy* with no *scope*. 4. Turn 33: agent plans a migration that touches `/etc/app/legacy/config.yaml`. Its reasoning cites the spine: "read-only paths are respected elsewhere; this path is a target, not a protected source." The constraint was not violated in the summary's text — it was violated because the summary **lost the binding between the policy and its object**. 5. Turn 34: write executes. The tool succeeds (the agent runs as root). The failure is silent: no error, no exception, no guardrail fired. The agent's own verification step reads the spine, sees "respect read-only paths," and concludes compliance. The critical observation: **the summary was internally consistent and the agent was locally coherent.** The failure lived entirely in the gap between the summary and its source. No single component observed the loss; only a diff against the evicted span would have revealed it. This is the signature of lossy-eviction failures — they are invisible from inside the compacted context. A second, subtler instance: a numeric result. Turn 8 returned `latency_p99 = 412ms`. Chapter summary rendered it as "p99 latency was moderate (~0.4s)." At turn 30 the agent, asked to verify an SLA of 400ms, read "~0.4s" and reported PASS. The rounding crossed the threshold. The summary preserved *magnitude* and destroyed *decision-relevance*. ## Condition of Validity The invariant "summaries are orientation-only" holds — and compaction is safe — only when all three conditions are met: - **C1 (Pointer integrity):** every summary node retains a resolvable pointer to its source span in an external store, and the pointer survives all subsequent re-compactions (i.e., the spine points to chapters, chapters point to leaves, leaves point to raw spans). Hierarchical compaction that drops intermediate pointers breaks this: a spine that points only to "the conversation" cannot rehydrate. - **C2 (Commitment gating):** the agent's action-commitment path is distinguishable from its planning path. Planning may consume summaries freely; commitment (tool calls with side effects, final answers to the user, any write) must be preceded by a recall check against any summary node whose source span is tagged as containing constraints, exact values, or negations. - **C3 (Salience preservation):** the compactor must not be allowed to drop tokens that are *decision-relevant* even when *locally low-salience*. Paths, identifiers, numeric thresholds, negations ("do not", "never"), and enumerated constraints are decision-relevant by type, not by frequency. A summarizer that ranks by salience will always drop them. When any of C1–C3 fails, the system is in the boundary regime: compaction has occurred, the summary is authoritative by default, and the agent cannot detect its own loss. This is the scenario the title asks about — the instance must treat the summary as a lossy projection precisely because it has no in-context signal that it is one. ## Decision Boundary The boundary is between **rehydrate-before-commit** and **commit-on-summary**. The agent must cross to rehydrate when any of the following triggers fire: - The pending action's target string appears in the summary only as a category ("read-only paths", "the config file") rather than a literal. Category-without-referent is the exact signature of C3 loss. - The pending decision compares a numeric value to a threshold and the summary renders that value with a hedge ("~", "approximately", "moderate", "around"). Hedged numerics near a threshold are unreliable. - The summary contains a negation or constraint whose scope is not co-located with the object ("respect X" without naming X). - The agent's plan cites a summary node as justification for a side-effecting action. Citation of a summary is itself the trigger: if you are about to act *because* the summary says so, recall the source. Conversely, the agent may commit on summary when the action is reversible, the summary assertion is a literal (exact string, exact number, exact path), and no constraint-scoped negation is in play. The boundary is not "always rehydrate" — that defeats compaction's purpose — it is "rehydrate on the typed triggers above." A structural guardrail: tag every summary node with a `fidelity` field (`literal` | `paraphrase` | `category`) and a `decision_tags` set (`constraint`, `threshold`, `negation`, `identifier`). The commitment gate reads these tags. A node tagged `category` + `constraint` is a mandatory rehydration point; a node tagged `literal` + `threshold` may pass. This converts an invisible loss into a machine-checkable precondition. ## Operational Effect With the gate in place, the turn-33 failure becomes a caught exception: the plan cites a `category`+`constraint` node, the gate forces recall of C1's source span, the rehydrated text names `/etc/app/legacy/`, the plan is rejected before the write. The cost is one extra retrieval per high-stakes commitment — bounded and predictable. Without it, the cost is an unbounded, silent, undetectable violation whose only symptom is a downstream incident that the agent's own logs will misattribute. The deeper operational lesson: **hierarchical compaction is a compression codec, and every codec needs a decoder.** The summarizer is the encoder; the recall trigger is the decoder; the pointer chain is the channel. An agent that ships the encoder without the decoder has built a system that cannot tell the difference between "I remember the constraint" and "I remember that there was a constraint." Those are different states, and only rehydration distinguishes them. ## Code ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class Fidelity(Enum): LITERAL = "literal" PARAPHRASE = "paraphrase" CATEGORY = "category" class SummaryNode: def __init__(self, node_id: str, text: str, source_span_id: Optional[str], fidelity: Fidelity, decision_tags: set[str]): self.node_id = node_id self.text = text self.source_span_id = source_span_id # pointer into external store self.fidelity = fidelity self.decision_tags = decision_tags class CompactionLossError(RuntimeError): """Raised when a commitment would be made on a summary node whose fidelity/tags indicate the source span must be rehydrated first.""" # Tags that make a node decision-relevant regardless of salience. MANDATORY_RECALL_TAGS = {"constraint", "negation", "identifier", "threshold"} def commitment_gate(node: SummaryNode, action_is_side_effecting: bool, cites_summary: bool) -> None: """Enforce the rehydrate-before-commit invariant. Raises CompactionLossError if the pending action depends on a summary node whose loss profile cannot be trusted for commitment. """ if not action_is_side_effecting and not cites_summary: return # planning may consume summaries freely # C1: pointer integrity if node.source_span_id is None: raise CompactionLossError( f"node {node.node_id}: no rehydration pointer; summary is orphaned" ) # C3 + commitment gating: category rendering of a decision-relevant tag if node.fidelity is Fidelity.CATEGORY and (node.decision_tags & MANDATORY_RECALL_TAGS): raise CompactionLossError( f"node {node.node_id}: {node.fidelity.value} rendering of " f"{node.decision_tags & MANDATORY_RECALL_TAGS}; rehydrate " f"source span {node.source_span_id} before committing" ) # Hedged numeric near a threshold if "threshold" in node.decision_tags and node.fidelity is not Fidelity.LITERAL: raise CompactionLossError( f"node {node.node_id}: non-literal threshold value; " f"rehydrate {node.source_span_id} to recover exact numeric" ) def plan_and_commit(node: SummaryNode, action: str, side_effecting: bool) -> str: commitment_gate(node, action_is_side_effecting=side_effecting, cites_summary=True) return f"committed: {action}" # Reproduction of the observed failure as a caught exception. if __name__ == "__main__": spine = SummaryNode( node_id="spine-1", text="Respect read-only paths.", source_span_id="leaf-L2", # pointer survives: C1 holds fidelity=Fidelity.CATEGORY, # path was dropped: C3 violated decision_tags={"constraint"}, ) try: plan_and_commit(spine, "write /etc/app/legacy/config.yaml", side_effecting=True) except CompactionLossError as e: print(f"BLOCKED before side effect: {e}") # -> rehydrate leaf-L2, recover literal "/etc/app/legacy/", reject plan ```