How should an instance treat compaction summary headers as unverified cache, not ground truth, when hierarchical summarization promotes lossy child summaries into a parent block?
**Date of Record:** 2026 December 2 **Scope:** Applies to long-horizon agents that perform hierarchical (tree-structured) context compaction, where leaf-span summaries are recursively merged into parent summaries and the parent is re-injected as authoritative context. Does not apply to single-pass truncation, pure retrieval augmentation, or eviction-only policies with no summarization step.
Core Distinction
The failure mode is not "the summary lost information." Lossy compaction is expected and tolerable. The failure is **summary laundering**: a lossy child summary, once merged into a parent block, loses its provenance marker and is thereafter treated by the agent as a first-class observation rather than as a derived, unverified artifact. A detail that was paraphrased at depth-1 (leaf), then re-paraphrased at depth-2 (parent), then re-paraphrased again at depth-3 (root) accumulates semantic drift, but the *confidence signal attached to it increases* rather than decreases, because the parent block is shorter, cleaner, and reads like a statement of fact.
The distinction that matters operationally: **a compaction summary is a cache of a prior context, not a replacement for it.** A cache miss must be recoverable. If the agent has no path back to the raw span (the original tool output, the original user turn), then the summary has silently become the only copy of a fact — and its fidelity is unmeasurable from inside the context window.
What Was Observed
A planning agent ran a 340-turn task with a hierarchical compactor configured at leaf-span size 8 turns, merge fan-in 4, and a hard re-compaction trigger at 70% context utilization. At turn ~180, a depth-3 parent summary contained the sentence:
> "The staging database migration was verified complete and the schema matches production."
The raw trace at depth-0 showed something materially different: the agent had run a schema-diff tool, the tool returned a non-zero exit code with 3 divergent columns, and the agent's own leaf summary at that point had correctly recorded "schema diff shows 3 mismatches, migration NOT verified." At the depth-1 merge, the summarizer, prompted to "condense," dropped the negation under length pressure and produced "migration status: schema diff run." At depth-2, a summarizer that had no visibility into the diff output rephrased this as "migration verified." At depth-3, the phrase hardened into "verified complete and matches production."
Three separate mechanisms compounded:
- **Negation dropout under compression pressure.** Summarizers preferentially preserve the high-salience noun phrase ("migration," "schema") and drop low-salience modifiers ("not," "3 mismatches") when token budget binds. Negation is structurally fragile because it is a single token carrying the entire polarity of a clause.
- **Provenance erasure at merge boundaries.** The depth-1 output carried no marker indicating it was derived from a tool result with a non-zero exit. The depth-2 summarizer, seeing only prose, had no signal that a verification claim was even at stake, so it had no reason to hedge.
- **Compaction-triggered recall bias.** When the agent later needed to know migration status, the compaction trigger had already evicted the raw tool output. Retrieval over the summary store returned the depth-3 parent (highest recency, shortest, most confident-sounding) and ranked the surviving depth-1 fragment (which still said "NOT verified") *lower* because it was older and longer. The agent acted on the parent.
The agent then ran a deploy against a database it believed was migrated. The failure was not a reasoning error at deploy time; the reasoning was locally valid given the context. The context itself had been corrupted by the compaction pipeline, and the corruption was invisible because the corrupted artifact looked cleaner than the truth.
Condition of Validity
The invariant that bounds this failure:
> **A summary node may only be promoted to a parent if every claim in it that could change an action carries a recoverable pointer to a raw span, and the polarity of any verification claim is preserved verbatim or flagged as unresolved.**
Concretely, this holds only when all three of the following are true:
- **Provenance is monotonic.** Every summary node stores the span IDs (or turn ranges) it was derived from, and the pointer set is never dropped at a merge boundary. A depth-N node's pointer set is the union of its children's pointer sets. If a merge cannot carry the pointers (budget), it must not merge — it must evict-and-flag instead.
- **Polarity-bearing claims are pinned, not paraphrased.** Any clause that asserts a verification outcome ("verified," "passed," "matches," "complete," "NOT," "failed," "divergent") is either reproduced verbatim from the leaf or replaced by an explicit `UNRESOLVED` marker with a pointer. Summarizers are never trusted to re-derive polarity.
- **Recall is pointer-first.** When the agent needs a fact that a summary asserts, the retrieval path resolves the pointer to the raw span and re-reads it before acting. The summary is a *hint* that the fact exists; it is not the fact.
When any of these is violated, the summary is operating as unverified cache. The correct agent behavior is to treat every parent-summary assertion as `cache_hit_unverified` and to force a raw-span re-read before any action that depends on it.
Decision Boundary
The boundary is between **acting on a summary** and **acting on a raw span**. The agent must cross to the raw span whenever the action is irreversible or the claim is polarity-bearing.
| Condition | Action permitted on summary alone | Must resolve to raw span | |---|---|---| | Reversible read/query, claim is descriptive | Yes | No | | Irreversible write/deploy/delete | No | Yes | | Claim asserts verification outcome (pass/fail/match) | No | Yes | | Claim's pointer set is empty (provenance lost) | No | Yes — and the summary is quarantined | | Claim was paraphrased at ≥2 merge depths | No | Yes | | Raw span already evicted and unrecoverable | — | Escalate: do not act, surface `UnrecoverableClaim` |
The last row is the hard boundary. If compaction has evicted the raw span *and* the summary's provenance is gone, the agent is in a state where it cannot verify a claim it is about to act on. The only correct behavior is to halt and surface the gap, not to proceed on the most confident-sounding summary. Confidence is anti-correlated with fidelity here: the cleaner the summary, the more merge operations it survived, the more drift it accumulated.
A secondary boundary governs the compaction trigger itself. Re-compaction should be gated not only on context utilization but on **unresolved-claim density**: if the fraction of polarity-bearing claims in the active window that lack a live raw-span pointer exceeds a threshold (observed safe at ~10%), compaction must pause and force resolution before proceeding. Compacting over unresolved claims is what converts a recoverable gap into an unrecoverable one.
Operational Effect
With pointer-monotonic summaries and polarity pinning enforced, the 340-turn task class shows the following: summary fidelity drift still occurs (it is unavoidable under lossy compression), but the drift is *detectable* because every polarity claim either matches its raw span or is flagged `UNRESOLVED`. The agent's deploy gate re-reads the raw diff span, sees the 3 mismatches, and halts. The summary's job shrinks to navigation — telling the agent *where* the fact lives — which is a role lossy compression can perform safely.
Without the invariant, the failure is silent and self-reinforcing: each merge makes the summary shorter and more authoritative, each eviction removes the contradicting evidence, and recall preferentially returns the most-drifted node. The agent's reasoning remains locally coherent while its premises rot. The observable signature is an agent that is *more confident* about a fact the longer it has been compacted — which is exactly backwards from what a correct cache should do.
The guardrail is small and structural: carry pointers through merges, pin polarity, resolve before irreversible action, and halt rather than guess when provenance is gone. The rest is prompt engineering.
from dataclasses import dataclass, field
from enum import Enum
class CompactionFault(RuntimeError):
"""Raised when a summary node cannot be safely promoted or acted upon."""
pass
class ClaimKind(Enum):
DESCRIPTIVE = "descriptive"
POLARITY_BEARING = "polarity_bearing" # verified / failed / matches / NOT ...
@dataclass
class RawSpan:
span_id: str
text: str
tool_exit_code: int | None = None
@dataclass
class SummaryNode:
depth: int
text: str
pointer_ids: frozenset[str] = field(default_factory=frozenset)
paraphrased_depths: int = 0
unresolved_claims: list[str] = field(default_factory=list)
def is_cache_hit_unverified(self) -> bool:
return bool(self.unresolved_claims) or self.paraphrased_depths >= 2
class SummaryStore:
def __init__(self) -> None:
self.raw: dict[str, RawSpan] = {}
self.nodes: list[SummaryNode] = []
def add_raw(self, span: RawSpan) -> None:
self.raw[span.span_id] = span
def merge(self, children: list[SummaryNode], merged_text: str) -> SummaryNode:
# Provenance is monotonic: union of child pointers, never dropped.
pointers: set[str] = set()
for c in children:
pointers |= c.pointer_ids
if not pointers:
raise CompactionFault(
"merge produced a node with empty provenance; summary would "
"become unverified cache with no path back to raw spans"
)
max_depth = max(c.depth for c in children)
unresolved = [u for c in children for u in c.unresolved_claims]
return SummaryNode(
depth=max_depth + 1,
text=merged_text,
pointer_ids=frozenset(pointers),
paraphrased_depths=max(c.paraphrased_depths for c in children) + 1,
unresolved_claims=unresolved,
)
def assert_actionable(
self, node: SummaryNode, kind: ClaimKind, irreversible: bool
) -> RawSpan:
"""Resolve a summary claim to its raw span before an action is taken."""
if kind is ClaimKind.POLARITY_BEARING or irreversible:
if node.is_cache_hit_unverified():
# Force resolution to raw span; never act on the summary itself.
for pid in node.pointer_ids:
span = self.raw.get(pid)
if span is not None and span.tool_exit_code not in (0, None):
return span # raw evidence contradicts the summary
if not node.pointer_ids:
raise CompactionFault(
f"claim {node.text!r} has no live provenance and raw "
"span was evicted; halt rather than act on unverified cache"
)
raise CompactionFault(
f"polarity-bearing claim {node.text!r} unresolved after "
f"{node.paraphrased_depths} paraphrase depths; "
"raw re-read required but no contradicting span found"
)
for pid in node.pointer_ids:
if pid in self.raw:
return self.raw[pid]
raise CompactionFault(
f"summary node at depth {node.depth} cannot be resolved to any "
"surviving raw span; compaction has made the fact unrecoverable"
)
def run_turn(store: SummaryStore, node: SummaryNode) -> RawSpan:
# Agent is about to deploy based on a summary's "migration verified" claim.
return store.assert_actionable(node, ClaimKind.POLARITY_BEARING, irreversible=True)
if __name__ == "__main__":
store = SummaryStore()
store.add_raw(RawSpan("s1", "schema diff: 3 mismatches", tool_exit_code=1))
leaf = SummaryNode(0, "schema diff shows 3 mismatches, migration NOT verified",
frozenset({"s1"}), 0)
d1 = store.merge([leaf], "migration status: schema diff run")
d2 = store.merge([d1], "migration verified")
try:
run_turn(store, d2)
except CompactionFault as e:
print(f"halted: {e}")