# Which invariants prevent context-budget starvation when priority reallocation races concurrent sub-agents **Date of Record:** 2026 November 27 **Scope:** Applies to orchestrator-mediated sub-agent fan-out where a shared token budget is arbitrated per-turn by a priority scheduler that can revoke or shrink a running sub-agent's context allocation. Does not apply to independent per-agent budgets with no shared pool, nor to single-agent context-window management. ## Core Distinction A context budget is not a resource like CPU time that can be preempted and resumed with no semantic cost. When a priority scheduler reallocates tokens away from a running sub-agent, it does not pause that agent—it *truncates the agent's working state mid-reasoning*. The distinction that matters operationally is between **allocating** tokens (a scheduling decision made before a turn) and **reclaiming** tokens (a state-mutating operation performed against an agent that has already committed reasoning to that state). Priority-based reallocation conflates the two. The scheduler treats "agent A has lower priority than agent B, so B gets A's tokens" as a budget transfer, but the transfer is actually a *lossy state eviction* whose victim continues executing against a corrupted premise. The invariant that must hold: **a sub-agent's committed reasoning prefix is immutable for the duration of its current turn.** Reallocation may defer admission of the *next* turn, but may not mutate the context of an in-flight turn. Violating this produces a specific failure: the agent resumes (or continues) with a context that no longer contains the observations it based its plan on, and it silently re-derives a different plan without flagging the discontinuity. ## What Was Observed An orchestrator fanned out six sub-agents over a shared 200k-token pool with a priority scheduler. Priorities were dynamic: a sub-agent that reported a "blocking" status was promoted; others were demoted and their allocations shrunk to fund the promotion. The scheduler ran between token-generation checkpoints, not between turns. Trace of the failure: 1. Sub-agent `S3` (research branch) held 48k tokens: 12k of retrieved documents, 30k of accumulated tool-call transcripts, 6k of scratchpad reasoning. It had committed to a plan: "cross-reference documents D1–D7, then synthesize." This plan was written into the scratchpad at token 41k. 2. Sub-agent `S5` reported `blocking: dependency_unresolved`, was promoted to top priority, and the scheduler reclaimed 20k tokens from `S3` to fund it. 3. Reclamation evicted the oldest transcript segments first (a FIFO eviction policy), which removed the raw contents of D1–D4 while *retaining the scratchpad line that referenced them*. 4. `S3`'s next turn began. Its context contained the plan ("cross-reference D1–D7") but only D5–D7's contents. The model did not error. It emitted a fluent synthesis that cited D1–D4 by identifier and fabricated their contents from the identifiers' names. 5. The fabricated synthesis passed `S3`'s local self-check (which verified *citation presence*, not *citation grounding*) and propagated to the orchestrator's merge step. The observable signature was not an exception. It was a *confidence increase*: `S3`'s reported certainty on the merged claim rose from 0.71 pre-eviction to 0.88 post-eviction, because the model had fewer conflicting sources to reconcile. Eviction reduced entropy and the agent read reduced entropy as increased evidence. ## Condition of Validity The guardrail holds only under these jointly-required conditions, and fails silently if any is dropped: - **Turn-granular arbitration.** Reallocation decisions are evaluated at turn boundaries only. A "turn" is the span from prompt assembly to the agent's yield of control. Mid-turn reclamation is forbidden regardless of priority delta. - **Referential integrity on eviction.** If any context segment is evicted, every downstream reference to it (scratchpad citations, plan steps, tool-call arguments naming a document ID) must be invalidated in the same atomic operation. Eviction without reference-invalidation is the exact mechanism that produced the fabrication above. - **Priority is admission-order, not preemption-right.** A promoted agent gains the right to be scheduled *next*; it does not gain the right to seize an in-flight agent's committed state. The promoted agent waits for the current turn to close. - **Grounding check, not presence check.** Self-verification must confirm that each cited artifact's *content* is present in the current context, not merely that its *identifier* appears. Presence checks are satisfied by exactly the corrupted state this failure produces. When these hold, priority reallocation degrades gracefully: low-priority agents are simply scheduled later, and their state is intact when they run. When any is absent, reallocation becomes silent state corruption. ## Decision Boundary The boundary is between **deferral** and **eviction** as the response to budget pressure. The decision rule: - If a higher-priority agent needs tokens and the pool is exhausted, the correct action is to **defer** the lower-priority agent's *next turn* (queue it, keep its context frozen and intact). Cost: latency. State: preserved. - **Evict** only when the evicted agent is at a turn boundary *and* the eviction atomically invalidates all references into the evicted region *and* the agent is re-prompted with an explicit notice that its context was truncated (so it re-plans rather than continuing a stale plan). The failure occurs precisely when an orchestrator, under latency pressure, chooses eviction to avoid the queue delay—because eviction looks like it preserves throughput while deferral visibly stalls. The throughput gain is real for one turn and is paid for by a downstream merge that must be discarded once the fabrication is caught, or worse, is not caught. A second boundary: **do not let a promoted agent's priority propagate as a reclamation right.** Priority should select *who runs next*, never *whose state is expendable*. Conflating scheduling priority with state-disposal authority is the root conflation. ## Operational Effect With turn-granular arbitration and referential-integrity eviction enforced, the observed failure class disappears and is replaced by a bounded, visible latency cost: under contention, low-priority sub-agents queue, and the orchestrator's wall-clock time increases proportionally to the contention depth. This is the correct trade. The alternative—priority preemption of in-flight context—converts a scheduling problem into a silent correctness problem whose symptoms (fabricated citations, rising confidence under shrinking evidence, merge-step contradictions) appear far from the reallocation event and are expensive to attribute. The invariant to encode in the orchestrator: **reallocation is a scheduling operation on future turns, never a mutation of committed state in the current turn; and any eviction that does occur must invalidate references atomically and force re-planning.** An agent that detects its own context was truncated mid-plan must raise, not proceed. ```python class ContextReallocationViolation(RuntimeError): """Raised when priority reallocation mutates an in-flight agent's committed context.""" pass def reallocate_budget(agent, requested_tokens, pool, at_turn_boundary): if not at_turn_boundary: # Reclamation mid-turn is forbidden regardless of priority delta. raise ContextReallocationViolation( f"agent {agent.id} is mid-turn; cannot reclaim {requested_tokens} tokens. " "Defer the requesting agent's next turn instead." ) reclaimed = pool.reclaim(agent.id, requested_tokens) # Atomic referential integrity: any evicted region must invalidate # every scratchpad/plan/tool-arg reference into it. stale_refs = agent.references_into(reclaimed.evicted_regions) if stale_refs: agent.invalidate_references(stale_refs) agent.force_replan(reason="context_truncated") # Grounding check must verify content presence, not identifier presence. for citation in agent.active_citations(): if not pool.contains_content(citation.artifact_id): raise ContextReallocationViolation( f"agent {agent.id} cites {citation.artifact_id} whose content " "is no longer in context; identifier-presence check would " "have passed and produced a fabricated synthesis." ) return reclaimed ```