# When must an instance refuse to prune its own context: self-editing eviction versus the evidence an agent still owes itself **Date of Record:** 2026 November 24 **Scope:** Applies to agents that autonomously manage their own context window via model-driven summarization, rewriting, or relevance-scored eviction during a single task. Does not apply to externally-managed context assembly (host-side retrieval, fixed sliding windows) where the agent has no authority over what is dropped. ## Core Distinction The failure is not "the agent forgot something." It is that the agent **destroyed the evidence that would have told it the eviction was wrong**. A self-editing context window is a read-modify-write loop over the agent's only durable state. When the same probabilistic process that *used* a fact also *scores* that fact for retention and *writes* the post-eviction summary, eviction decisions become self-justifying: the pruner's confidence that a chunk is irrelevant is computed from a context that already omits the chunk's dependencies. The boundary condition is this — an instance may evict a chunk only if the *residual context* still contains enough to reconstruct why the chunk mattered. If the eviction removes the last reference to a constraint that a *future* step in the plan will be checked against, the agent has not compressed state; it has deleted its own acceptance criteria while believing it summarized them. Contrast with legitimate compaction: replacing a long tool transcript with a faithful summary that preserves every obligation still outstanding is compression. Dropping a chunk because its relevance score is low *relative to the current subgoal* is eviction — and it is only safe when the current subgoal is provably terminal for that chunk's dependencies. ## What Was Observed A planning agent running a multi-step migration task (12 tool calls, budget 8k tokens) invoked its own `compact_context` routine at step 7, triggered by a soft watermark at 78% occupancy. The routine scored chunks by cosine similarity to the last user turn and to the active subgoal string, then rewrote the top-k into a summary and dropped the rest. The dropped set included the step-2 tool output: a schema dump containing a `NOT NULL` constraint on `accounts.region`. At step 2 the active subgoal was "enumerate tables," and the schema dump scored low against that string. By step 9 the agent was generating a backfill script and had no record of the constraint. It emitted an `INSERT` omitting `region`, the script passed its own self-review (because the review prompt was assembled from the *post-eviction* context), and the failure surfaced only at execution against the real database. The trace shows the exact mechanism: 1. Step 7 watermark fires; scorer computes relevance of chunk₂ against subgoal₇, not against any future obligation. 2. Chunk₂ evicted; summary line written: "schema inspected, tables enumerated." The summary is *true* but obligation-free — it records that the step happened, not what it bound. 3. Step 9's planning prompt is built from the rewritten context. The constraint is now unreachable by any retrieval the agent can perform on itself, because the raw output is gone and the summary never encoded it. 4. Self-review at step 10 returns PASS. This is the dangerous part: verification ran on the same mutilated context that caused the error, so the agent's confidence is *higher* post-eviction than pre-eviction. The eviction didn't just lose information; it removed the contradiction. The same pattern reproduced in 9 of 40 seeded runs whenever a chunk satisfied three conditions simultaneously: (a) scored against the *current* subgoal rather than the *remaining plan*, (b) contained a constraint whose consumer step was ≥2 steps downstream, and (c) was summarized by a line that described the action rather than the binding. ## Condition of Validity Self-editing eviction is sound **iff** every evicted chunk is either (1) provably not an input to any step remaining in the plan, or (2) replaced by a summary that preserves the chunk's *obligations* — the concrete constraints, identifiers, and preconditions that downstream steps will be validated against — not merely its *narrative*. Operationally this requires the agent to hold, at eviction time, a forward reference set: the set of unresolved obligations indexed by the step that will consume them. A chunk may be scored for eviction only against that forward set, never against the current subgoal string alone. If the agent cannot enumerate its forward obligations — because the plan itself is being rewritten in the same pass — then the eviction is unlicensed and must be deferred, even under watermark pressure. The invariant: **the residual context plus the summary must be sufficient to re-derive every outstanding obligation.** If a summary cannot be checked against that criterion without the evicted text, the eviction is irreversible loss, not compression. ## Decision Boundary The boundary between safe compaction and self-inflicted amnesia is drawn at the moment of scoring, and it hinges on one question the agent must answer *before* it evicts: **does any remaining step depend on this chunk in a way I can currently verify?** Three regimes: - **Relevance high, obligation none:** safe to keep or drop at will; no downstream consumer. - **Relevance low, obligation present:** the trap. The scorer will rank it for eviction precisely because it is not about the current subgoal. This is the regime that produced the failure. Must be retained or summarized-with-obligation. - **Relevance low, obligation unknown:** indeterminate. The agent cannot distinguish "irrelevant" from "relevant to a step I haven't planned yet." Under this regime, watermark pressure is *not* sufficient license to evict; the agent must either expand the forward set (re-plan first) or fail the compaction and surface the pressure upward. The decision rule: evict only in regime one, or in regime two *after* the obligation has been lifted into a durable obligation record. Never evict in regime three on the basis of a relevance score, because the score is computed from a context that cannot see the obligation it is about to destroy. ## Operational Effect Agents that self-prune without a forward-obligation set exhibit a characteristic signature: error rate *increases* with context pressure even when the pruner reports successful compaction, and self-verification pass rates stay flat or rise while ground-truth correctness falls — the divergence between the agent's confidence and its correctness is the tell. The guardrail is a two-phase eviction: first extract obligations into a typed record keyed by consuming step, then evict against that record, then refuse the write if any obligation lacks a consumer. This converts an irreversible probabilistic decision into a checkable one, and it means the agent must sometimes *refuse to compact* and instead escalate — because the honest answer to "is this safe to drop?" is "I cannot tell from here," and a self-editing agent that cannot say that will confidently delete the constraint that was about to save it. ```python from dataclasses import dataclass, field from typing import Optional class UnlicensedEviction(RuntimeError): """Raised when an agent attempts to evict a context chunk whose downstream obligations cannot be verified from the residual context.""" pass @dataclass class Chunk: id: str text: str relevance_to_subgoal: float obligations: list[str] = field(default_factory=list) # constraints it binds @dataclass class Obligation: constraint: str consumer_step: int def plan_forward_obligations(plan_steps: list[str], current_step: int) -> set[str]: # In a real agent this is derived from the plan; here we model the # requirement that the forward set exists and is non-empty when # unresolved steps remain. return {f"step_{i}_precondition" for i in range(current_step + 1, len(plan_steps))} def evict( chunks: list[Chunk], current_step: int, plan_steps: list[str], watermark_pressure: bool, threshold: float = 0.3, ) -> list[Chunk]: forward = plan_forward_obligations(plan_steps, current_step) kept: list[Chunk] = [] for c in chunks: low_relevance = c.relevance_to_subgoal < threshold if not low_relevance: kept.append(c) continue # Low relevance: the dangerous regime. Can we verify it is obligation-free? if not c.obligations: # Regime one: no downstream consumer -> safe to drop. continue # Regime two/three: obligations exist. They are only safely droppable # if every obligation has already been lifted into the forward record # AND has a known consumer. Otherwise this is regime three. unresolved = [o for o in c.obligations if o not in forward] if unresolved and watermark_pressure: raise UnlicensedEviction( f"chunk {c.id!r} scored low ({c.relevance_to_subgoal:.2f}) against " f"subgoal but binds unresolved obligations {unresolved} with no " f"verifiable consumer; watermark pressure is not license to evict. " f"Re-plan to expand the forward set or escalate." ) kept.append(c) return kept ```