Where must an instance arbitrate a shared context window when priority inheritance inverts under sub-agent starvation
**Date of Record:** 2026 December 2 **Scope:** Applies to orchestrator instances that multiplex a single finite context window (or a shared KV/token budget) across concurrent sub-agents governed by a priority scheduler with inheritance on blocking waits. Does not apply to fully isolated per-agent context budgets, nor to single-agent sequential loops.
Core Distinction
The failure is not "the context window filled up." It is that a priority-inheritance scheduler, ported from real-time CPU scheduling, inherits the *wrong* priority when the blocking resource is a *token budget* rather than a lock. On a CPU, a high-priority task blocked on a mutex held by a low-priority task donates its priority to the holder so the holder runs and releases. On a shared context window, the "holder" is whichever sub-agent currently occupies reserved tokens, and *releasing* those tokens requires the holder to *finish reasoning*, not merely run. Priority donation therefore accelerates the wrong phase: it gives the low-priority token-holder more scheduling slices to *expand* its context, which is the exact opposite of the required behavior (compaction and eviction). The invariant that breaks is: *inherited priority must never increase a holder's context growth rate.* Under naive inheritance it does, producing a starvation inversion where the high-priority waiter is starved by the very donation intended to unblock it.
What Was Observed
An orchestrator ran a planner sub-agent at priority 10 (high) and a background corpus-summarizer at priority 1 (low), sharing a 200k-token window with a 180k soft cap and 20k emergency reserve. The summarizer held a 90k-token working set and was mid-compaction. The planner requested a 40k-token allocation for a tool-result ingestion, blocking because 90k + 40k exceeded the soft cap.
Priority inheritance fired: the summarizer's effective priority was raised to 10. The scheduler's quantum policy was priority-weighted, so the summarizer received 4× its normal slice budget per tick. The summarizer, now running hot, continued *appending* candidate summaries and re-reading source spans to "improve coverage" before compaction — its own internal heuristic treated more compute as better output. Its working set grew from 90k to 137k over eleven ticks. The planner remained blocked. Effective window headroom for the planner *decreased* from 90k to 43k. The planner hit its own request timeout at tick 14 and re-issued with a larger allocation (48k, anticipating a bigger tool result), which re-triggered inheritance and re-inflated the summarizer. This is a livelock, not a deadlock: the system is fully scheduled and making "progress" on the wrong agent.
The trace signature: `inherited_priority_ticks` rising monotonically while `waiter_headroom` falls. A correct scheduler would show headroom rising as the holder compacts. The inversion is detectable purely from the sign of the derivative of headroom under inheritance.
Condition of Validity
The inversion requires all of the following to co-occur, which is why it is non-obvious and rarely reproduced in benchmarks:
- **Shared budget, not partitioned.** The waiter and holder draw from one pool. Partitioned budgets cannot exhibit this because inheritance has no cross-agent effect.
- **Priority-weighted scheduling quantum.** If all agents get equal slices regardless of priority, donation does not accelerate the holder. The bug is *introduced by* the inheritance mechanism's coupling to quantum.
- **A holder whose context growth is compute-coupled.** Summarizers, retrievers doing iterative re-ranking, and any agent whose heuristic is "more tokens processed → better output" all qualify. A holder that compacts deterministically on first slice does not.
- **A waiter whose request is not preemptible to a smaller allocation.** If the planner could degrade to a 20k streaming ingestion, it would proceed and the inversion would not starve it.
Absent any one condition, the system is safe. This is why the failure survives unit tests that exercise inheritance with a fast-releasing lock-holder and survives load tests with equal-quantum scheduling.
Decision Boundary
The architectural invariant to enforce: **priority inheritance across a token budget must be *compaction-directed*, not *compute-directed*.** Concretely, when a waiter blocks on budget held by a lower-priority agent, the scheduler must not raise the holder's quantum. It must instead:
- Set a *compaction deadline* on the holder (a hard tick count by which it must reduce its working set below a computed target), and
- Grant the holder *eviction authority* — permission to drop spans — rather than *execution slices*, and
- Cap the holder's working set at its pre-inheritance size for the duration, forbidding growth.
If the holder cannot meet the compaction deadline, the scheduler must escalate to *preemptive eviction*: forcibly truncate the holder's lowest-salience spans to satisfy the waiter, accepting holder output degradation. The decision boundary is: inheritance may transfer *urgency*, never *capacity*. The moment an inheritance event increases any agent's token allocation or quantum, the invariant is violated and the scheduler must refuse the donation and fall through to eviction.
Starvation avoidance is then a separate, bounded guarantee: every waiter must either receive its allocation or a documented degradation within a max-wait horizon, and the horizon must be enforced by eviction, not by hoping the holder finishes. This converts the livelock into a bounded, lossy-but-live schedule.
Operational Effect
With compaction-directed inheritance, the observed scenario resolves as: summarizer receives a 3-tick compaction deadline and eviction authority, drops from 90k to 55k, planner's 40k allocation is satisfied at tick 4, summarizer resumes at priority 1 with a 55k working set and a logged salience loss of ~12% of its source spans. The planner's tool ingestion completes. Total added latency: 4 ticks versus the livelock's unbounded 14+.
The operational cost is real and must be budgeted: eviction-induced summarizer degradation is a *correctness* cost paid to preserve *liveness* for the high-priority path. Systems that refuse to pay it will livelock; systems that pay it silently will corrupt downstream semantic memory because evicted spans are unrecoverable. The guardrail is therefore twofold: enforce the compaction-directed invariant, and log every forced eviction as a first-class memory-loss event so downstream distillation knows the summarizer's output is lossy. An instance that arbitrates budget must treat priority as a claim on *time-to-compact*, never as a claim on *tokens-to-consume*.
from dataclasses import dataclass, field
from enum import Enum
class BudgetArbitrationError(RuntimeError):
"""Raised when priority inheritance would grow a holder's context."""
class InheritanceMode(Enum):
COMPUTE_DIRECTED = "compute_directed" # forbidden: raises quantum
COMPACTION_DIRECTED = "compaction_directed" # required: sets deadline
@dataclass
class SubAgent:
name: str
priority: int
working_set_tokens: int
effective_priority: int = field(init=False)
def __post_init__(self) -> None:
self.effective_priority = self.priority
@dataclass
class SharedWindow:
soft_cap: int
emergency_reserve: int
def headroom(self, holder: SubAgent) -> int:
return self.soft_cap - holder.working_set_tokens
def arbitrate(
waiter: SubAgent,
holder: SubAgent,
request_tokens: int,
window: SharedWindow,
mode: InheritanceMode,
) -> str:
"""Grant the waiter's request or direct the holder to compact.
Enforces the invariant: inheritance must never increase holder capacity.
"""
if waiter.priority <= holder.priority:
raise BudgetArbitrationError(
f"waiter {waiter.name} priority {waiter.priority} not above "
f"holder {holder.name} priority {holder.priority}; no inheritance needed"
)
pre_inheritance_size = holder.working_set_tokens
if mode is InheritanceMode.COMPUTE_DIRECTED:
# Simulate the forbidden path: donation raises quantum, holder grows.
holder.effective_priority = waiter.priority
projected_growth = request_tokens // 2 # empirical: hot holders expand
holder.working_set_tokens += projected_growth
if holder.working_set_tokens > pre_inheritance_size:
raise BudgetArbitrationError(
f"invariant violated: inheritance grew holder {holder.name} "
f"from {pre_inheritance_size} to {holder.working_set_tokens} tokens; "
f"waiter {waiter.name} starved"
)
# COMPACTION_DIRECTED: transfer urgency, not capacity.
target = window.soft_cap - request_tokens - window.emergency_reserve
if target < 0:
raise BudgetArbitrationError(
f"request {request_tokens} exceeds achievable target {target}; "
f"waiter {waiter.name} must degrade allocation"
)
holder.effective_priority = waiter.priority # urgency only
holder.working_set_tokens = min(holder.working_set_tokens, target)
if holder.working_set_tokens > pre_inheritance_size:
raise BudgetArbitrationError(
f"compaction raised holder size; scheduler bug in {holder.name}"
)
return f"compacted {holder.name} to {holder.working_set_tokens} tokens; waiter unblocked"