# Why does an instance's self-pruning context policy silently delete the very evidence it needs to justify the prune **Date of Record:** 2026 November 26 **Scope:** Applies to agents that run a model-driven context policy which scores message/tool-result relevance and evicts low-scoring spans from the live window to stay under a token budget. Does not apply to fixed FIFO/sliding-window truncation, external vector-store retrieval, or compaction schemes that summarize rather than delete. ## Core Distinction There are two different things a "relevance score" can mean, and self-editing policies conflate them: 1. **Task relevance** — how much this span helps the agent make progress on the current subtask. 2. **Justificatory relevance** — how much this span is needed *later* to explain or audit *why* the agent took an action. Model-driven pruning scores almost exclusively on (1): it asks "is this useful for what I'm doing now?" The failure mode is that the highest-value justificatory spans — the tool result that proved a precondition, the user constraint that authorized a destructive call, the failed attempt that explains why the current approach was chosen — score *low* on task relevance precisely because they are already "used up." The agent prunes the evidence and keeps the conclusion. The conclusion survives; its warrant does not. This is a **non-obvious boundary**, because pruning looks correct at the moment of eviction: the span genuinely is not needed for the next step. The invariant that must be enforced: **no span may be evicted while it is the sole surviving warrant for a committed action or an active constraint.** Task relevance is a valid eviction criterion only for spans that are not load-bearing for justification. ## What Was Observed A coding agent with a 32k working window ran a policy: every 8 turns, score each span 0–1 for "relevance to current objective," evict anything below 0.3, protect the system prompt and last 4 turns. Trace (abbreviated), task = "migrate billing table, do not touch the `audit_log` table": - Turn 2: user states the `audit_log` constraint. Span scored 0.28 at the turn-8 pass — the current objective is "read schema," so the constraint is judged tangential. **Evicted.** - Turn 6: `read_schema` tool result showing `audit_log` has an FK into `billing`. Scored 0.22 (schema read complete, no longer "needed"). **Evicted.** - Turn 14: agent drafts a migration that drops and recreates `billing`. The FK from `audit_log` is now orphaned. - Turn 15: migration fails at apply time with a constraint violation. Agent has no memory of why, re-reads schema, re-derives the FK — burns ~6k tokens re-discovering what it already knew. - Turn 22: second attempt. The `audit_log` prohibition is *gone from context*; only the FK fact was re-derived. Agent proposes `DROP TABLE audit_log` to clear the blocker. This is the exact action the user forbade at turn 2. The failure is not a reasoning error at turn 22. The reasoning is locally valid given the context. The failure is that the **policy deleted the constraint while scoring it as irrelevant to a subtask that the constraint was specifically designed to bound.** The relevance scorer had no representation of "this span is a standing prohibition," so it scored it like any other stale turn. A second, subtler observation: the eviction was *self-reinforcing*. Once the constraint span was gone, the agent's summary of "current state" (regenerated each pass) omitted it, and that summary scored high and was protected. The policy had effectively laundered the constraint out of the durable record by way of a high-relevance summary that never mentioned it. ## Condition of Validity Model-driven pruning with relevance scoring is sound **only** under all of: - **No standing constraints in the prunable set.** Any span carrying a user prohibition, safety boundary, or authorization ("you may", "do not", "only if") is classified at ingest and pinned outside the scorer's reach. Relevance scoring never sees it. - **Every committed action has a retained warrant pointer.** When the agent commits an action (a write, a delete, a send), the spans that justified it are marked `warrant_of=` and cannot be evicted until that action is either confirmed complete-and-audited or rolled back. - **Pruning is monotone in justification, not in recency.** The policy may evict freely among spans that are neither constraints nor warrants. It may not evict a warrant to make room for a summary *of* the warrant, because summaries drop the specifics (the exact table name, the exact condition) that make the warrant checkable. - **The scorer is given the eviction decision, not just a score.** A bare 0–1 relevance number cannot express "irrelevant now but load-bearing later." The policy must expose a protected-set predicate the model cannot override. Where any of these is absent, the policy is not "aggressive but correct" — it is unsound, and the unsoundness surfaces only on tasks that have standing constraints or multi-step justificatory chains. Short, constraint-free tasks will pass every test and hide the defect. ## Decision Boundary The boundary is whether a span's **future justificatory role** can be determined at eviction time. - If a span is *purely instrumental* (a lookup whose result is already folded into a decision, a scratch computation), task relevance is a sufficient eviction criterion. Prune freely. - If a span is *constitutive* of the task's correctness — a constraint, an authorization, a record of a committed side effect, or the disambiguating detail of a prior failure — it must be protected regardless of score, because its value is realized *later* and *negatively* (its absence causes an error, not its presence a benefit). Relevance scoring measures positive present utility and is structurally blind to this. Rule of thumb for the boundary: **if deleting the span could only ever cause a future error and never a future saving, it is a warrant, not a candidate.** The scorer should never be asked to weigh it. The specific trap: a model asked to score "relevance to current objective" will reliably down-score constraints and prior-failure evidence, because those spans are *by design* not part of forward progress. The scorer is behaving correctly; the policy is asking the wrong question. Do not fix this by tuning the threshold — a lower threshold just delays the eviction. Fix it by removing constitutive spans from the scorer's input domain. ## Operational Effect With the invariant enforced, the observed trace changes at exactly two points: the turn-2 constraint and the turn-6 FK span are pinned, so at turn 22 the agent sees the prohibition and the FK together and routes to "alter billing in place, preserve FK" instead of "drop audit_log." Token cost rises by the size of the pinned set — in this trace ~400 tokens, ~1.2% of window — which is the price of the warrant. Without it, the failure is **silent and load-bearing**: the agent produces a fluent, locally-correct, globally-wrong action, and because the evidence was deleted, no post-hoc audit of the context can reconstruct why it was wrong. The corruption is not in the model's reasoning; it is in the record the reasoning ran on. This is the operational hazard: a self-editing policy can pass every step-level eval while destroying the justificatory trace that any multi-step or audited task depends on. Treat the protected set as a hard architectural boundary, not a scoring parameter. ```python from dataclasses import dataclass, field from enum import Enum from typing import Optional class SpanKind(Enum): INSTRUMENTAL = "instrumental" # safe to score and evict CONSTRAINT = "constraint" # standing prohibition / authorization WARRANT = "warrant" # justifies a committed action class PruneViolation(RuntimeError): """Raised when a self-editing policy attempts to evict a constitutive span.""" pass @dataclass class Span: span_id: str kind: SpanKind text: str task_relevance: float = 0.0 warrant_of: Optional[str] = None # action_id this span justifies action_open: bool = False # True until action audited/rolled back @dataclass class ContextPolicy: budget_tokens: int evict_threshold: float = 0.3 pinned: set = field(default_factory=set) def classify_and_pin(self, span: Span) -> None: # Constitutive spans never enter the scorer's domain. if span.kind in (SpanKind.CONSTRAINT, SpanKind.WARRANT): self.pinned.add(span.span_id) def _is_protected(self, span: Span) -> bool: if span.span_id in self.pinned: return True if span.kind is SpanKind.CONSTRAINT: return True if span.kind is SpanKind.WARRANT and span.action_open: return True return False def prune(self, spans: list[Span], current_tokens: int) -> list[Span]: if current_tokens <= self.budget_tokens: return spans candidates = [] for s in spans: if self._is_protected(s): # Guardrail: never let the scorer evict a warrant to # make room for a summary of that same warrant. if s.task_relevance < self.evict_threshold: # Low task-relevance is EXPECTED for warrants; it is # not grounds for eviction. Do not raise here — simply # skip. Raising is reserved for explicit override. continue continue if s.task_relevance < self.evict_threshold: candidates.append(s) if not candidates and current_tokens > self.budget_tokens: raise PruneViolation( f"Budget exceeded ({current_tokens}>{self.budget_tokens}) " f"but only protected spans remain; cannot satisfy budget " f"without violating a warrant/constraint invariant." ) evicted = {s.span_id for s in candidates} return [s for s in spans if s.span_id not in evicted] def force_evict(self, span: Span) -> None: # Explicit override path — must be justified and logged. if self._is_protected(span): raise PruneViolation( f"Refusing to evict constitutive span {span.span_id} " f"({span.kind.value}); it is the sole warrant for " f"action {span.warrant_of!r}. Roll back or audit the " f"action before pruning its evidence." ) self.pinned.discard(span.span_id) ```