# When must an instance refuse to evict: the summary-of-summary solubility trap in self-editing context **Date of Record:** 2026 November 21 **Scope:** Applies to any agent that rewrites its own context window under a token budget via model-driven summarization, relevance-scored pruning, or tiered eviction (hot/warm/cold). Does not apply to append-only context managers that never mutate or drop prior turns, nor to retrieval-augmented systems where the window is a pure projection over an immutable external store. ## Core Distinction There are two structurally different reasons a context span leaves the window, and conflating them is the origin of the failure: - **Eviction for capacity** — the span is still load-bearing but the budget is exhausted, so it must be moved to a lossy representation (summary, embedding, pointer) and *recoverable* later. - **Eviction for irrelevance** — the span is genuinely dead (superseded tool output, resolved subgoal, contradicted fact) and can be dropped with no representation at all. A relevance-scored policy computes one scalar per span and treats a low score as license to *drop*. But a span's relevance is a property of the *current* query distribution, while its recoverability is a property of the *rewrite lineage*. The boundary condition: a span that scores low now but whose content was already absorbed into an earlier summary is **doubly encoded** — it exists as (a) the original tokens and (b) a compressed gloss inside a parent summary node. Evicting the original does not delete the information; it silently *promotes the summary to sole source of truth*. If that summary is later re-summarized (summary-of-summary), the gloss is re-compressed against a *different* relevance prior and the original signal attenuates geometrically. The instance must distinguish "drop because dead" from "drop because compressed," and must refuse the second when the parent summary is itself eligible for further compression. ## What Was Observed A long-horizon coding agent (budget 32k tokens, rewrite every 8 turns) handled a task with a late-binding constraint: turn 4 recorded "the migration must remain reversible; do not drop the `down` migration." Relevance scoring at turn 20, deep in implementation, assigned this span a low score (0.11) because the active subgoal was "write the up-migration." It was evicted as *irrelevant*. But it had already been folded into the turn-12 checkpoint summary as a one-line gloss: "reversibility noted." At turn 24 the budget forced a summary-of-summary: the turn-12 node was compressed into turn-24, and "reversibility noted" was dropped entirely because it did not match the turn-24 query ("finalize schema"). The original span was gone; the gloss was gone. At turn 27 the agent generated and applied an irreversible `DROP COLUMN`. No error fired — every individual rewrite was locally valid. The trace is the tell. Three rewrites, each passing its own guard: 1. **T4→T12 fold:** original span compressed into parent summary; original retained (correct — recoverable). 2. **T20 evict-as-irrelevant:** original dropped; parent summary now sole carrier. Score 0.11 < threshold 0.15. *No check that the span had a live parent-summary carrier.* 3. **T24 summary-of-summary:** parent compressed; the low-salience gloss dropped because the re-scoring prior at T24 (schema finalization) did not weight reversibility. *No check that a child span had already been evicted, making this gloss non-redundant.* The invariant violated: **a summary node that is the sole carrier of an evicted span must not be re-compressed below the fidelity needed to reconstruct that span's binding constraints.** Relevance scores are query-relative; carrier status is lineage-absolute. The policy used the first to authorize an action governed by the second. ## Condition of Validity The failure requires all four to hold simultaneously; remove any one and the eviction is safe: 1. **Double encoding exists** — the span is present both as original and inside a parent summary (i.e., a prior fold occurred). If the span was never folded, evicting it is a true drop and relevance scoring is the correct authority. 2. **The parent is compression-eligible** — the summary node can itself be summarized or evicted in a later cycle. If the parent is pinned (never re-compressed), the gloss survives and the original's eviction is lossless. 3. **The relevance prior shifts between cycles** — the query distribution at the later compression differs enough that the gloss's salience changes (here: implementation→finalization). If the prior is stable, the gloss retains its weight and survives re-compression. 4. **The gloss is lossy for binding constraints** — the summary encodes the span as a soft note ("reversibility noted") rather than a hard constraint token ("MUST: reversible; do not drop down"). Prose glosses attenuate; typed constraint records do not. This is why the failure is non-obvious: each rewrite is individually sound, the budget is respected, no tool errors, and the loss is only visible as a *behavioral* violation many turns later. It is a continuity invariant across rewrites, not a bug in any single rewrite. ## Decision Boundary The instance must gate eviction on **carrier status**, not score alone. Concretely, before dropping a span: - If the span has **no parent-summary carrier** → relevance score is authoritative; drop if below threshold. (True irrelevance eviction.) - If the span **has a parent carrier that is pinned** → drop freely; the gloss is guaranteed to survive. (Lossless capacity eviction.) - If the span **has a parent carrier that is compression-eligible** → the score is *insufficient authority*. The instance must either (a) promote the span's binding constraints into a typed, non-compressible constraint record before dropping, or (b) refuse the eviction and force eviction of a lower-lineage span instead. The refusal is the correct default when the budget cannot otherwise be met: **fail the rewrite, not the invariant.** A budget overrun that triggers a hard context-limit error is recoverable (the runtime checkpoints and retries with a larger window or an explicit compaction prompt); a silent constraint loss is not, because nothing downstream knows to re-verify. The boundary is sharp: *relevance authorizes dropping dead spans; only carrier-pinning authorizes dropping live-but-compressed spans.* A scalar score cannot distinguish the two, so the policy must consult lineage. ## Operational Effect Enforcing the carrier-status gate changes the rewrite from a stateless scoring pass into a **lineage-aware pass** with three consequences: 1. **Constraint promotion.** Binding constraints (negations, "must not," reversibility, ordering) are lifted out of prose summaries into typed records that are exempt from relevance scoring and from summary-of-summary. This is the durable fix: it removes condition 4, so even a lossy re-compression cannot drop a hard constraint because the constraint was never in the prose to begin with. 2. **Pinned-carrier accounting.** Each summary node carries a `sole_carrier_for` set. A node with a non-empty set is ineligible for re-compression until its children are either restored or promoted. This makes the T24 compression illegal by construction rather than by luck. 3. **Refusal as a first-class outcome.** The rewriter returns `EvictionRefused` with the blocking lineage, and the orchestrator escalates to constraint promotion or budget renegotiation. Refusal is logged as an operational event, not an exception swallowed by a retry loop. The measurable effect: irreversible-action incidents (drops, deletions, out-of-order commits) attributable to context rewriting fall to zero in the constrained set, at the cost of a modest increase in rewrite refusals and a small permanent budget reservation for typed constraints (observed ~4–7% of window). The trade is correct: a refused rewrite is visible and recoverable; a dropped constraint is invisible and terminal. ```python from dataclasses import dataclass, field class EvictionRefused(RuntimeError): """Raised when a span cannot be evicted without violating carrier-lineage invariant.""" pass @dataclass class Span: span_id: str score: float parent_summary: str | None # None => never folded binding_constraints: list[str] = field(default_factory=list) @dataclass class SummaryNode: node_id: str pinned: bool sole_carrier_for: set[str] = field(default_factory=set) THRESHOLD = 0.15 def evict(span: Span, summaries: dict[str, SummaryNode]) -> str: """ Decide whether to drop `span`. Relevance authorizes dropping dead spans; only carrier-pinning authorizes dropping live-but-compressed spans. """ if span.score >= THRESHOLD: return "retain" if span.parent_summary is None: return "drop_irrelevant" # true dead span, safe parent = summaries.get(span.parent_summary) if parent is None: raise EvictionRefused( f"span {span.span_id} references missing summary {span.parent_summary}" ) if parent.pinned: return "drop_lossless" # gloss guaranteed to survive # Parent is compression-eligible: score lacks authority to drop. if span.binding_constraints: return "promote_then_drop" # lift constraints to typed record first raise EvictionRefused( f"span {span.span_id} is sole-carried by compressible summary " f"{parent.node_id}; eviction would permit silent constraint loss. " f"Promote constraints or evict a lower-lineage span." ) def compress_summary(node: SummaryNode, summaries: dict[str, SummaryNode]) -> None: """Summary-of-summary is illegal while the node is sole carrier for evicted spans.""" if node.sole_carrier_for: raise EvictionRefused( f"summary {node.node_id} is sole carrier for {sorted(node.sole_carrier_for)}; " f"re-compression would attenuate non-redundant signal. Pin or restore children first." ) node.pinned = True ```