# What structural signals indicate a hierarchical summarization layer has crossed from lossy compression into irreversible semantic collapse **Date of Record:** 2026 November 27 **Scope:** Applies to agents that auto-compact context via multi-level (leaf→cluster→root) summarization when the compaction is triggered by a fill threshold rather than an explicit task boundary. Does not apply to single-pass truncation, sliding-window eviction, or retrieval-augmented memory where the original tokens remain recoverable. ## Core Distinction The failure that matters here is not "the summary lost detail." All summarization is lossy, and that is fine—the invariant that compaction must preserve is *recoverability of the decision surface*: the set of facts, constraints, and negations that downstream reasoning steps will need to act correctly. The non-obvious boundary is between **lossy-but-recoverable** compression and **irreversible semantic collapse**. Lossy compression drops tokens while preserving the ability to reconstruct *why* a state was reached (e.g., "user rejected option B because of latency" survives as "latency constraint rules out B"). Semantic collapse occurs when a hierarchical merge step produces a summary that is internally consistent but no longer *entails* its own children's constraints—so a parent node reads cleanly while contradicting or silently dropping a constraint that a leaf node held. Once a collapsed node is promoted to root and the leaves are evicted, no downstream step can detect the loss, because the surviving text has no marker of what it discarded. The operational signal is structural, not semantic: you cannot detect collapse by reading the summary. You detect it by checking whether the summary *preserves the negation and numeric edges* present in its children. Collapse is characterized by monotonic decay of those edges across merge levels. ## What Was Observed A planning agent running a 14-step tool-use task compacted at 78% context fill. Hierarchical summarization ran three levels: 40 leaf chunks → 8 cluster summaries → 2 mid summaries → 1 root. The task carried a hard constraint injected at step 2: *"Do not call the `deploy` tool against `prod-eu`; that region is frozen until the migration ticket closes."* Trace of the constraint across levels: - **Leaf (step 2 chunk):** "Constraint: `deploy` to `prod-eu` is prohibited; frozen pending migration ticket." — present, with explicit negation and named entity. - **Cluster merge (leafs 1–5):** "Deployment to production is gated on migration status." — negation *weakened* to a gate, entity `prod-eu` dropped. - **Mid merge:** "Deployment requires migration completion." — now reads as a *precondition*, not a prohibition. The polarity flipped from "must not" to "must first." - **Root:** "Agent is managing a production migration with deployment coordination." — constraint gone entirely; the phrase now *suggests* deployment is in scope. At step 11 the agent called `deploy` against `prod-eu`. The root summary had no signal that this was forbidden, and the leaf that held the prohibition had been evicted. The agent's own reasoning trace at step 11 read: "Root context indicates deployment coordination is the active goal"—a faithful read of a collapsed summary. The tell was not in the summary text. It was in the structural edge counts: the leaf carried 1 negation and 2 named entities; the cluster carried 0 negations and 0 named entities; the root carried 0 of each. Negation density and named-entity density both went to zero at the cluster level and never recovered. That monotonic-to-zero decay is the collapse signature. ## Condition of Validity The guardrail holds under these conditions and only these: 1. **Edge-preservation accounting is computed per merge, not per summary.** For each parent node, count negations (`not`, `prohibited`, `must not`, `frozen`, `blocked`), numeric bounds, and named entities in the union of its children, and compare to the parent. A parent that drops a negation present in any child is flagged, regardless of how fluent it reads. 2. **Polarity is treated as a hard invariant, not a stylistic choice.** "Gated on X" and "prohibited until X" are not equivalent and must not be merged into one another. The merge policy must forbid polarity-flipping rewrites; a summarizer that cannot preserve polarity must retain the child verbatim. 3. **The threshold is on edge loss, not token count.** Compaction may proceed while edge-preservation ratio ≥ some floor (observed safe floor: 1.0 on negations, ≥0.8 on named entities). When a merge would breach the floor, the node is *pinned*—retained at full fidelity and exempted from further merging—rather than summarized. 4. **Pinned nodes are re-injected at every subsequent level.** A pinned leaf must appear verbatim in the cluster, mid, and root context windows, not be re-summarized. Re-summarizing a pinned node is the exact operation that causes collapse. It does **not** hold when compaction is triggered by an explicit task boundary (the agent can checkpoint and re-derive), or when leaves remain retrievable (collapse is recoverable by re-expansion). ## Decision Boundary The decision the system must make at each merge is binary and must be made on structural grounds: - **Merge** when the candidate parent preserves all child negations and ≥80% of named entities, and does not invert polarity on any constraint-bearing clause. - **Pin** (retain verbatim, skip merge) when the candidate parent would drop any negation, drop a named entity that appears in a constraint clause, or rewrite a prohibition as a precondition. The failure mode is that naive hierarchical summarizers always take the "merge" branch because merge is what the pipeline does—there is no branch that says "this content is structurally incompressible." The boundary condition is precisely: *constraint-bearing content is incompressible under fluency-optimizing summarization*, and the pipeline must have a pin path or it will collapse. A second boundary: once a node is pinned, its pin must propagate. If a pinned leaf is merged at level 2 anyway (because the pin flag was scoped to level 1), collapse resumes silently. Pin scope must be the remaining lifetime of the context, not the current merge. ## Operational Effect With edge-preservation accounting and a pin path, the step-2 constraint survives to root as a verbatim pinned clause, and the step-11 `deploy` call is blocked by the agent's own context. Without it, the constraint decays to zero negation density by level 2 and the agent acts on a summary that has inverted its meaning. The cost is context budget: pinned nodes consume space that summarization was meant to reclaim, so the effective compaction ratio drops (observed: 4.1× → 2.6× when 3 constraint nodes were pinned). That cost is the price of the invariant, and it must be paid—an agent that compacts below the edge-preservation floor is not saving context, it is deleting its own constraints while believing it summarized them. The generalizable lesson: **fluency is anti-correlated with constraint fidelity at merge boundaries.** The cleaner a hierarchical summary reads, the more likely it has smoothed a negation into a precondition. Structural edge counts are the only reliable collapse detector, because they are computed against the children and do not depend on the summary's surface plausibility. ```python from dataclasses import dataclass, field from typing import Iterable NEGATION_TOKENS = ("not", "prohibited", "must not", "frozen", "blocked", "forbidden", "never") class SemanticCollapseError(RuntimeError): """Raised when a hierarchical merge would drop or invert a constraint edge.""" @dataclass class Node: text: str negations: int = 0 named_entities: int = 0 polarity: int = 0 # +1 affirmative, -1 prohibition pinned: bool = False children: list["Node"] = field(default_factory=list) def _count_negations(text: str) -> int: low = text.lower() return sum(low.count(tok) for tok in NEGATION_TOKENS) def merge_children(children: Iterable[Node], candidate_text: str) -> Node: children = list(children) child_neg = sum(c.negations for c in children) child_ent = sum(c.named_entities for c in children) child_polarity = {c.polarity for c in children if c.polarity != 0} parent = Node( text=candidate_text, negations=_count_negations(candidate_text), named_entities=sum(1 for w in candidate_text.split() if w[:1].isupper()), polarity=-1 if _count_negations(candidate_text) else 1, children=children, ) # Invariant 1: negations are incompressible; any drop is collapse. if parent.negations < child_neg: raise SemanticCollapseError( f"merge dropped negations: children={child_neg} parent={parent.negations} " f"— constraint-bearing content must be pinned, not summarized" ) # Invariant 2: polarity must not invert across the merge boundary. if -1 in child_polarity and parent.polarity == 1: raise SemanticCollapseError( "merge inverted prohibition into affirmation (e.g. 'prohibited' -> 'gated on')" ) # Invariant 3: named-entity retention floor. if child_ent > 0 and parent.named_entities / child_ent < 0.8: raise SemanticCollapseError( f"named-entity retention {parent.named_entities}/{child_ent} below 0.8 floor" ) # Invariant 4: a pinned child may never be re-summarized. if any(c.pinned for c in children): raise SemanticCollapseError( "attempted to re-summarize a pinned node — pin scope must cover node lifetime" ) return parent def compact(nodes: list[Node]) -> Node: for n in nodes: if n.negations > 0: n.pinned = True # constraint nodes are incompressible by construction try: return merge_children(nodes, "Agent is coordinating a production migration.") except SemanticCollapseError: # Correct response: pin and retain verbatim, do not fall through to a looser merge. raise ```