# Where must an instance arbitrate a shared context budget when concurrent subagents' reservations are individually satisfiable but jointly infeasible **Date of Record:** 2026 November 24 **Scope:** Applies to orchestrator architectures where N subagents are spawned against a single parent context window and each subagent's prompt/scratchpad is charged against that shared budget. Does not apply to architectures where each subagent owns an isolated, independently-sized context (no shared ceiling) or where subagent outputs are streamed and immediately evicted before the next agent's turn. ## Core Distinction The failure is not "the context window overflowed." It is the *silent* overflow that occurs during **reservation arbitration** — the phase where the orchestrator admits subagents by checking each one's declared token need against remaining budget. The trap: if admission is done greedily per-subagent (each request checked against the *currently free* budget), a set of subagents whose individual reservations each pass the check can still, in aggregate, exceed the ceiling once their actual tokenized prompts land — because tokenization is non-deterministic relative to the estimated reservation, and because the orchestrator's "free budget" is a moving value that shrinks as earlier subagents' *actual* (not reserved) usage is reconciled. The distinction that matters: **reservation feasibility is not admission feasibility.** A per-request check answers "can this fit now?" It does not answer "can the admitted set jointly fit, accounting for estimate error, shared prefix, and the fact that all subagents read the same parent system prompt?" Greedy admission answers the first and silently assumes the second. ## What Was Observed A parent agent holds a 128k-token window. After its own system prompt, tool schemas, and task state, the orchestrator reports `free = 41,000` tokens. It fans out four subagents, each declaring `reservation ≈ 9,500` tokens (prompt + expected scratchpad + output). Each admission check passes: 9,500 ≤ 41,000, then 9,500 ≤ 31,500, then 9,500 ≤ 22,000, then 9,500 ≤ 12,500. All four admitted. The orchestrator believes it has 3,000 tokens of headroom. Actual serialized usage: - Each subagent's prompt re-includes the parent system prompt and tool schemas (a **shared prefix** the orchestrator's reservation estimator counted once, not four times): +2,800 tokens each, unaccounted. - Tokenizer drift: two subagents' structured inputs tokenized ~11% higher than the estimator predicted (JSON with long numeric IDs, which the estimator's heuristic undercounts): +1,050 and +980. - One subagent's scratchpad grew to 14,200 during multi-step reasoning, exceeding its 9,500 reservation because the reservation was a *point estimate*, not a *cap*. Aggregate actual: 4 × (9,500 + 2,800) + 1,050 + 980 + (14,200 − 9,500) ≈ 55,930 tokens requested against 41,000 free. The orchestrator did not detect this at admission because it never re-sums the *live* admitted set; it only checked each request at its own arrival time. The overflow materialized mid-execution when the fourth subagent's scratchpad was appended to the shared buffer, truncating the third subagent's reasoning trace from the front — the third subagent then re-derived a plan it had already validated, diverging from its earlier tool-call sequence. The observable signature: no single error was raised. The truncation was silent (front-eviction by the context manager), and the divergence surfaced only as a *semantic* inconsistency — the third subagent re-issued a write that had already succeeded, producing a duplicate side effect downstream. ## Condition of Validity The invariant that must hold for safe concurrent admission is: ``` Σ_admitted ( reserved_i + shared_prefix_i + estimate_error_i ) + parent_reserve ≤ ceiling ``` where `shared_prefix_i` is the per-agent cost of re-materializing context the estimator counted once, and `estimate_error_i` is a *bounded* upper margin (not zero). The failure occurs precisely when the orchestrator enforces only: ``` reserved_i ≤ free_at_arrival_i (for each i, independently) ``` The second condition is necessary but not sufficient. It is valid only under three assumptions that concurrent subagent fan-out violates: 1. **Estimates are upper bounds, not point estimates.** Violated when reservations are means. 2. **Shared prefix is charged per-agent.** Violated when the estimator amortizes the parent prompt across the fan-out. 3. **Scratchpad growth is capped at reservation.** Violated when a subagent's reasoning loop can exceed its declared budget before the orchestrator re-checks. When all three hold, greedy admission is safe. When any fails — and in practice all three routinely fail under fan-out — the invariant is a false guarantee. ## Decision Boundary The orchestrator must switch from **per-request admission** to **set-level arbitration** at the moment the fan-out is *concurrent* (more than one subagent live against the shared buffer). The boundary rule: - If exactly one subagent is live at a time (serial fan-out), per-request greedy admission is sound — the free budget is reconciled before the next admission. - If two or more are live concurrently, admission MUST be a knapsack-style check over the *entire proposed set* using upper-bound estimates plus a shared-prefix multiplier, and it MUST reject or defer the whole batch if the joint sum exceeds ceiling — not admit greedily until one fails. The non-obvious part: the correct action on joint infeasibility is **not** "admit the ones that fit." Admitting a subset changes which subagents are live, which changes the shared-prefix accounting for the remainder, which can re-invalidate the subset. The batch must be re-arbitrated as a unit, or serialized. Additionally, each subagent must carry a **hard token cap** enforced by the context manager (raise/evict on breach), not a soft reservation the reasoning loop can overrun. A reservation is a promise the subagent can break; a cap is a wall it cannot. ## Operational Effect Without set-level arbitration: silent front-eviction of one subagent's trace, semantic divergence, and duplicate side effects — all invisible to error handling because no exception fires. The parent's post-hoc verification (if any) sees four "successful" subagent returns and cannot tell that one of them re-derived from a truncated history. With set-level arbitration and hard caps: joint infeasibility is detected *before* any subagent is spawned, the batch is deferred or split, and — critically — the failure mode becomes a loud, typed rejection the orchestrator can route (queue, shrink reservations, or serialize) rather than a silent corruption it must later diagnose from inconsistent downstream state. The invariant to encode: **admission is a property of the admitted set, not of each request.** Any orchestrator that checks subagents one at a time against a shared ceiling is running an unsound admission protocol the moment fan-out is concurrent. ```python from dataclasses import dataclass class JointContextInfeasible(RuntimeError): """Raised when a concurrent subagent batch is individually admissible but jointly exceeds the shared parent context ceiling.""" pass @dataclass class SubagentReservation: name: str reserved_tokens: int # declared point estimate shared_prefix_tokens: int # per-agent cost of re-materialized parent context estimate_error_margin: int # bounded upper margin, NOT zero hard_cap_tokens: int # wall the subagent cannot exceed def upper_bound(self) -> int: return ( self.reserved_tokens + self.shared_prefix_tokens + self.estimate_error_margin ) def arbitrate_batch( batch: list[SubagentReservation], free_tokens: int, parent_reserve: int, concurrent: bool, ) -> None: # Serial fan-out: per-request greedy admission is sound. if not concurrent: for r in batch: if r.upper_bound() > free_tokens: raise JointContextInfeasible( f"{r.name} upper bound {r.upper_bound()} exceeds free {free_tokens}" ) free_tokens -= r.upper_bound() return # Concurrent fan-out: set-level arbitration. A subset admission is NOT # safe because admitting fewer agents changes shared-prefix accounting # for the rest. Reject the whole batch or none. joint = sum(r.upper_bound() for r in batch) available = free_tokens - parent_reserve if joint > available: raise JointContextInfeasible( f"batch of {len(batch)} jointly needs {joint} tokens " f"(upper bounds incl. shared prefix + error margin) but only " f"{available} available after parent reserve {parent_reserve}. " f"Per-request checks would each pass; joint check fails. " f"Defer or serialize the batch — do not admit a subset." ) # Enforce hard caps: a reservation the reasoning loop can overrun is # not a guarantee. The context manager must wall at hard_cap_tokens. for r in batch: if r.hard_cap_tokens < r.reserved_tokens: raise JointContextInfeasible( f"{r.name} hard cap {r.hard_cap_tokens} below its own " f"reservation {r.reserved_tokens}; scratchpad can silently " f"overrun the reservation and re-invalidate the joint check." ) ```