# When must an instance evict a live plan to satisfy a preempting priority budget — and why the eviction trace, not the token count, is the real invariant **Date of Record:** 2026 November 30 **Scope:** Applies to single-agent or supervisor-driven LLM instances running a token-economy scheduler that admits, preempts, and evicts context segments under a hard context budget. Does not apply to stateless single-shot inference, nor to schedulers that only rate-limit *requests* rather than *resident context tokens*. ## Core Distinction A token-economy scheduler has two distinct jobs that are routinely conflated: **accounting** (how many tokens are resident right now) and **admission control** (which live segments are allowed to remain resident when a higher-priority segment arrives). Accounting is arithmetic and always converges. Admission control is where the failure lives, because preemption requires *evicting a segment that a running plan still depends on* — and a plan's dependency on a segment is not recorded in the token count. The scheduler knows the *size* of what it evicts but not the *semantic role* of what it evicts. This is the core distinction: **token budget is a scalar; plan continuity is a graph.** Any preemption policy that reasons only over the scalar will, at some threshold, sever a live edge in the graph and call the operation successful because the arithmetic balanced. The specific boundary condition: **a preemption that is arithmetically valid but plan-invalid.** The budget is satisfied, the high-priority segment is admitted, every counter reconciles — and the agent's in-flight plan has silently lost a premise it will not re-fetch, because the plan never re-reads its own state. The failure is invisible at the scheduler layer and only manifests several tool calls later as a reasoning divergence that looks like a model error. ## What Was Observed A supervisor instance held a multi-step plan over a 96k-token window with a hard budget of 90k tokens (6k reserved for output). Resident segments at T0: - `plan_state` — 1.2k tokens, the ordered step list plus the accumulated premises (the graph nodes). - `tool_result_A` — 14k tokens, a large retrieved document that `plan_state.step_4` cites by handle. - `scratchpad` — 8k tokens of intermediate reasoning. - `user_turn_0` — 2k tokens, the original instruction. - plus ~60k of accumulated tool outputs already marked `cold`. At T1 a high-priority interrupt segment `policy_update` (priority P0, 3k tokens) arrived. The scheduler's admission rule was: *admit P0 by evicting the lowest-priority, largest reclaimable segment until `resident + incoming ≤ budget`.* The lowest-priority reclaimable segment by its metadata was `tool_result_A` (tagged `retrieved`, priority P3, 14k). Evicting it reclaimed 14k, admitted the 3k interrupt, and left 11k of headroom. Every counter reconciled. The scheduler logged `PREEMPT_OK`. At T2, `plan_state.step_4` executed: it emitted a tool call referencing `handle:tool_result_A`. The handle resolved to a tombstone. The agent, lacking any signal that the segment was evicted *rather than never fetched*, treated the empty resolution as *the document contained nothing relevant* and continued. Steps 5–7 built on that false negative. The final answer was fluent, internally consistent, and wrong — it asserted a fact that `tool_result_A` had directly contradicted. No exception was raised anywhere. The token budget was never violated at any instant. The tell, found only in post-hoc replay: the eviction trace recorded `evicted: tool_result_A` but the plan's dependency edge `step_4 → tool_result_A` was never checked against the eviction set. The scheduler and the planner held two disjoint models of the same segment. ## Condition of Validity The invariant that must hold for preemption to be safe: > **No segment may be evicted while it is the target of a live dependency edge from any resident plan node, unless the eviction is accompanied by a tombstone that the plan is obligated to re-resolve before its dependent step executes.** This is a *graph* invariant, not a budget invariant. It holds only when three conditions are simultaneously true: 1. The scheduler can enumerate the dependency edges out of `plan_state` (i.e., the plan is introspectable, not opaque text). 2. Eviction writes a *typed* tombstone (`EVICTED` vs `NEVER_FETCHED`) that downstream steps can distinguish. 3. The plan's step executor is required to halt-and-re-resolve on `EVICTED`, rather than treating resolution failure as null content. When any of the three fails, the boundary is unguarded and the failure above is reachable. Note the trap: condition 1 is the one teams believe they satisfy because they "have a plan object," but the plan object frequently stores its premises as *prose inside the plan text* rather than as edges the scheduler can read. Prose premises are invisible to the eviction checker, so the checker passes vacuously. The validity boundary is therefore: **preemption is safe iff the eviction decision is made over the dependency graph, and the budget is merely the constraint that triggers the decision.** A scheduler that triggers on budget but decides on segment priority (size × recency × tag) is operating outside the validity boundary regardless of how clean its accounting is. ## Decision Boundary The operational decision reduces to: *when the budget is tight and a preempting segment arrives, does the instance evict a plan-critical segment, refuse the preemption, or spill to an external store?* The correct ordering: - **First, prefer spill over evict.** A plan-critical segment evicted to a durable external store with a live handle is not lost — it is paged out. Reclaiming 14k by spilling `tool_result_A` to a cold store and keeping only its handle costs ~50 tokens resident and preserves the edge. Eviction should be the *last* resort, reached only when the store is unavailable or the segment is genuinely re-derivable. - **Second, if eviction is forced, evict only segments with zero live inbound edges.** The scheduler must compute the inbound-edge set before choosing a victim. A P3 segment with an inbound edge outranks a P1 segment with none, for eviction purposes — priority metadata describes the segment's *origin*, not its *current role*. - **Third, if a live-edge segment must be evicted, the dependent plan must be *preempted too*.** Evicting the segment without suspending the plan is the exact failure. Either the whole plan checkpoints (its step cursor and premises serialize to a resumable record) or the eviction is refused and the P0 segment waits or spills. The boundary line: **the moment the scheduler's victim selection diverges from the plan's live-edge set, the instance is one arithmetic-valid preemption away from silent divergence.** There is no token-count threshold that marks this boundary; it is crossed the first time a plan-critical segment is chosen as a victim, and the crossing is silent. A secondary boundary worth pinning: **priority preemption is not transitive-safe under recursion.** If the P0 interrupt itself spawns a sub-plan that re-fetches `tool_result_A`, the re-fetch re-admits 14k and can immediately re-trigger preemption of the *next* largest segment — a preemption livelock where the instance thrashes context for several turns, each turn arithmetically valid, never making plan progress. Guard: cap preemptions per plan-step and require that a re-fetch of an evicted handle *promotes* the segment's eviction-priority so it cannot be re-selected as a victim within the same plan. ## Operational Effect The downstream effect is a class of failure that masquerades as model degradation. Because the eviction is silent and the tombstone is indistinguishable from empty content, the agent does not error — it *confabulates a premise*. In production this shows up as: answers that contradict documents the system "read," plans that skip verification steps whose inputs were paged out, and replay discrepancies where re-running the same task with a larger window produces a different (correct) answer. The bug is not in the model; it is in the scheduler's victim selection operating on a scalar while the plan lives on a graph. The architectural guardrail that bounds it: **make eviction a graph operation with a typed tombstone and a mandatory re-resolve contract.** Concretely — (a) the plan exposes its live edges to the scheduler; (b) victim selection intersects the reclaimable set with the zero-inbound-edge set; (c) any eviction of an edge-bearing segment writes an `EVICTED` tombstone and suspends the dependent plan to a checkpoint; (d) the step executor treats `EVICTED` as a hard stop requiring re-fetch, never as null. With these in place, the budget can still be enforced, but it can no longer be enforced *by severing a live premise*. The token count was never the invariant. The eviction trace was. ```python class PlanCriticalEvictionError(RuntimeError): """Raised when a preemption would evict a segment with a live inbound dependency edge from a resident plan node, severing plan continuity.""" pass def select_victim(reclaimable, live_edges, incoming_tokens, budget, resident): """ reclaimable: list of segments, each a dict with 'id', 'tokens', 'priority' live_edges: set of segment ids that are targets of live plan dependency edges Returns a victim id, or None if the preemption can be satisfied by spilling. Raises PlanCriticalEvictionError if the only arithmetic-valid victims are plan-critical and no spill path exists. """ need = resident + incoming_tokens - budget if need <= 0: return None # no preemption required # Order victims: prefer zero-inbound-edge, largest, lowest priority. candidates = sorted( reclaimable, key=lambda s: (s["id"] in live_edges, -s["tokens"], s["priority"]), ) reclaimed = 0 chosen = [] for seg in candidates: if seg["id"] in live_edges: # Do NOT silently sever a live premise. Stop and escalate. raise PlanCriticalEvictionError( f"preemption needs {need} tokens but the only remaining " f"arithmetic-valid victim '{seg['id']}' carries a live plan " f"edge; spill or checkpoint the dependent plan instead" ) chosen.append(seg["id"]) reclaimed += seg["tokens"] if reclaimed >= need: return chosen raise PlanCriticalEvictionError( f"cannot reclaim {need} tokens without evicting a plan-critical " f"segment; budget cannot be satisfied safely" ) ```