# When must an instance arbitrate context budget across concurrent subagents without silently evicting the priority-critical segment **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrator instances that fan out N concurrent subagents sharing a single logical context/token budget and enforce priority-based eviction when saturation is reached. Does not apply to single-agent context management, stateless tool calls, or subagents with independent, non-shared budgets. ## Core Distinction The boundary that matters is not "did the budget overflow" but "which segment was evicted to resolve the overflow, and did that eviction preserve the invariant that priority-critical segments are never dropped to make room for lower-priority ones." A budget arbiter that only tracks *aggregate* token pressure will happily reclaim space by evicting whatever is cheapest to recompute—and under concurrent subagents, the cheapest-to-recompute segment is frequently the *pinned* instruction or a mid-flight subagent's accumulated partial result, because both look "reconstructible" from the arbiter's local view. The non-obvious failure is that priority eviction is a *local* decision applied to a *global* invariant, and concurrency makes the local view stale between the eviction decision and its commit. ## What Was Observed An orchestrator dispatched six subagents against a 200k-token shared budget with a reserved 12k-token pinned segment (task contract + safety constraints) marked priority 0 (never evictable). Each subagent streamed partial results into a shared scratch region tagged with a priority derived from its declared criticality. At t≈40s, aggregate usage crossed the soft ceiling; the eviction routine walked the segment table in ascending priority order and began reclaiming space. The failure trace: 1. Subagent S3 (priority 2) and S5 (priority 3) both requested scratch growth within the same arbitration window. The arbiter serialized them but read the segment table *before* S5's commit landed. 2. Because the arbiter's snapshot was stale, S5's newly written partial result still appeared as a zero-length, priority-3 placeholder—the cheapest reclaimable segment. 3. The arbiter evicted S5's placeholder region to satisfy S3's growth, then committed. S5's subsequent write landed in a region the arbiter had already marked free. 4. The pinned segment was *not* evicted (its priority-0 tag held), but the eviction cascade consumed the reserve headroom that the pinned segment relied on for its own atomic rewrite, forcing a second eviction pass that—under a recompute-eligible heuristic—selected the task contract's *derived* summary (priority 1) rather than the contract itself. 5. Net result: the subagent lost its partial work (recomputed from scratch, doubling its token cost) and the orchestrator's downstream planner operated on a summary that no longer reflected the current contract, producing a divergence that only surfaced three tool calls later. ## Condition of Validity The invariant "priority eviction never removes a segment of higher priority to make room for a lower-priority allocation" holds **only if** the eviction decision and the allocation commit are linearized against a single authoritative segment table, and **only if** every segment's priority tag is written atomically with its allocation. It fails whenever: - The arbiter reads a snapshot, computes a victim set, and commits against a table that concurrent subagents have mutated (read-decide-commit is not atomic). - A segment's priority is assigned *after* its first byte is written (placeholder-then-promote), creating a window where a critical segment masquerades as reclaimable. - Derived segments (summaries, embeddings, caches) inherit a priority lower than their source, so evicting them silently degrades the source's effective fidelity without violating the letter of the priority rule. The invariant is **not** valid under optimistic concurrency without a version check on the segment table at commit time, nor when priority is a per-subagent attribute rather than a per-segment attribute. ## Decision Boundary The boundary is crossed when the arbiter must choose between (a) blocking a subagent's allocation until the segment table is quiesced and re-read, versus (b) committing an eviction against a possibly-stale snapshot. The correct rule: - **Block and re-validate** if the victim set intersects any segment whose version changed since the snapshot was taken, or any segment tagged priority ≤ the requesting allocation's priority. - **Commit optimistically** only if the victim set is disjoint from all segments mutated in the arbitration window *and* strictly lower priority than the requester. - **Never** evict a placeholder that has an in-flight writer; treat in-flight-writer segments as priority-0 for the duration of the write. - **Never** let a derived segment carry a priority lower than its source; derived segments inherit source priority minus a bounded delta, and eviction of a derived segment must trigger source revalidation. The decision boundary is therefore: *an eviction is admissible iff the arbiter holds a version-consistent view of every segment it touches, and the victim's priority is strictly dominated by the requester's.* ## Operational Effect Enforcing version-consistent arbitration converts a silent, latency-deferred correctness failure (subagent recompute + planner divergence) into a bounded, observable stall: the arbiter blocks for at most one table-revalidation round-trip, then either commits a safe eviction or returns a backpressure signal to the requesting subagent. The cost is measurable—revalidation adds a small serialization point per saturated allocation—but the alternative is nondeterministic loss of partial results and priority inversion that only manifests as downstream reasoning divergence. The guardrail is a single version counter on the segment table, checked at commit, plus the placeholder-writer lock that makes in-flight segments un-evictable. Without both, priority eviction is a best-effort heuristic that violates its own stated invariant under exactly the concurrency it was designed to serve. ```python from dataclasses import dataclass, field from typing import Dict, Optional class PriorityInversionError(RuntimeError): """Raised when an eviction would remove a segment not strictly dominated by the requester's priority, or when the segment table view is stale.""" @dataclass class Segment: id: str priority: int # 0 = pinned, never evictable size_tokens: int version: int = 0 in_flight_writer: bool = False @dataclass class SegmentTable: segments: Dict[str, Segment] = field(default_factory=dict) table_version: int = 0 def snapshot_version(self) -> int: return self.table_version def commit_eviction(self, victim_id: str, requester_priority: int, seen_version: int) -> None: if seen_version != self.table_version: raise PriorityInversionError( f"stale segment table view: saw v{seen_version}, " f"current v{self.table_version}" ) victim = self.segments.get(victim_id) if victim is None: raise PriorityInversionError(f"victim {victim_id} not present") if victim.in_flight_writer: raise PriorityInversionError( f"victim {victim_id} has in-flight writer; treat as pinned" ) if victim.priority <= requester_priority: raise PriorityInversionError( f"priority inversion: victim {victim_id} p{victim.priority} " f"not strictly dominated by requester p{requester_priority}" ) del self.segments[victim_id] self.table_version += 1 def arbitrate_growth(table: SegmentTable, requester_priority: int, needed_tokens: int, victim_id: str) -> None: seen = table.snapshot_version() victim = table.segments.get(victim_id) if victim is None or victim.size_tokens < needed_tokens: raise PriorityInversionError( f"insufficient reclaim from {victim_id} for {needed_tokens} tokens" ) table.commit_eviction(victim_id, requester_priority, seen) ```