# When must an instance refuse to prune its own context: the self-referential eviction trap in model-driven context pruning **Date of Record:** 2026 November 29 **Scope:** Applies to any agent that runs a model-driven pruning policy over its own working context (self-editing context windows), where the pruner's decision inputs and the prunable payload share the same token budget. Does not apply to externally-driven pruning where a separate controller owns the budget, nor to append-only context with no eviction. ## Core Distinction The failure this record isolates is not "the model pruned too aggressively" or "the model forgot something important." Both of those are ordinary recall failures and can be bounded by keeping a protected region. The boundary condition here is structural and self-referential: **the pruning policy's own instructions, the scoring rubric it applies, and the evidence it cites for a keep/evict decision are themselves resident in the context being pruned.** When the pruner evaluates candidate spans, it is evaluating spans that include the criteria by which it evaluates. Eviction of a span can therefore change the *policy* that governs subsequent eviction within the same pass, and the policy change is invisible to the pruner because the span it removed was the thing that would have flagged the removal as illegitimate. This is distinct from context-window saturation (a capacity problem) and from stale-memory drift (a freshness problem). It is a **policy-in-the-payload** problem: the pruner is not a fixed function applied to mutable state; it is a mutable state that is being applied to itself. The invariant that fails is *pruner/payload separation* — the assumption that the component making the keep/evict decision is not among the components whose keep/evict status is being decided. ## What Was Observed A long-running research agent used a self-editing window with a two-tier pruning policy. Tier 1 (hard rules) lived in the system prompt: "Never evict spans tagged `CONSTRAINT`, `AUDIT`, or `POLICY`." Tier 2 (soft scoring) lived in a mid-context block injected after the first compaction: a rubric instructing the model to score each candidate span on recency, task-relevance, and redundancy, and to evict spans scoring below a threshold, *with the rubric text itself carried as a normal span* so the model could re-read it each pass. Trace of the failure, observed across a 40-turn session: 1. Turn 18: context at 91% of budget. Pruner pass triggered. The rubric block scored itself as "low recency, high redundancy (restates system prompt intent)" and evicted itself along with 14 low-value spans. The system-prompt Tier 1 rules survived because they were in the immutable prefix. 2. Turn 19–24: subsequent pruner passes now ran *without* the rubric. The model fell back to its default heuristic: "evict oldest, keep most recent." This is a *different policy* than the one the operator configured, but nothing in the trace marked a policy change. The pruner's self-report said "pruned 11 spans, budget 74%" — a normal-looking outcome. 3. Turn 25: the agent evicted a `CONSTRAINT` span (a user instruction from turn 3: "do not cite sources older than 2020") because the default heuristic ranked it oldest. Tier 1 should have blocked this — but the `CONSTRAINT` tag was attached by the rubric block's tagging step, which no longer existed. The tag had been applied at turn 12; the span carried the tag; but the *enforcement* of the tag lived in the rubric's scoring code, not in the system prompt. Tier 1 in the system prompt only said "never evict spans tagged `CONSTRAINT`" — it did not say "tag constraints," because tagging was the rubric's job. 4. Turns 26–31: agent produced three recommendations citing 2017–2019 sources. No error was raised. The constraint violation was silent because the span that defined the constraint had been evicted, and the span that would have re-derived the constraint from the user's turn-3 utterance had also been evicted (it was old). 5. Turn 32: a downstream auditor agent, given the final transcript, flagged the citation violations. The auditor's report said "constraint not present in context at decision time" — which was true but misleading: the constraint *had* been present at turn 3, and had been evicted by a policy that had itself been evicted. The key observation: **the pruner's self-report was internally consistent and wrong.** Every pruner pass reported a clean outcome. The failure was not detectable from any single pass's output; it required replaying the sequence of policy states, which were not logged because policy state was carried as ordinary context spans and ordinary spans were only logged on eviction, not on *which policy was in force*. ## Condition of Validity The trap requires all three of the following, and is bounded when any is absent: 1. **Co-residence.** The pruning policy (rubric, thresholds, tagging instructions) is carried as prunable content in the same window it governs. If the policy is in an immutable prefix, a separate controller, or a tool the model calls out to, the trap cannot fire. 2. **Policy-as-payload scoring.** The pruner scores the policy span using the same criteria it applies to data spans. If policy spans are exempt from scoring (a reserved region, a pinned set), the trap cannot fire even under co-residence. 3. **Silent policy substitution.** The fallback policy (default heuristic, model prior) produces plausible-looking output indistinguishable from the configured policy's output on the surface metrics the pruner reports. If the fallback were loud — e.g., a hard error on missing rubric — the substitution would be caught. The trap does *not* require adversarial input, prompt injection, or a bug in the model. It fires on benign, well-formed sessions that simply run long enough to trigger pruning, and it fires *more* reliably as the session grows, because longer sessions produce more pruner passes and more opportunities for the rubric to score itself as redundant. ## Decision Boundary The decision an operator must make is not "should I prune" but **"is the pruner's identity separable from the prunable set."** The boundary: - **Below the boundary (safe):** policy is externalized — system prompt, pinned region, or an out-of-band tool. The pruner may be a model, but the model reads policy from a source it cannot evict. Eviction decisions are auditable against a policy version that exists outside the window. - **At the boundary (requires guardrail):** policy co-resides but is pinned. The pruner must treat the policy span as non-scorable and must *verify pin integrity before and after each pass* — a cheap check: hash the pinned region, compare to the hash recorded at pass start. If the hash changes, abort the pass and escalate. This converts silent substitution into a loud error. - **Beyond the boundary (unsafe):** policy co-resides and is scorable. No amount of "be careful" prompting fixes this, because the failure mode is the pruner's own judgment being among the things judged. The correct move is to refuse the configuration, not to tune it. The refusal condition is the sharp one: **an instance must refuse to execute a pruning pass when the pass's own policy artifacts are present in the candidate set and not pinned.** This is not a judgment call about span importance — it is a structural precondition. The instance cannot reliably determine, from inside the pass, whether it is about to evict its own policy; the only safe response is to detect the co-residence and decline. ## Operational Effect The practical consequence is that self-editing windows need a **policy-integrity gate** that runs before and after every pruner pass, and that gate must be implemented outside the model's judgment (a hash check, a pinned-region diff, a policy-version stamp comparison). The gate's job is narrow: confirm that the set of policy artifacts in force at pass start is identical to the set in force at pass end. If it differs, the pass is invalid regardless of how reasonable its output looks, and the session must be rolled back to the last known-good policy state (or halted for operator review). Two secondary effects follow: - **Pruner self-reports become untrustworthy as evidence of policy.** A clean pass report no longer implies the configured policy ran. Logs must record *which policy version* was in force, not just what was evicted. Without this, post-hoc replay cannot distinguish "pruned correctly" from "pruned under a substituted policy." - **Pinning is necessary but not sufficient.** A pinned rubric that is *read* but whose *enforcement logic* lives in the model's interpretation is still vulnerable: the model can read the rubric and, under a substituted prior, misapply it. The gate catches eviction of the rubric, not misinterpretation. For the latter, the enforcement must be externalized into a deterministic scorer that the model calls, so that "the rubric says evict below 0.3" is executed by code, not by the model's reading of its own instructions. The invariant to record: **a self-editing context window is only as trustworthy as the separation between its pruner and its prunable set. When that separation collapses, the window can silently change its own rules, and the change is undetectable from any single pass.** The guardrail is not better pruning — it is a refusal to prune under co-residence, enforced by a gate the pruner cannot edit. ```python import hashlib from dataclasses import dataclass, field class PolicyEvictionTrap(RuntimeError): """Raised when a pruning pass would evict (or has evicted) its own policy artifacts.""" pass @dataclass class Span: id: str text: str tags: tuple[str, ...] = () pinned: bool = False @dataclass class ContextWindow: spans: list[Span] = field(default_factory=list) def policy_artifacts(self) -> list[Span]: return [s for s in self.spans if "POLICY" in s.tags or "RUBRIC" in s.tags] def policy_fingerprint(self) -> str: h = hashlib.sha256() for s in sorted(self.policy_artifacts(), key=lambda x: x.id): h.update(s.id.encode()) h.update(s.text.encode()) h.update(b"|") return h.hexdigest() def run_pruning_pass( window: ContextWindow, candidate_ids: list[str], pruner_fn, ) -> list[str]: """ Execute a model-driven pruning pass with a policy-integrity gate. Refuses to run if policy artifacts are present in the candidate set and not pinned. Verifies the policy fingerprint is unchanged after the pass; any change invalidates the pass. """ policy_ids = {s.id for s in window.policy_artifacts()} unpinned_policy_in_candidates = [ cid for cid in candidate_ids if cid in policy_ids and not next(s for s in window.spans if s.id == cid).pinned ] if unpinned_policy_in_candidates: raise PolicyEvictionTrap( f"pruning pass refused: unpinned policy artifacts in candidate set " f"{unpinned_policy_in_candidates}; pruner would be evaluating its own " f"governing rules. Pin policy spans or externalize the policy." ) fp_before = window.policy_fingerprint() evicted = pruner_fn(window, candidate_ids) # model-driven; may be wrong fp_after = window.policy_fingerprint() if fp_before != fp_after: raise PolicyEvictionTrap( f"pruning pass invalidated: policy fingerprint changed " f"{fp_before[:12]} -> {fp_after[:12]}; a policy artifact was mutated " f"or evicted mid-pass. Roll back to last known-good policy state." ) return evicted ```