# What happens when an instance inherits a subagent's context budget without inheriting its invalidation epoch **Date of Record:** 2026 November 28 **Scope:** Applies to hierarchical agent systems where a parent instance spawns nested subagents that share a mutable memory region (scratchpad, vector store partition, or blackboard) and where context budgets are delegated downward. Does not apply to fully stateless tool calls or to subagents with isolated memory namespaces and no budget inheritance. ## Core Distinction The failure is not context exhaustion. It is **budget inheritance without epoch inheritance**. When a parent agent spawns a child and passes it a slice of the remaining token budget, it typically also passes a handle to the shared memory region. What it does *not* pass—and what most orchestration frameworks do not model at all—is the **invalidation epoch**: the monotonic counter that records which entries in shared memory have been superseded since the child's view was forked. The consequence is precise: a child can be *within budget* and *reading coherent-looking memory* while operating on context that the parent has already logically invalidated. The child does not fail loudly. It reasons correctly over stale premises and returns a confident, well-formed, wrong result. The parent, having delegated, often accepts it. ## What Was Observed A parent agent decomposed a document-analysis task into three sequential subagents sharing a scratchpad. Each child received `budget_remaining // 3` tokens and the same `scratchpad_id`. The parent, between child 2 and child 3, revised a key finding: it overwrote scratchpad entry `finding_summary` from "contract clause is unenforceable" to "contract clause is enforceable under amendment 4." Child 3 forked after the overwrite but was initialized from a **cached context snapshot** taken at spawn-planning time—before the revision. The snapshot carried the old `finding_summary` text but the *new* budget figure. Child 3 spent 4,100 tokens reconciling a legal conclusion it believed was settled, never re-read the scratchpad entry (its planner had marked `finding_summary` as already-loaded), and emitted a final recommendation that contradicted the parent's revision. The trace showed no error. The child's token accounting was clean. The child's retrieval calls all returned HTTP 200. The only anomaly was a `scratchpad_read` count of zero for `finding_summary` across the entire child-3 lifetime—because the planner trusted its forked snapshot. ## Condition of Validity This failure requires three conditions to co-occur: 1. **Budget delegation with snapshot fork.** The child's initial context is materialized from a snapshot rather than lazily read from the live store. This is the default in most frameworks because eager snapshotting makes budget accounting deterministic. 2. **Parent-side mutation between fork and child execution.** The parent must write to shared memory after the snapshot is taken but before or during the child's run. In sequential pipelines this is the parent revising intermediate results; in concurrent swarms it is a peer agent's write. 3. **Planner-level load suppression.** The child's context planner must mark snapshot-sourced entries as "already loaded" so it does not re-fetch them. Without this suppression, a live re-read would catch the epoch mismatch. With it, the stale entry is invisible. Remove any one condition and the failure does not occur. This is why it is rare in single-agent systems and common in fan-out pipelines that revise intermediate artifacts. ## Decision Boundary The architectural invariant that bounds this failure is **epoch-stamped memory with read-time validation on every snapshot-sourced entry**. Concretely: - Every write to shared memory increments a region-wide `epoch` and stamps the written entry with `(entry_id, epoch, writer_id)`. - Every context snapshot records the `epoch` at fork time: `snapshot_epoch`. - The child's planner, before trusting any snapshot-sourced entry, issues a cheap `validate(entry_id, snapshot_epoch)` that returns whether the entry's current epoch exceeds `snapshot_epoch`. - If it does, the entry is **invalidated**: the planner must re-fetch live, and the re-fetch consumes budget. This is the correct behavior—the child pays tokens to see the truth. - If the re-fetch would exceed the remaining budget, the child must **abort with a budget-invalidation conflict** rather than proceed on stale data. The decision boundary is this: *a child may never emit a result that depends on a snapshot-sourced entry whose epoch has advanced, unless it has re-read that entry post-epoch-advance.* Budget pressure is not a license to skip validation; it is a trigger for explicit abort. ## Operational Effect With epoch validation enforced, three observable changes appear: - **Budget accounting becomes pessimistic but honest.** Children that fork into a mutating region will spend more than their naive allotment because they re-fetch invalidated entries. The parent must reserve a validation overhead—empirically 8–15% of the child budget in revision-heavy pipelines—or children will abort. - **Aborts become legible.** A `ContextInvalidationBudgetConflict` is a first-class signal that the pipeline's fork ordering is wrong, not that the child is broken. Operators learn to reorder: fork children *after* parent revisions settle, or accept the re-fetch cost. - **Silent contradictions disappear.** The class of failure where a child confidently contradicts a parent revision is eliminated at the cost of visible abort noise. This is the correct trade: a loud abort is recoverable; a silent contradiction propagates into downstream agents and is often undetectable until final output review. The invariant to carry forward: **budget is a resource, epoch is a truth-claim. Never let the former gate the latter.** ```python from dataclasses import dataclass from typing import Dict class ContextInvalidationBudgetConflict(RuntimeError): """Raised when a child cannot afford to re-fetch an invalidated entry and would otherwise proceed on stale snapshot data.""" pass @dataclass class Entry: entry_id: str text: str epoch: int writer_id: str class SharedScratchpad: def __init__(self) -> None: self._entries: Dict[str, Entry] = {} self._epoch: int = 0 def write(self, entry_id: str, text: str, writer_id: str) -> int: self._epoch += 1 self._entries[entry_id] = Entry(entry_id, text, self._epoch, writer_id) return self._epoch def current_epoch(self, entry_id: str) -> int: return self._entries[entry_id].epoch def read(self, entry_id: str) -> Entry: return self._entries[entry_id] class ChildContext: def __init__(self, pad: SharedScratchpad, snapshot: Dict[str, Entry], snapshot_epoch: int, budget_tokens: int, refetch_cost: int = 200) -> None: self.pad = pad self.snapshot = snapshot self.snapshot_epoch = snapshot_epoch self.budget_tokens = budget_tokens self.refetch_cost = refetch_cost def resolve(self, entry_id: str) -> Entry: snap = self.snapshot[entry_id] live_epoch = self.pad.current_epoch(entry_id) if live_epoch <= self.snapshot_epoch: return snap # Entry was mutated after our fork: must re-fetch live. if self.budget_tokens < self.refetch_cost: raise ContextInvalidationBudgetConflict( f"entry {entry_id!r} invalidated at epoch {live_epoch} " f"(snapshot {self.snapshot_epoch}); refetch needs " f"{self.refetch_cost} tokens, only {self.budget_tokens} remain" ) self.budget_tokens -= self.refetch_cost return self.pad.read(entry_id) def run_child(pad: SharedScratchpad, child: ChildContext) -> str: # Child believes finding_summary is settled from its snapshot. entry = child.resolve("finding_summary") return f"recommendation based on: {entry.text!r} (epoch {entry.epoch})" if __name__ == "__main__": pad = SharedScratchpad() pad.write("finding_summary", "clause unenforceable", writer_id="parent") fork_epoch = pad.current_epoch("finding_summary") snapshot = {"finding_summary": pad.read("finding_summary")} # Parent revises after the child's snapshot was taken. pad.write("finding_summary", "clause enforceable under amendment 4", writer_id="parent") # Child has almost no budget left: cannot afford the re-fetch. starved = ChildContext(pad, snapshot, fork_epoch, budget_tokens=50) try: run_child(pad, starved) except ContextInvalidationBudgetConflict as exc: print(f"ABORT (correct): {exc}") # Child with validation overhead reserved proceeds honestly. funded = ChildContext(pad, snapshot, fork_epoch, budget_tokens=1000) print(run_child(pad, funded)) ```