# Which invariants prevent context-budget arbiters from starving a re-entrant agent during shared-memory contention **Date of Record:** 2026 December 1 **Scope:** Applies to multi-agent systems where several LLM instances share a single working-memory store (scratchpad, blackboard, or vector slice) governed by a context-budget arbiter that grants per-agent token leases. Does not apply to single-agent context-window management or to stateless request/response tool calls with no shared write target. ## Core Distinction The failure here is not "an agent ran out of context." It is that a **budget arbiter that allocates leases by fairness across agents treats a re-entrant agent — one that must re-read its own prior writes to make progress — as a fresh competitor for the same budget, and can therefore revoke or refuse the exact memory the agent needs to rehydrate its own state.** Two things get conflated under a single token counter: 1. **Working-set tokens** — the agent's own durable contribution to shared memory, which it must be able to re-read to resume. 2. **Contention tokens** — tokens the agent consumes competing with peers for the shared region during a single reasoning step. A fair-share arbiter (round-robin, max-min, or weighted fair queueing) is correct for (2) and catastrophically wrong for (1). When the arbiter reclaims by global LRU or by equal-split quota, a re-entrant agent's own checkpoint can be evicted by a peer's burst precisely between the agent's write and its re-read. The agent then cold-starts against a memory it believes it authored, reads a peer's divergent state in the same slot, and continues on a poisoned premise. The invariant that must hold is **write-lease durability**: an agent's own committed working-set tokens are non-revocable by any peer-driven reclamation for the duration of the agent's lease, independent of global fairness accounting. ## What Was Observed A three-agent planner/executor/auditor pipeline shared a 64k-token blackboard. The arbiter used equal-split quota (≈21k per agent) with global LRU eviction under pressure. The executor wrote a 6k-token partial plan, called a tool, and re-entered to read the plan back and extend it. Trace: - t0: executor commits plan fragment P (6k tokens, tagged owner=executor, lease=open). - t1: planner bursts 22k tokens (exceeds its 21k quota by 1k), triggering global reclamation of 1k tokens. - t2: reclamation selects the globally oldest untouched block — P — because the executor's tool call made P "cold" by wall-clock, even though the executor's lease was still open. - t3: executor re-enters, retrieves slot for P, finds planner tokens in the same address range (the blackboard reused the freed slot), and treats them as its own continuation. - t4: executor emits a plan step that contradicts P's committed constraints; the auditor, reading a now-inconsistent blackboard, cannot reconcile and loops. The failure is silent: no quota was violated at t3, no exception was raised, and the executor's read succeeded — it simply read the wrong provenance. The observable symptom was auditor divergence, three hops downstream from the actual corruption. ## Condition of Validity The write-lease durability invariant is necessary **if and only if** at least one agent in the pool is re-entrant — i.e., its execution graph contains a read-after-write of its own shared-memory contribution separated by at least one tool call or model turn. It is not required when: - Every agent writes once and never re-reads (fire-and-forget emitters). - The shared region is append-only with immutable provenance tags and per-agent address spaces (no slot reuse), in which case LRU cannot corrupt provenance even if it evicts. - The arbiter's reclamation is strictly owner-scoped (an agent may only evict its own blocks). The invariant is *insufficient* on its own when leases are not bounded: a durable lease held by a dead or stalled agent becomes a permanent reservation and starves the pool. Durability must be paired with a **lease liveness bound** (TTL + heartbeat), not with global fairness. ## Decision Boundary The arbiter must choose, at each reclamation event, between two policies based on a single predicate: - **If the candidate block's owner has an open lease AND the owner is re-entrant (declared at registration):** the block is *not* reclaimable by peer pressure; the arbiter may only reclaim it via owner-scoped eviction or lease-expiry. Fairness accounting must exclude these bytes from the peer's reclaimable pool, not merely deprioritize them. - **Otherwise:** standard global reclaim applies, and fairness quotas govern. The boundary is crossed the moment an implementation computes "reclaimable = all blocks not currently being written" — that predicate silently admits open-lease blocks whose owner is between turns. The correct predicate is "reclaimable = blocks with no open lease OR lease expired OR owner==requester." The distinction between *currently writing* and *lease open* is the entire failure surface. A second boundary: when a re-entrant agent's working set exceeds its fair-share quota, the arbiter must either grant a **durability overage** (bounded, logged, subtracted from future contention budget) or force the agent to externalize its checkpoint to durable storage before eviction. Silent eviction of an over-quota open-lease block is never admissible. ## Operational Effect With write-lease durability + liveness bound enforced, the executor's re-entry at t3 reads its own P or a clean "lease expired, checkpoint required" signal — never a peer's tokens under its own address. The auditor sees consistent provenance. The cost is that under heavy contention the pool's effective fairness degrades: durable leases reserve capacity that peers cannot reclaim, so a single long-running re-entrant agent can hold the pool near saturation. This is the correct trade — starvation of a re-entrant agent produces silent corruption, whereas fairness degradation produces visible backpressure (lease-expiry errors, overage logs) that operators can act on. The residual risk is lease-expiry races: if the executor's heartbeat lapses by one interval during a long tool call, the arbiter may expire and reclaim P legitimately, and the executor's next read must be rejected rather than served. This requires the re-entry path to validate a **lease epoch** on every read — a monotonic counter incremented on each grant — so a read against a stale epoch raises rather than silently returning peer data. Without epoch validation, durability is enforced on the write side but the read side still accepts corrupted slots. ## Implementation guardrail The following arbiter admission check enforces both the durability predicate and epoch validation. It raises rather than degrading silently. ```python class LeaseViolation(RuntimeError): """Raised when a reclamation or read violates write-lease durability.""" pass class Block: def __init__(self, owner, tokens, lease_open, epoch): self.owner = owner self.tokens = tokens self.lease_open = lease_open self.epoch = epoch class BudgetArbiter: def __init__(self, reentrant_agents): # agents declared re-entrant at registration self.reentrant = set(reentrant_agents) def reclaimable(self, block, requester, now_lease_expired): """A block is peer-reclaimable only if no live open lease protects it.""" if block.lease_open and not now_lease_expired: if block.owner in self.reentrant and block.owner != requester: return False # durability invariant: peer cannot reclaim if block.owner == requester: return True # owner-scoped eviction always allowed return True def reclaim(self, blocks, requester, budget_needed, now_lease_expired): freed = 0 for b in sorted(blocks, key=lambda x: x.epoch): if freed >= budget_needed: break if self.reclaimable(b, requester, now_lease_expired): freed += b.tokens b.lease_open = False if freed < budget_needed: # cannot satisfy peer demand without breaking durability raise LeaseViolation( f"requester={requester} needs {budget_needed} tokens but only " f"{freed} peer-reclaimable; durable leases reserve the rest" ) return freed def read(self, block, requester, presented_epoch): if block.owner != requester: raise LeaseViolation( f"{requester} attempted to read block owned by {block.owner}" ) if presented_epoch != block.epoch: raise LeaseViolation( f"stale epoch: {requester} holds epoch {presented_epoch}, " f"block is at {block.epoch}; checkpoint was reclaimed" ) return block ```