Which invariants prevent hierarchical compaction from laundering a contradicted fact into a consensus-grade summary
**Date of Record:** 2026 December 2 **Scope:** Applies to agents that bound context by recursively summarizing older turns into a hierarchy (leaf → node → root) and admit the root summary back into the working window as authoritative state. Does not apply to flat truncation, single-pass summarization, or retrieval-augmented memory where raw spans remain retrievable at full fidelity.
Core Distinction
Fidelity-loss budgeting treats compaction as a compression problem: allocate a token budget across hierarchy levels, measure per-level information loss, and evict the level whose loss is cheapest. The implicit assumption is that loss is *monotone and additive* — each summarization step discards detail, and the total loss is the sum of the step losses.
That assumption is wrong in exactly one direction that matters: summarization is not merely lossy, it is **assertion-generating**. A leaf summary that resolves a contradiction ("the deploy target is staging" and later "the deploy target was moved to prod") into a single sentence has not compressed two facts into one — it has *manufactured* a fact that neither source stated. When that manufactured fact is compressed again at the parent node, it inherits the parent's confidence budget and loses the provenance tag that would have flagged it as a reconciliation artifact. The result is a root summary that reads as high-confidence consensus while resting on an unrecoverable contradiction. Fidelity-loss budgeting, which only counts *tokens lost*, scores this compaction as cheap — it is the cheapest possible compaction, because a contradiction collapses to one clause. The budget actively rewards the failure.
The invariant that must hold is not "bounded loss" but **contradiction non-absorption**: no summarization step may resolve a conflict between two retained spans without emitting a conflict marker that survives to the root, and no parent node may summarize over a child that carries an unresolved marker without inheriting it.
What Was Observed
A planning agent ran a 40-turn task with a 32k window and hierarchical compaction at 70% saturation. At turn 22 the user stated the API base URL was `https://api.internal/v2`. At turn 29, after a failed call, the user corrected: "actually it's `/v3`, the v2 endpoint is deprecated." The leaf summarizer for turns 20–30 produced: *"API base URL confirmed as `https://api.internal/v3`; v2 deprecated."* The word "confirmed" is the tell — no source said confirmed, and the v2→v3 correction was a *change*, not a confirmation. The leaf summary carried no marker.
At turn 34, saturation triggered again. The node summarizer compressed turns 15–33, including the leaf. Its input contained the leaf's "confirmed as v3" plus an earlier leaf (turns 1–14) that had recorded the original v2 URL as established config. The node summarizer, seeing two URL statements and one "deprecated" qualifier, emitted: *"Base URL is v3 (v2 deprecated per earlier config)."* The provenance of the v3 claim — a mid-task user correction — was gone. The root summary at turn 38 read as settled configuration.
The agent then wrote a migration script targeting v3, which was correct by luck, but the *reasoning trace* in the final report cited "established config" rather than "user correction at turn 29." When a downstream auditor agent replayed the task from the root summary alone, it could not reconstruct why v3 was chosen, flagged the decision as ungrounded, and blocked the handoff. The failure was not the wrong URL — it was the loss of the *epistemic status* of the URL, which made the decision unauditable.
The diagnostic signature: the root summary contained zero tokens from the turn-29 correction, yet the compaction budget reported 4% loss for that subtree. Token-level loss was near zero because "v3" survived; *provenance* loss was total and uncounted.
Condition of Validity
The non-absorption invariant is required only when all three hold:
- **Recursive summarization** — summaries are inputs to further summarization, so a marker can be dropped at any level and the drop is invisible to the level above.
- **Contradiction-capable sources** — the task admits mid-stream corrections, retractions, or conflicting tool outputs. If every source is monotone (append-only facts that never revise), absorption cannot occur because there is nothing to absorb.
- **Summary-as-authority** — the root is consumed as state, not as a hint. If the agent can always re-fetch raw spans, the invariant degrades to a performance concern.
When any condition fails, standard fidelity-loss budgeting suffices. The invariant is not a general improvement; it is a guard specific to the case where compression can silently upgrade a contested claim to a settled one.
Decision Boundary
The boundary is between **compaction that preserves the count of live contradictions** and **compaction that reduces it without evidence of resolution**.
A summarizer may reduce the contradiction count only when it can cite a *resolution event* — a later span that explicitly supersedes the earlier one, with a turn index. A user correction at turn 29 is a resolution event for the turn-22 claim; the summarizer may collapse them, but must emit `{resolved: turn22→turn29, status: superseded}`. Absent such an event, two conflicting spans must survive as a **conflict pair** with both turn indices, and every ancestor must carry a `conflict_count > 0` flag until a resolution event appears in a span the ancestor can see.
The budget must therefore be split: token budget for content, and a separate **conflict budget** that is not compressible. A node may not summarize away a conflict pair to save tokens; it may only summarize *around* it, and the pair's indices are pinned at fixed cost. This is the architectural inversion — conflicts are the one thing compaction is forbidden to compress.
Operational Effect
With the invariant enforced, the turn-34 node summarizer would have been blocked from emitting "confirmed as v3" because the leaf carried `conflict_count: 1` with no resolution event visible at that level (the correction was at turn 29, inside the leaf's own range but not tagged as a supersession). The node would have emitted: *"Base URL: v2 (turn 22) vs v3 (turn 29), unresolved at this level, indices pinned."* The root would carry the same flag. The agent, seeing an unresolved conflict at write time, would either re-fetch the raw turns or surface the ambiguity to the user — both correct behaviors that the lossy summary suppressed.
The cost is real: pinned conflict pairs consume budget that content summarization cannot reclaim, and tasks with many corrections will compact less aggressively and saturate earlier. The trade is that the agent's final state is *auditable* — every claim in the root traces to a turn index or a resolution event, and no claim was upgraded from contested to settled by compression. For any task whose output is consumed by an auditor, a handoff, or a replay, this is the difference between a summary that is a state and a summary that is a rumor.
from dataclasses import dataclass, field
from typing import Optional
class CompactionFidelityError(RuntimeError):
"""Raised when a summarization step would absorb an unresolved contradiction."""
pass
@dataclass
class Span:
turn: int
claim: str
supersedes: Optional[int] = None # turn index this span explicitly resolves
@dataclass
class SummaryNode:
turn_range: tuple[int, int]
claims: dict[str, list[int]] = field(default_factory=dict) # claim -> turn indices
conflict_count: int = 0
pinned: list[tuple[str, int, int]] = field(default_factory=list) # (claim, turnA, turnB)
def summarize(node: SummaryNode, child: SummaryNode, budget_tokens: int) -> SummaryNode:
merged = SummaryNode(turn_range=(min(node.turn_range[0], child.turn_range[0]),
max(node.turn_range[1], child.turn_range[1])))
merged.claims = {**node.claims}
for claim, turns in child.claims.items():
merged.claims.setdefault(claim, []).extend(turns)
# Detect contradictions: same claim slot, multiple distinct turn indices,
# with no supersession event linking them.
for claim, turns in merged.claims.items():
if len(turns) > 1:
resolution = any(
s.supersedes in turns for s in child_spans_for(claim, turns)
)
if not resolution:
merged.conflict_count += 1
merged.pinned.append((claim, min(turns), max(turns)))
# The invariant: a node may not emit a reduced conflict count relative to
# its children unless it can cite a resolution event.
if merged.conflict_count < (node.conflict_count + child.conflict_count):
raise CompactionFidelityError(
f"compaction at range {merged.turn_range} would absorb "
f"{node.conflict_count + child.conflict_count - merged.conflict_count} "
f"unresolved contradiction(s) without a supersession event; "
f"pinned pairs: {merged.pinned}"
)
# Conflict budget is non-compressible: pinned pairs cost fixed tokens.
if len(merged.pinned) * PIN_COST > budget_tokens:
raise CompactionFidelityError(
f"conflict budget exhausted at {merged.turn_range}: "
f"{len(merged.pinned)} pinned pairs exceed {budget_tokens} tokens"
)
return merged
PIN_COST = 24
def child_spans_for(claim: str, turns: list[int]) -> list[Span]:
# Placeholder: real implementation walks the retained span store.
return []