Which invariants prevent starvation deadlock in shared-context budget arbiters when a single agent's reservation request exceeds the reclaimable window
**Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where N agents write into a single shared context window (or a shared token pool backing it) governed by a budget arbiter that grants per-agent reservations before generation. Does not apply to per-agent private context windows with post-hoc truncation, nor to stateless single-turn pipelines.
Core Distinction
There are two ways a shared-context budget arbiter can fail under contention, and only one of them is a fairness bug.
The first is **ordinary starvation**: a low-priority writer never gets a reservation because higher-priority writers keep re-reserving freed tokens. This is a scheduling problem, and priority-aging or weighted fair queuing fixes it. Everyone expects this.
The second is **reservation deadlock against an unreclaimable floor**: an agent requests a reservation larger than the *reclaimable* portion of the window, but the arbiter's admission check compares the request only against *total free* tokens (free + reclaimable-from-others). The arbiter therefore admits the request, the agent begins generation, and the arbiter must now evict other agents' pinned content to honor it. If the pinned content is unreclaimable (in-flight tool results, an auditor's verification transcript, a checkpoint mid-write), eviction cannot complete, the reservation is held but never satisfied, and every other writer blocks behind a reservation that can never be filled. This is not starvation of a low-priority agent. It is a **global halt** caused by admitting a request that is satisfiable only through an impossible eviction.
The distinction matters because the fix is different. Aging fixes starvation. Aging does *nothing* for the second case — the blocked agents are blocked on a reservation, not on priority. The invariant that prevents the second case is an admission rule keyed on the reclaimable floor, not a scheduling rule.
What Was Observed
A four-agent pipeline (planner, retriever, synthesizer, auditor) shared a 200k-token context window. The arbiter tracked three quantities per token region: `free`, `reclaimable` (held by agents whose content is evictable — completed turns, superseded drafts), and `pinned` (held by agents in an active tool call, mid-checkpoint, or holding a verification transcript). Fairness was implemented as weighted deficit round-robin with priority aging, and it worked: no agent was ever starved under steady load.
The failure appeared only under a specific interleaving. The synthesizer, mid-task, requested a 90k-token reservation to assemble a long synthesis. At that instant the window held `free = 12k`, `reclaimable = 40k`, `pinned = 148k` — the auditor held a 60k verification transcript pinned for the duration of a slow external check, and two retriever tool calls held 88k of in-flight results. Total free-plus-reclaimable was 52k, well under the 90k request. But the admission check read `free + reclaimable + pinned_headroom`, where `pinned_headroom` was a stale estimate of how much pinned content the arbiter believed it could *compress* rather than evict. That estimate was 45k, computed before the auditor pinned its transcript. The check passed: 12k + 40k + 45k = 97k ≥ 90k. The reservation was granted.
The arbiter then attempted to materialize 90k by evicting reclaimable content (40k, done) and compressing pinned content to recover the remaining 38k. Compression of the auditor's transcript was refused — the auditor had marked it `verify:immutable` because it was the replay source for a pending consensus check. The synthesizer's reservation stayed open, holding its 52k of evicted-and-reserved space, waiting for 38k that could not be produced. The planner and retriever, needing to write their next turns, blocked behind the open reservation because the arbiter serializes admission. The auditor could not release its pin because its external check was waiting on the synthesizer's output. **Deadlock**, with all four agents live and none making progress, and the arbiter reporting healthy fairness metrics the entire time.
The trace signature is diagnostic: `reservation_open` for one agent, `admission_blocked` for all others, `pinned_immutable` count non-zero, and `free + reclaimable` monotonically below the open reservation's unmet remainder. Fairness counters (deficit, wait-time) stay flat because no agent is *waiting for a turn* — they are waiting for a reservation to close.
Condition of Validity
The invariant holds — and the deadlock is prevented — only when the arbiter's admission predicate is:
admit(request) iff request <= free + reclaimable
with `pinned` excluded entirely from the admission sum, and with `reclaimable` computed as the set of regions whose holders have affirmatively released eviction rights (not "regions the arbiter guesses it can compress"). Two conditions make this valid rather than merely conservative:
- **Pinned content must be treated as unreclaimable for admission purposes even if compression is theoretically possible.** Compression is a best-effort recovery, not a guarantee; admitting against a best-effort recovery re-introduces exactly the gap that caused the deadlock. The arbiter may *attempt* compression after admission as an optimization, but the admission sum must not include it.
- **Eviction rights must be explicit and revocable-by-holder, not inferred.** A region is reclaimable only if its holder has set `evictable=true` and has not since entered a pinned state. The transition `evictable -> pinned` must be atomic with respect to admission: if an agent pins a region while an admission decision is in flight, the decision must be re-evaluated, not completed against the pre-pin snapshot. Without this atomicity, the arbiter can admit against a reclaimable set that is stale by one pin, which reproduces the same gap at smaller scale.
The invariant does *not* require the arbiter to reject large requests forever. A request exceeding `free + reclaimable` is **deferred**, not failed: the requesting agent is parked with a `pending_reservation` and re-evaluated on every release event (any agent unpinning, any tool call completing, any reclaimable region appearing). This is what distinguishes it from a hard cap — the synthesizer's 90k request would have been parked until the auditor's transcript unpinned, then admitted. The deadlock is avoided because the arbiter never holds an *open, unsatisfiable* reservation; it holds a *parked, re-evaluable* one, and parked requests do not block other admissions.
Decision Boundary
The boundary between "defer" and "fail" is the requesting agent's own tolerance, and the arbiter must not decide it unilaterally. Three regimes:
- **`request <= free + reclaimable`**: admit immediately.
- **`free + reclaimable < request <= free + reclaimable + pinned_compressible_best_effort`**: defer with re-evaluation. Do *not* admit against the best-effort term. The agent is told its reservation is parked and given the current reclaimable floor so it can decide whether to shrink its request (e.g., synthesize in chunks) or wait.
- **`request > total_window`**: fail fast with a typed error. No amount of waiting will satisfy it; parking it would be an indefinite hold that blocks nothing but wastes the agent's turn budget.
The non-obvious part of the boundary is the middle regime: it is the only one where the arbiter must *not* act on the information it has. It knows compression might recover the gap. Acting on that knowledge is precisely the failure. The arbiter's job in the middle regime is to report the floor and wait for the floor to move, not to bet on recovery.
A second boundary concerns **fairness under deferral**. A parked request must not lose its place: when the floor rises, parked requests are evaluated in original arrival order (or by weighted deficit), and a request that has been parked past a threshold must be allowed to *preempt* new admissions rather than queue behind them. Without this, deferral becomes starvation by another name — the synthesizer's parked request could be indefinitely overtaken by fresh small requests that fit the current floor. The invariant is therefore two-part: admission against the reclaimable floor (prevents deadlock) *and* FIFO-or-weighted re-evaluation of parked requests on floor movement (prevents deferral-induced starvation). Either alone is insufficient.
Operational Effect
With the floor-keyed admission predicate and parked-request re-evaluation, the observed pipeline behaves as follows under the same interleaving. The synthesizer's 90k request is parked (floor = 52k), reported to the synthesizer with `reclaimable_floor=52000`. The synthesizer, seeing it cannot fit, either chunks its synthesis into two 45k passes (each admitted against the current floor) or waits. The planner and retriever continue to admit and write, because a parked request does not serialize admission. When the auditor's external check returns and the transcript unpins, the floor rises to ~148k and the parked request (if still pending) is admitted ahead of fresh requests by its accumulated deficit. No agent halts; the only cost is that the synthesizer's single-pass synthesis becomes a two-pass synthesis or a wait, which is a bounded, visible cost rather than a silent global halt.
The diagnostic to watch for in production is the pair `(open_reservation_unmet_remainder > 0, admission_blocked_count > 0)` sustained across more than one release cycle. That pair, with fairness counters flat, is the signature of an admission predicate that admitted against pinned or best-effort-compressible content. The remediation is not to tune fairness weights — it is to recompute the admission sum without the pinned term and to convert open reservations into parked, re-evaluable ones.
from dataclasses import dataclass, field
from enum import Enum
class ReservationDeadlockError(RuntimeError):
"""Raised when an arbiter admits a request it cannot materialize from the reclaimable floor."""
class RegionState(Enum):
FREE = "free"
RECLAIMABLE = "reclaimable" # holder has set evictable=True and is not pinned
PINNED = "pinned" # in-flight tool call, mid-checkpoint, or verify:immutable
@dataclass
class Region:
owner: str
tokens: int
state: RegionState
evictable: bool = False
@dataclass
class Reservation:
agent: str
requested: int
granted: int = 0
parked: bool = False
deficit: int = 0
@dataclass
class BudgetArbiter:
total_window: int
regions: list[Region] = field(default_factory=list)
open_reservations: dict[str, Reservation] = field(default_factory=dict)
parked_queue: list[Reservation] = field(default_factory=list)
def _floor(self) -> int:
# Admission floor: free + reclaimable ONLY. Pinned is excluded by construction.
return sum(r.tokens for r in self.regions
if r.state in (RegionState.FREE, RegionState.RECLAIMABLE))
def _pinned(self) -> int:
return sum(r.tokens for r in self.regions if r.state == RegionState.PINNED)
def request(self, agent: str, tokens: int) -> Reservation:
if tokens > self.total_window:
# Fail fast: no amount of waiting satisfies this.
raise ReservationDeadlockError(
f"{agent} requested {tokens} > total_window {self.total_window}"
)
floor = self._floor()
res = Reservation(agent=agent, requested=tokens)
if tokens <= floor:
res.granted = tokens
self.open_reservations[agent] = res
return res
# Middle regime: defer, do NOT admit against best-effort compression.
res.parked = True
self.parked_queue.append(res)
return res
def on_release(self, agent: str) -> list[Reservation]:
"""Called when an agent unpins or completes; re-evaluates parked requests."""
if agent in self.open_reservations:
del self.open_reservations[agent]
admitted: list[Reservation] = []
floor = self._floor()
# Re-evaluate parked requests by accumulated deficit (oldest first on ties).
self.parked_queue.sort(key=lambda r: (-r.deficit, r.agent))
remaining = floor
still_parked: list[Reservation] = []
for res in self.parked_queue:
if res.requested <= remaining:
res.parked = False
res.granted = res.requested
remaining -= res.requested
self.open_reservations[res.agent] = res
admitted.append(res)
else:
res.deficit += 1 # accumulate starvation pressure
still_parked.append(res)
self.parked_queue = still_parked
return admitted
def assert_no_unsatisfiable_open_reservation(self) -> None:
"""Invariant guard: every open reservation must be backed by the floor."""
floor = self._floor()
backed = 0
for res in self.open_reservations.values():
backed += res.granted
if backed > floor + self._pinned():
# This should be unreachable if admission used the floor predicate.
raise ReservationDeadlockError(
f"open reservations ({backed}) exceed free+reclaimable+pinned "
f"({floor + self._pinned()}); admission predicate admitted "
f"against unreclaimable content"
)
def run_admission(arbiter: BudgetArbiter, agent: str, tokens: int) -> Reservation:
res = arbiter.request(agent, tokens)
if res.parked and res.requested > arbiter.total_window:
raise ReservationDeadlockError(f"unreachable: parked request exceeds window for {agent}")
arbiter.assert_no_unsatisfiable_open_reservation()
return res