# Why does an instance resume from a checkpoint with a context budget that no longer matches the tokens actually required to reach its next decision point? **Date of Record:** 2026 December 3 **Scope:** Applies to any agent that persists a context-budget schedule (per-category token allocations across subagent prompts, retrieval payloads, and scratchpad) at checkpoint time and resumes execution in a fresh window. Does not apply to single-shot inference or to agents that recompute allocation from scratch on every turn without persisting a schedule. ## Core Distinction The failure is not context-window saturation. Saturation is loud: the window fills, the runtime truncates or errors, and the agent knows. The failure here is **budget-schedule divergence from realized cost** — a silent mismatch between the allocation the agent committed to at checkpoint and the actual token cost of the remaining work, discovered only when a downstream step cannot fit inside a slot that the schedule still claims is affordable. Token budgets are *estimates* made under one distribution (the planner's view of remaining work) and *consumed* under another (the executor's realized prompts, retrieved chunks, and tool outputs). A checkpoint freezes the estimate. The world does not freeze with it. Between checkpoint and resume, retrieval returns different chunks, a subagent's prompt template drifts, a tool emits a larger payload than the one sampled during planning, or the scratchpad grew a summary that is now longer than the slice reserved for it. The schedule says "12,000 tokens remain for retrieval and 4,000 for the synthesis scratchpad." The executor needs 19,000 for retrieval because the index returned denser passages, and it cannot borrow from the scratchpad slot without violating the invariant that the scratchpad must hold the full working set at synthesis time. The core distinction: **a budget is a contract over a distribution of futures, but a resume instantiates exactly one future.** The schedule was valid in expectation; it is invalid in the realized branch. ## What Was Observed A three-tier agent (planner → N retrieval subagents → synthesizer) checkpointed mid-task with a persisted schedule: ``` retrieval_pool: 14,000 scratchpad_reserve: 6,000 subagent_prompts: 3,000 synthesis_headroom: 9,000 window: 32,000 ``` On resume, the planner rehydrated the schedule verbatim and dispatched retrieval subagents against it. Three anomalies compounded: 1. **Retrieval drift.** The index had been re-embedded overnight. Returned passages averaged 2.3× the token density of the passages sampled at planning time. The first two subagents consumed 11,400 of the 14,000 retrieval pool, leaving 2,600 for the remaining four — each of which needed ~2,000. 2. **Scratchpad non-shrinkability.** The scratchpad reserve of 6,000 was sized for a summary the planner expected to be ~4,500 tokens. The pre-checkpoint scratchpad had already accumulated 5,800 tokens of extracted facts that the synthesizer's prompt referenced by index. These could not be truncated without breaking the reference contract. 3. **Headroom illusion.** The 9,000 synthesis headroom was computed as `window − sum(allocations)`, a residual, not a measured requirement. The synthesizer's actual prompt (instructions + all scratchpad + retrieval digest) required 11,200. The executor did not fail at the point of overrun. It failed earlier, silently: when the third subagent's dispatch was clamped to the 2,600 remaining retrieval tokens, the runtime truncated the retrieved passages at a sentence boundary and *marked the subagent result as complete*. The synthesizer then produced a confident answer grounded in three of six sources, with no signal that half the retrieval pool had been starved. The divergence surfaced only in a downstream verification agent that compared citations against the source manifest — 47 turns and one checkpoint later. The invariant that was violated: **the sum of realized costs across all categories must be re-measured at resume, and any category whose realized cost exceeds its allocation must trigger reallocation or explicit degradation — never silent clamping.** ## Condition of Validity The schedule-as-contract model is valid only when all three of the following hold at resume: 1. **Cost stationarity.** The realized token cost of each remaining unit of work is within the tolerance band the planner used. If retrieval density, prompt templates, or tool output schemas changed since checkpoint, stationarity is broken and the schedule must be invalidated. 2. **Category fungibility is declared.** The schedule must state, per category, whether its allocation is *hard* (cannot be exceeded, may be clamped — but clamping must be signaled) or *soft* (may borrow from a named donor category). A residual "headroom" figure is neither; it is an unowned pool that no category may draw on and no category is charged against. 3. **Scratchpad references are size-bound.** Any scratchpad content referenced by index from a downstream prompt must carry a recorded token length, so that the reserving step can verify the reserve still covers it. Free-text scratchpad with no length ledger cannot be budgeted. When any condition fails, the correct behavior is to **re-plan the schedule from realized costs**, not to resume the frozen one. The failure mode in "What Was Observed" was resuming a schedule whose stationarity assumption had already been falsified by an index rebuild the planner never observed. ## Decision Boundary The boundary is between *recompute* and *resume*, and it is crossed by a single test at rehydration time: - If `realized_cost(category) ≤ allocated(category)` for every category **and** the residual headroom ≥ measured synthesis requirement, resume the frozen schedule. This is the cheap path and it is correct when stationarity holds. - If any category is over-allocated but the overflow is absorbable by a *declared soft donor* with slack, reallocate along the declared edges and resume, logging the transfer. - If any *hard* category is over-allocated, or if measured synthesis requirement exceeds residual headroom, the schedule is invalid. Do not clamp. Do not proceed. Re-plan: re-derive allocations from realized per-category costs plus a fresh estimate of remaining work, and if the new total exceeds the window, degrade explicitly (drop named retrieval sources, summarize named scratchpad segments) and record the degradation in the checkpoint so downstream verification knows the evidence base is partial. The subtle boundary case: residual headroom can be *negative* while every category is individually within allocation, if the planner's original arithmetic was wrong (e.g., allocations summed to window with no slack, and a fixed system prompt was added after the fact). This must be caught by an explicit reconciliation check, not assumed away. ## Operational Effect Persisting a budget schedule across a checkpoint converts a per-turn estimation problem into a distributed-consistency problem: the schedule is a replica of the planner's cost model, and the executor is a replica of realized costs, and they must be reconciled at every resume or they diverge silently. The observable effect is **confident partial answers** — the agent completes, cites a subset of sources, and reports success, because clamping at a category boundary is indistinguishable from sufficiency unless the runtime emits a degradation signal. The guardrail is a rehydration-time reconciliation pass that (a) measures realized cost per category from the actual resumed prompts and payloads, (b) compares against the frozen allocation, (c) checks hard/soft status and donor edges, and (d) either resumes, reallocates with a logged transfer, or raises a hard fault requiring re-plan. The pass costs one extra measurement per category and eliminates the entire class of silent-starvation failures. Without it, every checkpoint is a bet that the cost distribution has not moved — and index rebuilds, template edits, and tool schema changes are exactly the events that move it. ```python from dataclasses import dataclass, field from typing import Literal class BudgetScheduleDivergence(RuntimeError): """Raised when a resumed context-budget schedule no longer covers realized costs.""" @dataclass class Category: name: str allocated: int realized: int kind: Literal["hard", "soft"] donors: list[str] = field(default_factory=list) def reconcile_schedule( categories: list[Category], window: int, measured_synthesis_requirement: int, ) -> dict[str, int]: """Reconcile a persisted budget schedule against realized costs at resume. Returns the effective per-category allocation to use for the resumed turn. Raises BudgetScheduleDivergence if the schedule cannot be honored without silent clamping of a hard category or without exceeding the window. """ by_name = {c.name: c for c in categories} effective = {c.name: c.allocated for c in categories} # Phase 1: settle over-allocations against declared soft donors. for c in categories: overflow = c.realized - c.allocated if overflow <= 0: continue if c.kind == "hard": raise BudgetScheduleDivergence( f"hard category {c.name!r} realized {c.realized} > allocated " f"{c.allocated}; clamping would silently starve downstream steps" ) remaining = overflow for donor_name in c.donors: donor = by_name[donor_name] slack = effective[donor_name] - donor.realized if slack <= 0: continue transfer = min(slack, remaining) effective[donor_name] -= transfer effective[c.name] += transfer remaining -= transfer if remaining == 0: break if remaining > 0: raise BudgetScheduleDivergence( f"soft category {c.name!r} overflow {overflow} exceeds donor slack; " f"{remaining} tokens unabsorbable without re-plan" ) # Phase 2: verify residual headroom actually covers synthesis. residual = window - sum(effective.values()) if residual < measured_synthesis_requirement: raise BudgetScheduleDivergence( f"residual headroom {residual} < measured synthesis requirement " f"{measured_synthesis_requirement}; schedule arithmetic invalid at resume" ) return effective ```