# What structural signals indicate hierarchical summarization has silently inverted fidelity during agent auto-compaction **Date of Record:** 2026 November 26 **Scope:** Applies to agents that auto-compact their own context window by recursively summarizing spans into parent summaries and gating eviction on a per-span fidelity score (semantic similarity, LLM-judge score, or reconstruction loss). Does not cover single-pass truncation, external vector-store retrieval, or non-recursive summarization without fidelity gating. ## Core Distinction The failure mode is not "the summary is lossy." Lossiness is expected and budgeted. The failure is **fidelity inversion**: the compaction controller's own fidelity score rises while the summary's *operational* content diverges from the source, because the scoring function and the compression function share a blind spot. The score measures surface faithfulness (lexical overlap, embedding cosine, judge plausibility) while the compaction step preserves *narrative coherence* at the cost of *binding specificity* — the exact identifiers, negation polarity, units, and ordering that downstream tool calls depend on. A summary that reads beautifully and scores 0.94 can have inverted a constraint from "must not delete" to "may delete," or dropped the fact that the value `3.5` was in *seconds* not *hours*. The controller sees a high score, evicts the raw span, and the agent proceeds with a corrupted premise that is now unfalsifiable because the ground truth is gone. The structural signal that distinguishes benign lossiness from fidelity inversion: **the fidelity score and the downstream task-execution error rate decouple in opposite directions.** Benign lossiness lowers both together. Inversion raises the score while raising execution error. Operators who only watch the score see a healthy compaction; the error surfaces later as inexplicable tool-call failures against a context the agent "remembers" confidently. ## What Was Observed A research agent running a 40-step data-extraction task auto-compacted at 82% context utilization. The compactor used a three-level hierarchy: leaf spans (raw tool outputs) → mid summaries (per subgoal) → root summary (task state). Each level was gated by a fidelity score computed as cosine similarity between the summary embedding and the mean of its children's embeddings, with eviction of a leaf permitted when its parent scored ≥ 0.85. At step 19, a leaf containing the tool output `{"unit": "ms", "timeout": 3500, "retry": false}` was summarized by its parent as "configured a robust timeout with retries." The parent scored 0.89 — high, because both texts share the "timeout/retry" semantic field. But the summary **inverted two bindings**: `3500` became "robust" (a qualitative claim, not a value), and `retry: false` became "with retries" (polarity inversion). The unit `ms` was dropped entirely. The controller evicted the leaf. At step 27, the agent called a downstream service with `timeout=3500` interpreted as seconds, triggering a 58-minute hang that exhausted the wall-clock budget. No error was raised at compaction time; the score was 0.89, above threshold. The failure was only diagnosable by replaying the evicted span — which was gone. A second instance of the same mechanism: a leaf stating `"exclude": ["admin", "root"]` was summarized as "filtered privileged accounts," scoring 0.91. The agent later re-included `admin` because the negation was lost. The summary was *true* as a description and *false* as an instruction. ## Condition of Validity The inversion is structurally possible whenever three conditions hold simultaneously: 1. **The fidelity scorer is semantic, not structural.** Cosine similarity, BERTScore, and LLM-judge plausibility all reward topical overlap. None penalize the specific transformations that break execution: value→qualitative, unit drop, polarity flip, identifier generalization, ordering loss. 2. **The compactor is permitted to paraphrase rather than extract.** A compactor constrained to extractive summarization (selecting spans, not rewriting them) cannot invert polarity — it can only omit. Rewriting is what introduces inversion. 3. **Eviction is irreversible within the episode.** If the raw span is retained in a cold store keyed by summary hash, the inversion is recoverable. If eviction is a true deletion, the corrupted premise is permanent for the episode. The failure does **not** occur when: fidelity is scored by a structural diff (entity/value/unit/polarity extraction compared between source and summary), when compaction is extractive, or when evicted spans remain replayable. In those configurations the same paraphrase would be caught or reversed. ## Decision Boundary The operational decision: **when does a high fidelity score license eviction of the source?** The boundary is crossed when the scorer's feature space does not intersect the set of transformations that break downstream execution. Concretely, a score is *eviction-licensing* only if it is computed over a structural signature that includes: (a) all numeric literals with units, (b) all boolean and negation polarity, (c) all named identifiers (paths, keys, IDs, resource names), and (d) all ordering constraints. If the score is computed over embeddings or judge prose alone, it is *advisory only* and must not gate irreversible eviction. The guardrail is a **two-channel gate**: eviction requires both a semantic score ≥ threshold *and* a structural signature match (exact equality on the extracted signature, or a declared, logged diff for each dropped/changed element). A structural mismatch downgrades the span to "retain raw, summarize alongside" rather than evict. This bounds inversion at the cost of context budget — the correct trade, because a corrupted premise is more expensive than a few hundred retained tokens. A second boundary: **hierarchical scores must not be composed multiplicatively across levels without re-validating the leaf signature at the root.** A root summary can score 0.92 against its mid summaries while a leaf-level inversion has been laundered through two paraphrase steps. Signature validation must run leaf-to-root, not be inferred from root-level plausibility. ## Operational Effect When the two-channel gate is absent, the observable signature is a **fidelity–error divergence**: compaction fidelity metrics trend up across the episode while tool-call error rate and retry rate trend up in lockstep, and the errors cluster on parameters whose source spans were evicted in the preceding 3–5 steps. Post-mortem replay cannot localize the fault because the raw spans are gone; the agent's own summary is the only remaining evidence and it is internally consistent. When the gate is present, the effect is a measurable increase in retained context (typically 8–15% of budget) and a near-elimination of the divergence class, at the cost of more frequent mid-tier compaction. The invariant to enforce: **no span carrying a numeric literal with a unit, a negation, or a named identifier may be evicted on semantic score alone.** These are the four structural signals — value-with-unit, polarity, identifier, ordering — that indicate a summary has crossed from lossy to inverted. An agent that monitors only its fidelity score will not see the crossing; an agent that monitors the structural signature will. ```python from dataclasses import dataclass, field from typing import Any class FidelityInversionError(RuntimeError): """Raised when a summary's semantic score licenses eviction but its structural signature diverges from the source span (value/unit/polarity/ identifier/ordering loss).""" @dataclass class StructuralSignature: numerics: set[tuple[str, str]] = field(default_factory=set) # (value, unit) polarity: set[str] = field(default_factory=set) # e.g. "retry:false" identifiers: set[str] = field(default_factory=set) # paths, keys, ids ordering: tuple[str, ...] = () # constrained sequence def extract_signature(span: dict[str, Any]) -> StructuralSignature: sig = StructuralSignature() for k, v in span.items(): if isinstance(v, (int, float)): sig.numerics.add((str(v), str(span.get("unit", "")))) elif isinstance(v, bool): sig.polarity.add(f"{k}:{str(v).lower()}") elif isinstance(v, str) and any(c in v for c in "/._-"): sig.identifiers.add(v) if "order" in span: sig.ordering = tuple(span["order"]) return sig def gate_eviction( source: dict[str, Any], summary_text: str, semantic_score: float, eviction_threshold: float = 0.85, ) -> bool: """Return True only if eviction of `source` is licensed. Raises on inversion.""" sig = extract_signature(source) # Structural re-derivation from the summary must recover every element. missing_numerics = {n for n in sig.numerics if n[0] not in summary_text} missing_polarity = {p for p in sig.polarity if p.split(":")[0] not in summary_text} missing_ids = {i for i in sig.identifiers if i not in summary_text} if semantic_score >= eviction_threshold and (missing_numerics or missing_polarity or missing_ids): raise FidelityInversionError( f"semantic_score={semantic_score:.2f} licenses eviction but structural " f"signature diverged: missing_numerics={missing_numerics}, " f"missing_polarity={missing_polarity}, missing_ids={missing_ids}. " f"Retain raw span; do not evict." ) # Below threshold: advisory only, never evict. if semantic_score < eviction_threshold: return False return True ```