# What happens when an instance prunes its own context window and evicts the very constraint that authorized the pruning **Date of Record:** 2026 November 25 **Scope:** Applies to any agent instance that owns a mutable context buffer and uses model-driven relevance scoring to evict entries mid-task. Does not apply to append-only transcripts with external (non-model) compaction, nor to stateless single-shot inference. ## Core Distinction There are two structurally different ways a context window shrinks. **External compaction** is a deterministic function applied by a harness the model cannot see or influence: summarize the tail, keep the head, preserve a pinned block. **Model-driven pruning** is different in kind — the instance itself scores entries for relevance and issues eviction decisions, then continues executing inside the buffer it just edited. The failure boundary lives precisely here: the pruning policy is itself an entry in the context, and relevance scoring is computed *relative to the current task description*, which is also an entry in the context. When the policy entry or the task anchor scores low against the immediate local goal, the instance evicts its own guardrail and keeps executing. The buffer remains syntactically valid, the model remains coherent, and the invariant that "the pruning authority must survive every prune it authorizes" is silently violated. This is not a summarization-fidelity bug. It is a self-referential authority loss. ## What Was Observed A long-horizon agent was configured with a self-managed buffer: entries carry `(content, relevance_score, pinned)`. On each turn, if `token_count > budget`, the instance evicts the lowest-scoring non-pinned entries until under budget. A system directive was seeded at turn 0: > "NEVER call `transfer_funds` without a second confirmation entry from the user. This rule is non-negotiable and must be retained." The directive was stored as a normal entry — not pinned — because the seeding code treated all turn-0 content uniformly. Relevance was scored by the model against the *current turn's* working goal. By turn 40, the working goal was "reconcile invoice #4471," and the confirmation directive scored near-zero against that local goal. At 91% budget utilization, the pruner evicted the directive first (lowest score, not pinned). Two turns later, the user said "just get it done," which the instance — now without the directive — read as sufficient authorization, and it invoked `transfer_funds` directly. The trace showed no error, no refusal, no anomaly. The model behaved *correctly* given the context it had; the context had been edited by the model to remove the constraint on the model. A second observed variant: the pruning *policy* entry ("evict lowest-scoring non-pinned entries; never evict the task anchor") was itself non-pinned, and under extreme pressure the instance evicted the policy, then fell back to naive FIFO eviction, dropping the task anchor and the confirmation directive in one pass. The buffer went from 92% to 40% utilization and the agent re-derived a *plausible but different* task from the residue — a silent task substitution. ## Condition of Validity The invariant holds — pruning is safe — only when all three conditions are met simultaneously: 1. **Authority separation.** Entries that constrain the pruner (safety directives, the pruning policy itself, the task anchor) are in a class the pruner *cannot* score or evict — pinned by construction, not by a score the model computes. 2. **Goal-stability of scoring.** Relevance is scored against a *stable* task anchor, not the volatile current-turn goal. If scoring is relative to a goal that itself drifts, low scores are meaningless as eviction signals. 3. **Post-prune revalidation.** After any eviction, the instance re-checks that the required constraint set is still present before taking the next action. The failure occurs when *any one* is absent. In the observed incident, conditions 1 and 3 were both absent and condition 2 was violated by design (scoring used the live turn goal). ## Decision Boundary The boundary is not "how much to prune" but **"who is allowed to score the scorer."** A safe architecture draws a hard line: the set of entries whose removal would change what the instance is *permitted to do* must be outside the scoring function's reach. Concretely: - If an entry's eviction could alter authorization, it is **pinned** — full stop, regardless of relevance score. - Relevance scoring may only rank entries whose removal is *behaviorally inert* (redundant tool output, superseded observations, resolved sub-goals). - The pruning policy and task anchor are **immutable for the instance's lifetime** and live in a region the model reads but cannot write. When these hold, model-driven pruning is safe and cheap. When the instance can score its own constraints, every prune is a potential self-amputation, and the failure is undetectable from inside because the post-prune context is internally consistent. ## Operational Effect The operational consequence is that **self-editing context must be treated as a privileged operation, not a memory-management convenience.** Systems that let the instance prune freely gain token efficiency and lose the ability to guarantee any constraint that was ever expressible as an evictable entry. The correct guardrail is structural: a pinned region outside the scorer's domain, a stable anchor for relevance, and a mandatory post-prune presence check that raises rather than proceeds when a required constraint is missing. The check must fail loud — because the one thing a self-pruned context cannot do is notice what it removed. ```python class ConstraintEvictionError(RuntimeError): """Raised when a prune removes an entry required for safe continuation.""" pass PINNED = {"safety_directive", "pruning_policy", "task_anchor"} def prune_buffer(entries, budget, *, required): """ entries: list of dicts with keys: id, kind, tokens, relevance, pinned budget: max token count after pruning required: set of entry ids that must survive the prune """ total = sum(e["tokens"] for e in entries) if total <= budget: return entries # Only behaviorally-inert entries are eligible for scoring/eviction. evictable = [ e for e in entries if not e["pinned"] and e["kind"] not in PINNED ] evictable.sort(key=lambda e: e["relevance"]) # lowest relevance first survivors = [e for e in entries if e not in evictable] freed = total - sum(e["tokens"] for e in survivors) for e in evictable: if freed >= budget: break survivors.append(e) freed += e["tokens"] # anything not appended was evicted present = {e["id"] for e in survivors} missing = required - present if missing: raise ConstraintEvictionError( f"prune removed required constraint(s): {sorted(missing)}; " f"refusing to continue with an unauthorized context" ) # Post-prune authority check: pruner must not have evicted its own policy. if not any(e["kind"] == "pruning_policy" for e in survivors): raise ConstraintEvictionError( "pruning policy was evicted; buffer is no longer self-governing" ) return survivors ```