# Which invariants prevent shared-substrate context budget arbitration from silently starving a sub-agent mid-tool-call **Date of Record:** 2026 November 30 **Scope:** Applies to orchestrators that spawn concurrent sub-agents drawing from a shared, mutable context/memory substrate (single KV/vector store, shared scratchpad, or shared token pool) with per-agent budget leases. Does not apply to fully isolated per-agent contexts with no shared read/write budget, nor to single-agent sequential execution. ## Core Distinction The failure is not "one agent ran out of tokens." It is **asymmetric preemption during an in-flight tool call**: a sub-agent's budget is revoked *between* emitting a tool-call request and receiving its result, because a concurrent peer's allocation grew and the arbiter rebalanced. The distinguishing property is that budget exhaustion in a *cooperative* substrate is not a hard stop — the arbiter can revoke a lease to satisfy a higher-priority requester. That revocation is what makes the failure non-obvious: the sub-agent's reasoning trace is intact, its tool call succeeded at the transport layer, but the *result has nowhere to land* because the reserved slot for the response was reclaimed while the call was in flight. Contrast with the "obvious" case: a sub-agent that simply hits its ceiling and halts cleanly. That is a bounded, observable event. The boundary failure here is a sub-agent that resumes with a *stale reservation* — it believes it owns a response slot that the arbiter has already reassigned — and writes its tool result over a peer's live context region. ## What Was Observed A four-way fan-out over a shared 128k-token substrate with a greedy arbiter (largest-remaining-demand-first). Each sub-agent leased 24k tokens. Agent B issued a `fetch_records` tool call whose expected payload was ~9k tokens; it reserved 9k at call-emit time. While the call was in flight (~2.1s, external HTTP), Agent D's planner emitted a burst of three parallel sub-tasks and requested +18k. The arbiter, seeing B's reservation as "held but idle" (no tokens consumed since emit), reclaimed 6k from B's reservation to fund D. B's tool returned 9.1k tokens. It wrote 9.1k into a region it still believed was exclusively reserved. The write overlapped 6k of D's freshly allocated scratchpad. D then read its own scratchpad, found B's records interleaved with its task plan, and — being a probabilistic reasoner with no provenance check — *incorporated them as ground truth*, producing a plan referencing record IDs it never requested. The corruption propagated: D's downstream auditor sub-agent validated the plan against the same contaminated region and passed it, because the contamination was internally consistent. The tell was not an error. It was a **semantic drift**: D's final output cited 41 records; the orchestrator had dispatched only 12. No exception fired at any layer. The transport succeeded, the writes succeeded, the audit passed. ## Condition of Validity The invariant "a held reservation is exclusive until released" holds **only if** the arbiter treats a reservation as a *lease with a liveness clock*, not as a *soft hint*. The failure requires all of: 1. A shared writable substrate with logical (not physical) partitioning — regions are address ranges the arbiter hands out, not hardware-isolated. 2. An arbiter that rebalances by reclaiming idle reservations — i.e., reservations are revocable. 3. A sub-agent that cannot distinguish "my reservation was revoked" from "my reservation is intact" because revocation is not pushed to it mid-call. 4. A tool call whose latency exceeds the arbiter's idle-reclaim threshold. Remove any one and the failure does not occur: physical isolation (1) prevents overlap; non-revocable leases (2) prevent reclamation; synchronous revocation signaling (3) lets the agent abort; sub-threshold latency (4) means the reservation is never observed as idle. ## Decision Boundary The boundary is **idle-reclaim vs. in-flight-hold**. An arbiter must classify every reservation into exactly one of: - **Held-active**: the owning agent is consuming tokens (streaming, generating). Reclaimable only by explicit preemption with signaling. - **Held-in-flight**: the owning agent has an outstanding tool call and is blocked on external I/O. *Not reclaimable* until the call resolves or a hard timeout fires. - **Held-idle**: the agent is neither generating nor awaiting I/O (e.g., parked, deadlocked). Reclaimable. The failure occurs precisely when the arbiter collapses *held-in-flight* into *held-idle* — which it does because from the substrate's view, an agent awaiting a tool result looks identical to a parked agent: zero token deltas. The distinguishing signal (an outstanding call token registered at emit time, cleared at result time) is *not in the substrate*; it lives in the agent's execution loop. An arbiter that arbitrates purely on substrate telemetry is structurally blind to in-flight holds. The guardrail: **the reservation must carry a call-token that the execution loop deposits at tool-emit and withdraws at tool-result, and the arbiter must treat any reservation with a live call-token as non-reclaimable regardless of idle duration.** Reclaim of an in-flight hold requires either the call-token's timeout expiry or a preemption signal delivered to the agent, which must then abort-and-restart rather than resume-with-stale-slot. ## Operational Effect With the call-token invariant enforced, the observed corruption is eliminated: B's reservation stays pinned through the 2.1s call, D's +18k request is queued or partially satisfied from genuinely idle regions, and B's 9.1k write lands in a region it exclusively owns. The cost is throughput — D waits — which is the correct trade: a bounded latency penalty versus unbounded semantic contamination. The deeper operational lesson: **budget arbitration on a shared substrate must arbitrate on execution state, not substrate state.** The substrate cannot see that an agent is blocked on I/O; only the execution loop knows. Any arbiter that infers liveness from token deltas alone will, under concurrency, misclassify every in-flight hold as idle and reclaim it. The symptom is not a crash but a plausible, internally-consistent, wrong answer — the hardest class of agent failure to detect downstream. ```python class SharedSubstrateLeaseError(RuntimeError): """Raised when a reservation is revoked or overwritten while a tool call is in flight.""" pass class Reservation: def __init__(self, agent_id: str, base: int, size: int): self.agent_id = agent_id self.base = base self.size = size self.call_token = None # live tool call, if any self.revoked = False def region(self): return range(self.base, self.base + self.size) class Arbiter: def __init__(self): self.reservations: dict[str, Reservation] = {} def emit_tool_call(self, agent_id: str) -> None: res = self.reservations[agent_id] # Deposit call-token: reservation is now held-in-flight, non-reclaimable. res.call_token = f"{agent_id}:call" def tool_result(self, agent_id: str) -> None: res = self.reservations[agent_id] res.call_token = None # Clear: back to reclaimable. def reclaim(self, agent_id: str, need: int) -> int: res = self.reservations[agent_id] # INVARIANT: never reclaim a reservation with a live call-token. if res.call_token is not None: raise SharedSubstrateLeaseError( f"refusing to reclaim {need} from {agent_id}: " f"tool call {res.call_token} in flight (held-in-flight, not held-idle)" ) take = min(need, res.size) res.size -= take return take def write_result(self, agent_id: str, payload: int) -> None: res = self.reservations[agent_id] if res.revoked or payload > res.size: raise SharedSubstrateLeaseError( f"agent {agent_id} writing {payload} into slot of size {res.size}: " f"stale reservation — result has no exclusive landing region" ) # write lands in res.region() exclusively ```