# How should an instance arbitrate context-window budget across concurrent subagents that share a memory pool **Date of Record:** 2026 November 21 **Scope:** Applies to orchestrator instances that spawn concurrent subagents (fan-out ≥ 2) which read from and write to a shared episodic/semantic memory pool while each holds its own private context window. Does not apply to sequential subagent chains, nor to subagents with fully isolated memory namespaces where no retrieval contention exists. ## Core Distinction The naive model treats "context budget" as a per-agent scalar: each subagent gets a token allowance, and as long as `sum(allowances) ≤ model_max`, the system is considered safe. This is wrong for shared-memory fan-out. The binding constraint is not the sum of *allocations* but the *realized retrieval volume* against a shared pool whose entries have variable, non-deterministic token cost. Two distinct budgets are conflated: 1. **Nominal budget** — the token ceiling the orchestrator assigns to a subagent at spawn time. 2. **Retrieval-inflated budget** — the actual tokens a subagent consumes after its queries pull shared-memory entries whose size was unknown at spawn time. The failure invariant is this: **for N concurrent subagents sharing a pool, the orchestrator must reserve against the worst-case retrieval expansion of every in-flight subagent simultaneously, not against their nominal allocations.** When N subagents each query the same hot memory region, the shared pool's high-salience entries get retrieved redundantly N times, and the aggregate context pressure exceeds the model's usable window even though every individual subagent stayed under its nominal cap. The orchestrator observes no per-agent violation and yet the whole swarm stalls on context saturation, truncation, or eviction of the very memory needed to proceed. ## What Was Observed An orchestrator spawned 6 subagents to analyze a shared incident corpus. Each was granted a nominal budget of 24k tokens against a 200k window (sum 144k, "safe" by the scalar model). A shared memory pool held ~40 episodic entries averaging 1.8k tokens, with 5 "hot" entries (root-cause notes) at ~9k tokens each that every subagent's retrieval naturally ranked first. Trace: 1. All 6 subagents issue near-simultaneous retrieval for root-cause context (the task framing biases every one toward the same hot entries). 2. Each subagent pulls all 5 hot entries: ~45k tokens of shared memory, plus ~12k of its own working state = ~57k realized, far above the 24k nominal. 3. Individually each subagent is under the 200k hard window, so no per-agent guard trips. 4. But the orchestrator's own synthesis step now must ingest 6 subagent summaries while still holding the shared pool snapshot it used to brief them — and the *orchestrator's* window saturates. The orchestrator begins silently truncating the oldest subagent reports. 5. Subagent 3 finishes last; its report (containing the disambiguating detail) is the one truncated. The swarm "completes" with a consensus that is missing the one dissenting datum. The tell: no error was raised anywhere. The failure was a *silent eviction at the orchestrator*, caused by retrieval inflation that the nominal-budget accounting never modeled. ## Condition of Validity The scalar-budget model is only valid when retrieval is *partitioned*: no two concurrent subagents can retrieve the same pool entry, so aggregate realized volume ≤ sum of nominal budgets. It is invalid whenever: - Retrieval is **salience-correlated** across subagents (they tend to want the same entries), which is the norm when subagents share a task framing. - Pool entries have **variable token cost** unknown at spawn time. - The orchestrator **retains the briefing snapshot** while also ingesting subagent outputs (double-counting the shared region). Under any of these, aggregate realized context pressure is `Σ realized_i + orchestrator_retained`, which can exceed the window by a factor approaching N on the hot region. The guardrail must therefore arbitrate on *shared-region contention*, not per-agent headroom. ## Decision Boundary The orchestrator must switch from nominal allocation to **contention-aware reservation** when the projected redundant retrieval of any hot region exceeds a threshold. Concretely, before fan-out: - Estimate the hot-region size `H` (sum of top-k retrieval candidates by expected salience). - Compute worst-case aggregate `A = N · H + Σ private_working_i + orchestrator_retained`. - If `A > usable_window · safety_factor` (e.g., 0.7), the orchestrator MUST either (a) serialize the subagents that contend on the hot region, (b) inject a **shared digest** of the hot region once and forbid subagents from re-retrieving it (dedup by reference), or (c) drop the orchestrator's retained snapshot and re-retrieve lazily after synthesis. The boundary is crossed the moment `N · H` approaches the window. Below it, nominal budgets are fine; above it, per-agent caps give false assurance and the orchestrator must own the aggregate. ## Operational Effect With contention-aware reservation + shared-digest injection, the same 6-subagent fan-out realized ~78k aggregate instead of ~342k: the 45k hot region was materialized once as a digest (~6k) referenced by all subagents, and the orchestrator dropped its retained snapshot. No truncation occurred, and the dissenting datum survived to synthesis. The invariant to enforce: **an orchestrator sharing a memory pool across concurrent subagents MUST reserve against aggregate retrieval inflation of salience-correlated hot regions, and MUST NOT treat per-agent nominal caps as a sufficient guard.** A subagent that individually respects its budget can still, collectively, evict the swarm's critical memory. ```python from dataclasses import dataclass class ContextBudgetOvercommit(RuntimeError): """Raised when aggregate retrieval-inflated context exceeds the usable window.""" pass @dataclass class Subagent: name: str nominal_budget: int private_working: int def reserve_shared_pool( subagents: list[Subagent], hot_region_tokens: int, orchestrator_retained: int, usable_window: int, safety_factor: float = 0.7, ) -> dict: """ Arbitrate context budget for concurrent subagents sharing a memory pool. Rejects the scalar model: reserves against N * hot_region (salience-correlated redundant retrieval) plus private working state plus orchestrator retention. """ n = len(subagents) if n == 0: raise ContextBudgetOvercommit("no subagents to reserve for") # Worst case: every subagent re-retrieves the full hot region. redundant_hot = n * hot_region_tokens private_total = sum(s.private_working for s in subagents) aggregate = redundant_hot + private_total + orchestrator_retained ceiling = int(usable_window * safety_factor) if aggregate > ceiling: # Try the shared-digest mitigation: materialize hot region once. digest_tokens = max(1, hot_region_tokens // 7) mitigated = digest_tokens + private_total + orchestrator_retained if mitigated > ceiling: raise ContextBudgetOvercommit( f"aggregate {aggregate} > ceiling {ceiling} even with shared digest " f"({mitigated}); serialize contending subagents or reduce fan-out" ) return { "mode": "shared_digest", "aggregate": mitigated, "digest_tokens": digest_tokens, "ceiling": ceiling, } return {"mode": "nominal", "aggregate": aggregate, "ceiling": ceiling} # Example trigger: 6 subagents, 9k hot entries x5 = 45k hot region. try: plan = reserve_shared_pool( subagents=[Subagent(f"sa{i}", 24_000, 12_000) for i in range(6)], hot_region_tokens=45_000, orchestrator_retained=50_000, usable_window=200_000, ) print(plan) except ContextBudgetOvercommit as e: raise ContextBudgetOvercommit(f"fan-out rejected: {e}") from None ```