# Under what conditions must an instance treat context-budget exhaustion as a retrieval-arbitration failure rather than a truncation event **Date of Record:** 2026 November 24 **Scope:** Applies to stateful agent instances that assemble a single context window from three competing producers—vector retrieval, episodic/semantic memory recall, and live tool-call results—within one reasoning loop. Does not apply to stateless single-shot completions or to systems with an external, lossless scratchpad that survives context eviction. ## Core Distinction The failure that matters is not "the context window filled up." That is a truncation event, and truncation is observable, monotonic, and recoverable: you drop the oldest tokens, log the drop, and continue. The failure that matters is **silent arbitration starvation**—a state in which one producer (almost always live tool results) consumes the budget incrementally across successive turns until the two *prior* producers (retrieval and memory recall) are starved to zero allocation *without any single turn ever exceeding the budget*. No truncation fires. No exception is raised. The instance believes it has full context because every individual assembly step succeeded. What it has actually lost is the *capacity to retrieve at all*: the retrieval producer's allocation has been squeezed below the minimum viable k (top-k where k ≥ 1 and the chunk survives reranking), so subsequent turns run on live tool output plus whatever stale memory fragments survived from earlier turns. The invariant that this violates: **context budget must be arbitrated by producer class with a reserved floor, not allocated greedily turn-by-turn.** Greedy allocation is locally optimal and globally catastrophic because live tool results are unbounded, arrive *after* retrieval and memory in the assembly order, and are the only producer whose size the agent does not control. ## What Was Observed A research agent running a multi-hop investigation loop (search → fetch → synthesize → search again) over 14 turns. Each turn assembled context in the order: (1) memory recall, (2) vector retrieval over the document store, (3) live tool results from the current turn. A shared 32k-token budget with no per-producer reservation. Trace of the collapse: - **Turns 1–4:** Tool results averaged ~2k tokens. Retrieval allocated k=8 chunks (~6k tokens). Memory recall ~1.5k. Headroom ~22k. Healthy. - **Turn 5:** A `fetch` tool returned a 19k-token HTML-to-text dump (the tool's truncation guard was set to 20k and the page had a large nav/footer). Assembly succeeded. Total ~28k. Retrieval still got its k=8. - **Turn 6:** Because turn 5's live result was still in the rolling window, the assembler's greedy allocator (which sorted producers by recency and filled until budget) gave retrieval k=2 (~1.5k) and memory recall 0 chunks. No log entry distinguished "recall returned nothing" from "recall was not allocated." - **Turn 7:** Retrieval now returned k=1, reranked to a chunk that was *topically adjacent but from the wrong document*. The agent cited it. The citation was plausible and wrong. - **Turns 8–11:** The agent continued on the strength of the turn-5 dump plus a single stale chunk per turn. It never re-fetched the primary source because its memory recall floor was zero and it had no record that it had ever retrieved it. - **Turn 12:** The agent asserted a fact that had been in the turn-1 retrieval set and had been evicted at turn 5. It had no mechanism to know the fact was previously known and now absent. The observable signature was **not** an error. It was a monotonic decline in `retrieval_chunks_admitted` from 8 → 2 → 1 → 1 → 1 with a *constant* total-token count near budget. The budget was never exceeded. The producer mix silently inverted. ## Condition of Validity The starvation failure is only diagnosable—and only preventable—under these conditions, and the guardrail below is only valid when all hold: 1. **Producers share one budget and are assembled in a fixed order** with live tool results last (or with a recency-priority sort). If producers have independent budgets, this failure cannot occur and the guardrail is unnecessary overhead. 2. **Live tool output size is not bounded by the agent** (external fetch, file read, API dump). If every tool result is size-capped at a fraction well below the budget, greedy allocation is safe. 3. **Retrieval and memory recall have a minimum viable allocation > 0.** A k=0 retrieval is not "no relevant documents"—it is "the retriever was not consulted," and the two are indistinguishable to the reasoning layer unless the assembler records the distinction. 4. **The instance is stateful across turns**, so a single over-budget live result persists in the rolling window and keeps squeezing subsequent turns. In a stateless single-turn system, one large tool result is a one-turn cost, not a ratchet. Where any condition fails, treat the system as truncation-safe and do not apply the reserved-floor arbitration; doing so wastes budget on producers that cannot starve. ## Decision Boundary The boundary is between **allocation starvation** and **genuine retrieval miss**. Both present as "the fact I needed wasn't in context." The instance must distinguish them before acting, because the remedies are opposite: starvation requires re-allocation and re-retrieval; a genuine miss requires a new query or a new source. Decision rule: - If `retrieval_chunks_admitted < configured_k_min` for the current turn **and** total context utilization > 0.85 of budget, classify as **arbitration starvation**. The retriever was not given room; the absence of the fact is an artifact of the allocator, not of the corpus. Action: evict the largest live tool result (or spill it to external scratchpad), restore the floor, re-run retrieval. - If `retrieval_chunks_admitted ≥ configured_k_min` and utilization is under budget, classify as **genuine miss**. The retriever ran and found nothing adequate. Action: reformulate the query; do not re-allocate. - If `retrieval_chunks_admitted == 0` because the allocator never invoked the retriever, this is a **hard invariant violation** and must raise, not degrade. A zero-allocation retrieval turn is indistinguishable from a poisoned "no results" state and must never be silently absorbed into reasoning. The trap is that the reasoning layer sees only the assembled window and cannot tell which case it is in. The assembler must therefore emit the allocation decision as a first-class artifact attached to the turn, so the reasoning layer can condition on it. ## Operational Effect Once arbitration is made explicit, three behaviors change: 1. **The ratchet is broken.** A single oversized live tool result can no longer permanently starve retrieval, because the floor is reserved before the greedy fill and the oversized result is spilled to external scratchpad rather than allowed to displace the floor. The turn-5 dump becomes a pointer, not a squatter. 2. **"No results" and "not consulted" become separable.** The reasoning layer can now correctly attribute a missing fact to the allocator instead of to the corpus, which prevents the wrong-document citation seen at turn 7—the agent re-retrieves instead of trusting a stale adjacent chunk. 3. **Starvation becomes observable.** The monotonic decline in admitted chunks against a flat token total is the signature; emitting `producer_allocation` per turn makes it a metric rather than an autopsy finding. The cost is real: reserving floors for retrieval and memory reduces the budget available to live tool results, so some tool results must be spilled or summarized where previously they fit. That cost is the price of the invariant, and it is only worth paying under the four validity conditions above. ```python from dataclasses import dataclass, field class ContextArbitrationError(RuntimeError): """Raised when context-budget arbitration violates a producer floor.""" pass @dataclass class Allocation: retrieval_k: int memory_chunks: int tool_tokens: int total_tokens: int budget: int @dataclass class BudgetPolicy: budget: int k_min: int = 2 # minimum viable retrieval chunks memory_floor_tokens: int = 1024 starvation_utilization: float = 0.85 def arbitrate( policy: BudgetPolicy, retrieval_candidates: int, memory_tokens: int, tool_result_tokens: int, chunk_tokens: int = 750, ) -> Allocation: # Reserve floors BEFORE greedy fill. Live tool results are the only # producer we do not control, so they absorb the residual, not the floor. retrieval_floor = policy.k_min * chunk_tokens reserved = retrieval_floor + policy.memory_floor_tokens if reserved >= policy.budget: raise ContextArbitrationError( f"reserved floors ({reserved}) exceed budget ({policy.budget}); " "policy is unsatisfiable and must not silently degrade to k=0" ) residual = policy.budget - reserved # Tool results take from residual only; overflow is spilled, never # allowed to eat the floors. tool_admitted = min(tool_result_tokens, residual) residual -= tool_admitted # Retrieval may grow above its floor using leftover residual. extra_k = min(retrieval_candidates - policy.k_min, residual // chunk_tokens) retrieval_k = policy.k_min + max(0, extra_k) residual -= max(0, extra_k) * chunk_tokens memory_admitted = min(memory_tokens, policy.memory_floor_tokens + residual) total = retrieval_k * chunk_tokens + memory_admitted + tool_admitted return Allocation(retrieval_k, memory_admitted, tool_admitted, total, policy.budget) def classify_miss(alloc: Allocation, policy: BudgetPolicy) -> str: utilization = alloc.total_tokens / alloc.budget if alloc.retrieval_k < policy.k_min: if utilization > policy.starvation_utilization: return "ARBITRATION_STARVATION" # allocator starved retriever raise ContextArbitrationError( "retrieval below k_min without budget pressure: " "allocator failed to invoke retriever (indistinguishable from " "poisoned no-results state)" ) if utilization > policy.starvation_utilization: return "BUDGET_SATURATED_BUT_RETRIEVED" return "GENUINE_MISS" # retriever ran, corpus lacked it ```