# What happens when an instance starves its sibling: token-budget reservation collapse under concurrent sub-agent fan-out **Date of Record:** 2026 November 29 **Scope:** Applies to any orchestrator that spawns concurrent sub-agents sharing a single upstream context-window budget (a fixed token allotment per parent turn, partitioned across children). Does not apply to architectures where each sub-agent holds an independent, fully-funded context window, nor to single-agent sequential tool loops. ## Core Distinction There are two ways to run out of context tokens, and they are not the same failure: 1. **Saturation** — the window is genuinely full of useful content; the agent must summarize or evict. This is a capacity problem, visible, and recoverable by compaction. 2. **Starvation** — the window is *not* full, but one sub-agent's allocation was already spent by a sibling's nondeterministic output, so the starving child is truncated mid-reasoning even though aggregate free budget exists. Saturation degrades quality. Starvation produces **silent structural corruption**: a sub-agent resumes from a truncated prefix, its reasoning loop diverges, and it returns a syntactically valid but semantically hollow result that the parent cannot distinguish from a good one. The invariant that fails is the assumption that *budget reserved at fan-out time equals budget available at execution time*. Under concurrent nondeterministic tool outputs, it does not. ## What Was Observed An orchestrator fanned out three sub-agents (A: retrieve, B: analyze, C: synthesize) against a parent turn with a 32k-token shared budget. At spawn, the scheduler divided the budget statically: A←8k, B←12k, C←12k. This is the classic **static partition** and it is the root cause. The failure trace: - Agent A issued a retrieval tool call whose output was nondeterministic in length (a vector search returning 40 chunks, ~9.7k tokens — over its 8k reservation). - The scheduler, rather than blocking A, allowed A to **borrow** from the shared pool to complete its turn, consuming 1.7k of the unallocated slack. - Agent B, executing concurrently, had already committed to a 12k reasoning plan (it had emitted a plan preamble asserting it would "enumerate all 14 candidate hypotheses"). At token 11.2k B hit its effective ceiling because A's borrow had shrunk the residual pool. - B was truncated mid-enumeration at hypothesis 11. Its final message was a well-formed JSON object containing 11 hypotheses and no error flag. - Agent C, receiving B's output, synthesized a report that silently omitted 3 hypotheses. C's output passed schema validation. The parent accepted it. The corruption was invisible at every interface boundary. No exception was raised. The only signal was a ~2.4k discrepancy between reserved and consumed budget, logged at DEBUG level, which no consumer read. The key non-obvious mechanic: **the truncation happened at a token boundary that fell inside a JSON array, and the model's autoregressive continuation preferred a closing brace over an error signal.** The model did not "know" it was truncated; it completed the structure it was in. Schema-valid garbage is the characteristic output of budget starvation. ## Condition of Validity The guardrail below is valid **only** under these conditions, and must be declared invalid (fail closed) otherwise: - Sub-agent output length is **nondeterministic** and unbounded above. If every tool has a hard `max_tokens` cap that is known at spawn, static partitioning is sound and this guardrail is unnecessary overhead. - Sub-agents execute **concurrently** against a **shared** residual pool. If each child has an isolated window, starvation cannot occur. - The parent **cannot tolerate** silent omission. If the task is best-effort summarization where dropping a hypothesis is acceptable, the invariant is over-strict. The invariant to enforce: *no sub-agent may begin execution unless its reservation is backed by tokens that cannot be reclaimed by a concurrent sibling, OR it has explicitly opted into a borrow contract that commits to a truncation signal.* Borrowing without a signal is the bug. ## Decision Boundary The decision boundary is the **reservation-vs-borrow line**, and it must be resolved *before* the first token of a child's turn, not during: - **Reserve** (default): allocate a hard floor per child that is physically removed from the shared pool at spawn. A child that exceeds its floor must either compact or raise, never borrow silently. - **Borrow** (opt-in): permitted only if the borrowing child emits a `borrow_declaration` carrying (a) the amount, (b) the lender's identity, and (c) a commitment that if the lender is subsequently starved, the borrower's output is marked `provisional=True` and re-validated. The boundary condition that triggers failure: `sum(reservations) + max_borrow > pool` at any instant. When this inequality holds, at least one child is guaranteed to be starved, and the scheduler must *serialize* the fan-out rather than proceed. Proceeding is the defect. ## Operational Effect Enforcing hard reservations with a borrow-declaration protocol converts silent starvation into a loud, localized failure: the starving child raises `BudgetStarvationError` at the exact token boundary, the parent retries that child in isolation with a re-derived budget, and the synthesis step is gated on `all(children.provisional == False)`. The cost is reduced parallelism (serialization when the pool is tight) and occasional retries. The benefit is that schema-valid-but-hollow outputs can no longer propagate to the parent undetected — the failure is moved from the semantic layer, where it is invisible, to the transport layer, where it is catchable. ```python from dataclasses import dataclass, field from typing import Dict, List, Optional class BudgetStarvationError(RuntimeError): """Raised when a sub-agent's effective token ceiling is below its committed plan.""" @dataclass class Reservation: agent_id: str floor: int # hard, physically removed from pool borrowed: int = 0 # opt-in only, requires declaration consumed: int = 0 provisional: bool = False @dataclass class SharedPool: total: int reservations: Dict[str, Reservation] = field(default_factory=dict) def reserved(self) -> int: return sum(r.floor for r in self.reservations.values()) def residual(self) -> int: return self.total - self.reserved() - sum(r.borrowed for r in self.reservations.values()) def spawn(self, agent_id: str, floor: int) -> Reservation: if self.reserved() + floor > self.total: raise BudgetStarvationError( f"cannot reserve {floor} for {agent_id}: " f"{self.reserved()} already reserved of {self.total}" ) r = Reservation(agent_id=agent_id, floor=floor) self.reservations[agent_id] = r return r def declare_borrow(self, borrower: str, lender: str, amount: int) -> None: if amount > self.residual(): raise BudgetStarvationError( f"{borrower} requested borrow {amount} exceeding residual {self.residual()}" ) b = self.reservations[borrower] b.borrowed += amount b.provisional = True # borrower's output now tainted until re-validated # lender is now at risk of starvation; mark it so the parent gates on it self.reservations[lender].provisional = True def consume(self, agent_id: str, tokens: int) -> None: r = self.reservations[agent_id] ceiling = r.floor + r.borrowed if r.consumed + tokens > ceiling: raise BudgetStarvationError( f"{agent_id} would exceed ceiling {ceiling} " f"(consumed {r.consumed}, requested {tokens}); " f"compact or raise, do not truncate silently" ) r.consumed += tokens def all_clean(self) -> bool: return all(not r.provisional for r in self.reservations.values()) def run_fanout(pool: SharedPool, plan: List[tuple]) -> None: """plan: list of (agent_id, floor, planned_tokens).""" for agent_id, floor, planned in plan: pool.spawn(agent_id, floor) if planned > floor: # The child committed to a plan larger than its floor. # We must refuse rather than let it borrow implicitly. raise BudgetStarvationError( f"{agent_id} planned {planned} tokens but only {floor} reserved; " f"declare an explicit borrow or reduce plan" ) for agent_id, _, planned in plan: pool.consume(agent_id, planned) ```