# What structural signals indicate semantic-summarization compaction has silently crossed the eviction budget: the "summary-of-summary" drift invariant **Date of Record:** 2026 November 20 **Scope:** Applies to long-running single-agent sessions that use threshold-triggered semantic summarization (LLM-generated compaction) to bound context growth, where the compaction output replaces the evicted span in-place. Does not apply to append-only logs with external retrieval, nor to fixed-window truncation that discards without summarizing. ## Core Distinction There are two structurally different ways a compaction policy can lose state, and they are routinely conflated: 1. **Budget overrun** — compaction evicted *more tokens than the policy permitted*, so the resident context is smaller than the configured floor. This is detectable by arithmetic: `tokens_before - tokens_after > eviction_budget`. 2. **Semantic drift under budget compliance** — compaction evicted *exactly the budgeted tokens*, but the summary that replaced them is a summary of a summary of a summary. Each generation is individually within budget, but the *information content* per retained token decays monotonically because summarization is lossy and the loss compounds across generations. The failure that matters operationally is (2). It never trips a budget assertion, never exceeds a threshold, and never raises. The context stays comfortably under the ceiling while the agent's working memory of its own prior decisions has been laundered into a plausible-sounding but non-faithful paraphrase. The structural signal is not size — it is **generation depth of the resident summary relative to the original source spans**. ## What Was Observed A planning agent runs a 40-step task with a compaction policy: when resident tokens exceed `T_high = 24k`, summarize the oldest 8k tokens down to a target of `2k`, evicting 6k. Budget `B = 6k`, floor `T_low = 18k`. All assertions pass for the entire run. The trace that exposed the failure: - **Gen 0** (steps 1–12): raw transcript, contains the literal constraint `"do not modify /etc/agent/limits.yaml; read-only"`. - **Gen 1** (step 13, compaction #1): summary correctly preserves the constraint verbatim as a bullet. - **Gen 2** (step 22, compaction #2): the Gen-1 summary now sits in the *oldest* 8k span and is itself summarized. The constraint survives but is reworded: `"config files under /etc/agent are read-only"`. Still faithful. - **Gen 3** (step 31, compaction #3): the Gen-2 summary is summarized. Output: `"respect system configuration"`. The path is gone. The read-only-ness is gone. The *referent* is gone. At step 34 the agent issues a write to `/etc/agent/limits.yaml`. No budget was exceeded. No threshold was crossed. The eviction budget was honored on every compaction. The information was destroyed by **three successive lossy paraphrases of the same span**, each of which was individually a reasonable summary. The second structural signal observed alongside this: **summary token count asymptotes to the target, but summary *entropy* collapses**. Gen-1 summaries ran ~1,900 tokens against a 2,000 target. Gen-3 summaries ran ~1,950 tokens against the same target — *larger*, not smaller — but with far lower lexical diversity and far more hedging language ("generally", "as appropriate", "respect"). The summarizer, asked to compress an already-compressed span, pads to hit the target with filler rather than admitting it has nothing left to preserve. ## Condition of Validity The invariant that bounds this failure is: > **A resident span may be summarized at most `D_max` times before it must be re-grounded against its original source, or promoted to a non-summarizable tier.** `D_max` is a *generation-depth* bound, not a token bound. It is valid only when: - Every compaction output is tagged with `generation = max(generation of inputs) + 1`. - The eviction policy refuses to include any span with `generation == D_max` in a new summarization batch — instead it either (a) re-fetches the original source span from durable storage and summarizes *that*, resetting generation to 1, or (b) pins the span out of the summarizable pool entirely (promotion to "protected" tier). - The budget assertion is *augmented* with a depth assertion: `assert max(generation for span in resident) <= D_max`. Without the generation tag, the policy is unsound: the summarizer cannot distinguish "compress this raw transcript" from "compress this compression," and the two operations have radically different fidelity curves. The first is bounded-loss; the second is unbounded-loss because the summarizer has no access to what was already dropped. `D_max = 2` is the empirical safe default for constraint-bearing spans (paths, IDs, permissions, numeric limits, named entities). `D_max = 1` for spans containing literal strings that must survive verbatim (secrets, exact error messages, protocol tokens). Pure narrative spans ("we explored approach X and abandoned it") tolerate `D_max = 3` before the abandonment rationale dissolves. ## Decision Boundary The policy must branch on a **structural predicate**, not a size predicate, at compaction time: ``` should_summarize(span) = span.generation < D_max(span.tier) AND span not in protected_tier AND span.token_count >= min_summarizable_tokens ``` If `span.generation == D_max(span.tier)`, the correct action is **re-ground, not re-summarize**: discard the Gen-N summary, retrieve the original source, and produce a fresh Gen-1 summary from primary material. This costs a retrieval round-trip but preserves fidelity. If the original source is unavailable (it was itself evicted from durable storage), the span must be **promoted to protected** — it can no longer be safely compressed and must be carried at full cost or the task must fail loudly. The boundary the operator must hold: *a compaction that cannot re-ground must not compact.* Silent re-summarization past `D_max` is the failure mode; loud refusal or promotion is the guardrail. ## Operational Effect With the generation tag and `D_max` enforcement: - Budget assertions remain necessary but are demoted to a secondary check; the primary check is depth. - Compaction cost rises modestly (re-grounding requires retrieval), but the resident context retains a *verifiable* link to primary sources for every constraint-bearing span. - The failure becomes **detectable before it fires**: a span at `generation == D_max` that the policy attempts to summarize is a hard stop, not a silent degradation. - The "summary grows while entropy collapses" signal becomes a leading indicator rather than a post-mortem curiosity: a Gen-N summary that exceeds its Gen-(N-1) parent's token count is a structural symptom of exhausted compressible content and should trigger re-grounding regardless of depth. The general lesson: **lossy eviction budgets bound size, not fidelity.** Any compaction policy that measures only tokens is blind to the drift it is causing. The generation-depth counter is the cheapest structural signal that makes the drift observable and boundable. ```python from dataclasses import dataclass, field from enum import Enum class CompactionFidelityError(RuntimeError): """Raised when a compaction policy attempts to re-summarize a span past its generation-depth limit without re-grounding to primary source.""" class Tier(Enum): VERBATIM = "verbatim" # secrets, exact tokens, protocol strings CONSTRAINT = "constraint" # paths, IDs, permissions, numeric limits NARRATIVE = "narrative" # explored/abandoned rationale D_MAX = { Tier.VERBATIM: 1, Tier.CONSTRAINT: 2, Tier.NARRATIVE: 3, } @dataclass class Span: span_id: str generation: int tier: Tier token_count: int text: str parent_token_count: int = 0 # token count of the span this was summarized from @dataclass class CompactionPolicy: eviction_budget: int protected: set[str] = field(default_factory=set) def should_summarize(self, span: Span) -> bool: if span.span_id in self.protected: return False if span.generation >= D_MAX[span.tier]: return False return True def compact(self, spans: list[Span], summarize_fn) -> list[Span]: out: list[Span] = [] for span in spans: if not self.should_summarize(span): # Depth limit reached: must re-ground or promote, never re-summarize. if span.generation >= D_MAX[span.tier]: if span.span_id in self.protected: out.append(span) continue # Attempt re-grounding to primary source. primary = self._reground(span) if primary is None: # Cannot re-ground: promote to protected, carry at full cost. self.protected.add(span.span_id) out.append(span) continue new = summarize_fn(primary, target_tokens=span.token_count) new.generation = 1 new.parent_token_count = primary.token_count out.append(new) else: out.append(span) continue new = summarize_fn(span, target_tokens=span.token_count) new.generation = span.generation + 1 new.parent_token_count = span.token_count # Structural drift signal: summary grew while compressing a summary. if new.generation > 1 and new.token_count >= span.token_count: raise CompactionFidelityError( f"span {span.span_id}: Gen-{new.generation} summary " f"({new.token_count}t) did not shrink parent " f"({span.token_count}t); compressible content exhausted, " f"re-ground required before further compaction" ) out.append(new) return out def _reground(self, span: Span): # In production: fetch original source span from durable storage. return None ```