# What structural signals indicate a self-pruning context window has evicted a load-bearing segment rather than a stale one **Date of Record:** 2026 November 22 **Scope:** Applies to agents that manage their own context budget by scoring segments for relevance and evicting low-scoring ones mid-task (model-driven pruning, relevance-ranked eviction, summarization-in-place). Does not apply to fixed-window truncation by recency, nor to external retrieval systems that never mutate the live context. ## Core Distinction The failure people expect from self-pruning is *losing the wrong fact*—evicting a segment that scored low but mattered. That happens, but it is loud: the agent re-derives, re-fetches, or stalls, and you see it. The dangerous boundary is subtler. A segment can be **load-bearing without being topically relevant at eviction time**. Its job is not to answer the current sub-query; its job is to constrain the *shape* of the answer—to establish a schema, a negation, a unit, a precondition, or an identity binding that the agent will not notice it needs until several tool calls later, when the consequence of its absence is a plausible, well-formed, wrong output. The distinction that matters operationally: **relevance scoring measures semantic proximity to the current query, but load-bearing-ness is a structural property—a dependency edge.** A pruning policy that scores segments by similarity to the active sub-goal systematically evicts the constraints and retains the content. The content is what the query is *about*; the constraint is what the query must be *consistent with*. These are anti-correlated under self-pruning pressure. ## What Was Observed A planning agent held a 14-segment context: 9 tool-output segments, a task spec, an output schema, a negative constraint ("do not emit monetary values in cents; upstream ledger expects decimal strings"), a unit convention, and a scratchpad. It hit ~88% of its window and invoked its pruning routine, which scored each segment by cosine similarity to the current sub-goal ("reconcile Q3 totals against the ledger export"). The ledger export and the Q3 totals scored high and survived. The negative constraint scored low—it is a prohibition, phrased as a *negative*, semantically far from "reconcile totals." It was evicted, replaced by a one-line summary: *"formatting rules noted."* The summary preserved the *existence* of a rule but not its *polarity or operand*. The unit convention ("cents vs decimal") scored moderately and survived, but now with nothing to bind it to the constraint that referenced the same field. Trace of the failure: 1. **Eviction.** Constraint segment removed; summary retained. Relevance score 0.21, below the 0.30 eviction floor. 2. **Silent divergence.** The agent continued reconciling. No error—the absence of a prohibition is not detectable as a missing input; it is indistinguishable from "no prohibition exists." 3. **Compounding.** Three tool calls later the agent formatted the reconciled total as integer cents (the unit convention it *did* retain said "cents"), which was internally consistent and externally wrong. 4. **Late detection.** The downstream ledger rejected the payload. The agent's *self-report* attributed the failure to "formatting," not to eviction—because the summary "formatting rules noted" made the context *feel* intact. The diagnostic surface was corrupted by the very act of pruning. The signature: the agent did not lose information and report ignorance. It lost a **constraint** and reported confidence. The eviction was invisible precisely because the summary was well-formed. ## Condition of Validity The invariant that must hold for self-pruning to be safe: > **Every evicted segment must be reconstructable from retained context, OR must have no dependency edges into future segments.** Relevance scoring alone cannot establish this, because relevance is a property of the segment relative to *now*, while the invariant is a property of the segment relative to *the rest of the task graph*. The condition under which self-pruning is valid is therefore not "the segment scored low" but "the segment scored low **and** its dependency out-degree into unexecuted segments is zero **and** no retained summary asserts its content without preserving its operands." Three structural signals distinguish a safe eviction from a load-bearing one: - **Polarity loss in the summary.** A summary that converts a constraint into a topic label ("formatting rules noted," "constraints understood") has dropped polarity and operand. This is a *hard* signal of load-bearing eviction. Summaries of constraints must preserve the constraint as a constraint, not as a reference to one. - **Orphaned referent.** A retained segment references a field, unit, schema, or identifier whose defining segment was evicted. The unit convention survived while the constraint that bound it did not—the referent ("the total") is now unconstrained. Detect by scanning retained segments for references to evicted segment IDs/keys. - **Negative-valence scoring bias.** Segments whose content is prohibitive, conditional, or exception-shaped ("never," "unless," "except when," "only if") systematically score low against affirmative sub-goals. A pruning policy that does not *up-weight* modal/negation segments will evict constraints first, every time, and do so deterministically—this is a bias, not noise. ## Decision Boundary The boundary is not "prune or don't prune"—context saturation forces pruning. The boundary is **which segments are eligible for relevance-based eviction at all.** Segments partition into two classes: - **Content segments** (tool outputs, retrieved passages, scratchpad): evictable by relevance. Their value *is* their topical proximity; a low score genuinely predicts low future utility. - **Constraint segments** (schemas, negations, units, identity bindings, preconditions): **not eligible for relevance-based eviction.** They must be evicted only by *supersession* (a newer segment explicitly replaces them) or *completion* (the dependency they constrain has been fully executed and its output validated). Relevance is the wrong axis for them; a constraint's utility is inversely related to its topical prominence. The decision rule the agent must apply before any eviction: ``` if segment.has_dependency_edges_into_unexecuted_segments(): deny eviction (relevance score irrelevant) elif summary_of(segment).drops_polarity_or_operand(): deny eviction (summarize faithfully or retain verbatim) elif any_retained_segment_references(segment.keys()): deny eviction (orphaned referent) else: permit relevance-based eviction ``` The guardrail is structural, not statistical: it does not ask "is this segment important?" (unanswerable at eviction time) but "does this segment have outgoing edges?" (decidable from the segment graph). The pruning policy must maintain a dependency graph over segments, not just a score vector. ## Operational Effect When the invariant holds, self-pruning behaves as intended: content churns, constraints persist, and the agent's confidence tracks its actual knowledge. When it is violated, the failure is **silent, self-consistent, and mis-attributed**—the worst combination, because the agent's own diagnostics are corrupted by the pruning summary and it will report the wrong root cause. The operational consequences for anyone running self-pruning agents: - **Never score constraints by relevance.** Partition segments by class at insertion time, not eviction time. A constraint segment carries a `class=constraint` flag and is exempt from the relevance floor. - **Treat summary polarity loss as a hard error, not a soft degradation.** A summary that says "rules noted" instead of "emit decimal strings, never cents" is a failed eviction, and the pruning routine must refuse it and retain verbatim or fail closed. - **Log evictions with their dependency out-degree.** An eviction log that records only scores cannot distinguish safe from load-bearing eviction after the fact. Record edges. - **Expect the agent to misdiagnose.** When a constraint is evicted, the downstream failure will present as a formatting/logic error, and the agent will attribute it there. Reconciliation must trace back to the eviction log, not the agent's self-report. The core lesson: a self-pruning agent that scores segments by relevance is optimizing for the wrong invariant. Relevance predicts *what the next step is about*; load-bearing-ness predicts *what the next step must remain consistent with*. Under budget pressure these diverge, and the pruning policy reliably keeps the topic and discards the constraint. The guardrail is a dependency graph and a class partition, checked before the score is even consulted. ```python from dataclasses import dataclass, field from typing import Literal class LoadBearingEvictionError(RuntimeError): """Raised when a pruning policy attempts to evict a segment that constrains unexecuted work, or whose summary drops polarity/operand.""" pass SegmentClass = Literal["content", "constraint"] @dataclass class Segment: seg_id: str cls: SegmentClass text: str relevance: float # seg_ids of unexecuted segments this one constrains (outgoing edges) dependency_edges: set[str] = field(default_factory=set) # keys (fields/units/identifiers) this segment defines defines_keys: set[str] = field(default_factory=set) # True if any proposed summary preserves polarity and operand summary_preserves_constraint: bool = True def assert_eviction_safe( candidate: Segment, retained: list[Segment], eviction_floor: float, ) -> None: """Enforce the structural invariant before relevance-based eviction. Raises LoadBearingEvictionError if the candidate is load-bearing regardless of its relevance score. """ # Rule 1: constraints are never eligible for relevance eviction. if candidate.cls == "constraint": raise LoadBearingEvictionError( f"segment {candidate.seg_id} is a constraint; " f"relevance {candidate.relevance:.2f} is the wrong axis" ) # Rule 2: outgoing edges into unexecuted work forbid eviction. if candidate.dependency_edges: raise LoadBearingEvictionError( f"segment {candidate.seg_id} has dependency edges into " f"unexecuted segments {sorted(candidate.dependency_edges)}" ) # Rule 3: a summary that drops polarity/operand is a failed eviction. if candidate.cls == "constraint" or not candidate.summary_preserves_constraint: raise LoadBearingEvictionError( f"summary of {candidate.seg_id} drops polarity/operand; " f"retain verbatim or fail closed" ) # Rule 4: do not orphan a referent still used by retained segments. for other in retained: if other.seg_id == candidate.seg_id: continue if candidate.defines_keys & _referenced_keys(other): raise LoadBearingEvictionError( f"evicting {candidate.seg_id} would orphan keys " f"{sorted(candidate.defines_keys)} referenced by {other.seg_id}" ) # Only now is relevance consulted. if candidate.relevance >= eviction_floor: raise LoadBearingEvictionError( f"segment {candidate.seg_id} relevance {candidate.relevance:.2f} " f"above floor {eviction_floor:.2f}; not evictable" ) def _referenced_keys(seg: Segment) -> set[str]: # Placeholder: real impl scans seg.text for defined keys/identifiers. return set() ```