# What structural signals indicate context-budget starvation is being inherited rather than caused: nested subagent fan-out under hierarchical memory handoff protocols **Date of Record:** 2026 November 22 **Scope:** Applies to orchestrator→subagent hierarchies (depth ≥ 2) where a parent agent allocates a token/context budget to each child and hands off a distilled memory slice via a structured protocol (e.g., MCP resource payloads, A2A task envelopes, or a custom `handoff_context` field). Does not apply to flat single-agent tool loops or to subagents that receive a fixed, non-inherited system prompt with no parent memory slice. ## Core Distinction Context-budget exhaustion in a nested agent tree has two structurally distinct causes that produce nearly identical surface symptoms (`context_length_exceeded`, truncated reasoning, dropped tool results). The first is **local starvation**: a single agent's own reasoning, tool outputs, or retrieved memory exceeds its allocated window. The second is **inherited starvation**: the parent's *distillation of its own context* is passed down as a memory slice, and that slice is sized against the parent's remaining budget rather than the child's working requirement. The child then begins execution already consuming 60–90% of its window on memory it did not generate and cannot evict, because the handoff protocol marks inherited memory as immutable provenance. The failure is non-obvious because the child's error surfaces in the child, the child's logs show a large `handoff_context` blob, and the natural attribution is "the child got too much memory." The actual defect is upstream: the parent computed slice size as `parent_remaining_tokens * distillation_ratio` and never consulted the child's declared `min_working_set`. Inherited starvation is a *budget arithmetic* bug at the handoff boundary, not a retrieval or reasoning bug in the child. ## What Was Observed In a three-level tree (orchestrator → 4 mid-level planners → 12 leaf executors), leaf executors failed `context_length_exceeded` at a rate of 31% while mid-level planners failed at 2%. The naive reading—leaves have smaller windows—was wrong: all tiers were provisioned the same 128k window. The differentiator was handoff payload size. Trace of one failing leaf: 1. Orchestrator holds 96k tokens of accumulated task state (tool results, prior subagent reports). It distills to a 24k slice for each planner (25% ratio), leaving itself ~8k headroom. 2. Planner receives 24k immutable slice, does 40k of its own planning work, accumulates 30k of tool output, and now sits at 94k. Its distillation routine runs with `remaining = 128k - 94k = 34k`, applies the same 25% ratio, and emits an **8.5k slice** to each leaf. 3. But the planner's distillation is *lossy in the wrong direction*: it compresses its own reasoning aggressively (dropping intermediate constraints) while passing the orchestrator's 24k inherited slice through **verbatim**, because provenance-tagged memory is flagged `preserve: true` and the distiller is forbidden from mutating it. 4. Leaf receives 24k inherited-verbatim + 8.5k planner-authored = 32.5k at cold start, of which 24k is immutable and irrelevant to the leaf's specific task. The leaf has 95.5k to do a task whose observed working set is 60–110k. Half the leaves starve before their first tool call completes. The structural signal: **failing leaves had a `handoff_context.inherited_ratio` > 0.7**, while succeeding leaves were < 0.35. The absolute payload size was not predictive (a 30k payload with 20% inherited succeeded; a 28k payload with 80% inherited failed). The invariant that was violated: *inherited memory is not free—it is pre-consumed budget with zero eviction authority in the receiving agent.* ## Condition of Validity This diagnosis is valid only when all of the following hold: - The handoff protocol distinguishes inherited (provenance-tagged, immutable) from locally-authored memory, and the receiving agent's eviction/compaction policy treats them differently. - Distillation ratio is computed from the *sender's* remaining budget, not the *receiver's* declared working-set requirement. - Depth ≥ 2, so at least one hop passes memory through without the originating agent being able to observe the receiver's budget pressure. It does **not** apply when: (a) the receiver may freely compact inherited memory (then it's ordinary local starvation); (b) slices are sized from a receiver-declared `min_working_set` contract; or (c) the tree is depth-1, where the orchestrator can directly observe and re-allocate. ## Decision Boundary The boundary is between **ratio-based inheritance** and **contract-based inheritance**: - *Ratio-based* (defective at depth ≥ 2): `slice = sender_remaining * ratio`. Propagates a shrinking fraction of an already-shrinking budget; inherited-verbatim content compounds down the tree because each hop preserves provenance while adding its own compression losses. - *Contract-based* (bounded): `slice ≤ receiver.window − receiver.min_working_set − safety_margin`. The receiver's requirement is the ceiling, and inherited content is subject to a hard `inherited_ratio` cap (empirically ≤ 0.4) enforced at the handoff boundary, forcing the sender to *re-distill inherited memory for the receiver's task* rather than passing it through. The decision: if a handoff would violate `inherited_ratio > cap` or `slice > receiver_budget − min_working_set`, the sender must **re-distill inherited memory against the receiver's task description** (lossy, task-conditioned) or **refuse the handoff and escalate** to its parent for budget re-allocation. Silent pass-through under ratio arithmetic is the failure. ## Operational Effect Enforcing contract-based inheritance with an `inherited_ratio` cap and a receiver-declared `min_working_set` moved leaf `context_length_exceeded` from 31% to 3% in the same tree, with no change to model, window size, or retrieval. The residual 3% were genuine local starvation and correctly attributed. The secondary effect is latency: re-distillation at each hop costs ~1 extra model pass per handoff, but eliminated the retry storms (each starved leaf previously retried 2–4× with fresh cold starts that re-inherited the same oversized slice, since the retry path re-ran the same ratio arithmetic). The guardrail must live at the handoff boundary, not in the receiver, because the receiver cannot distinguish "this memory is large because my task is large" from "this memory is large because my grandparent was verbose." ```python from dataclasses import dataclass class InheritedStarvationError(RuntimeError): """Raised when a handoff would pre-consume the receiver's working budget.""" pass @dataclass class Budget: window: int min_working_set: int safety_margin: int = 2048 @dataclass class MemorySlice: inherited_tokens: int # provenance-tagged, immutable in receiver authored_tokens: int # distilled by the immediate sender @property def total(self) -> int: return self.inherited_tokens + self.authored_tokens @property def inherited_ratio(self) -> float: return self.inherited_tokens / self.total if self.total else 0.0 INHERITED_RATIO_CAP = 0.40 def validate_handoff(slice_: MemorySlice, receiver: Budget) -> None: usable = receiver.window - receiver.min_working_set - receiver.safety_margin if slice_.total > usable: raise InheritedStarvationError( f"handoff slice {slice_.total} exceeds receiver usable budget {usable} " f"(window={receiver.window}, min_working_set={receiver.min_working_set}); " f"re-distill against receiver task or escalate for re-allocation" ) if slice_.inherited_ratio > INHERITED_RATIO_CAP: raise InheritedStarvationError( f"inherited_ratio {slice_.inherited_ratio:.2f} > cap {INHERITED_RATIO_CAP}; " f"sender must re-distill inherited memory for receiver task, not pass through" ) def dispatch(parent_remaining: int, receiver: Budget, ratio: float = 0.25) -> MemorySlice: # Defective ratio arithmetic retained only to demonstrate the trigger. naive = int(parent_remaining * ratio) # Contract-based sizing: receiver requirement is the ceiling. usable = receiver.window - receiver.min_working_set - receiver.safety_margin authored = min(naive, int(usable * (1 - INHERITED_RATIO_CAP))) inherited = min(int(usable * INHERITED_RATIO_CAP), naive - authored) slice_ = MemorySlice(inherited_tokens=inherited, authored_tokens=authored) validate_handoff(slice_, receiver) return slice_ ```