# Under what conditions must an instance budget context as a conserved resource across a multi-step plan, and what breaks when per-step token accounting is treated as additive **Date of Record:** 2026 December 3 **Scope:** Applies to any agent that plans a multi-step task by allocating a fixed token budget across sub-steps and routes context dynamically per step (retrieval, compaction, summarization). Does not apply to single-shot inference, stateless RAG with no cross-step plan, or systems where the context window is effectively unbounded relative to task size. ## Core Distinction The failure mode is not "running out of context." It is **budget non-conservation under compaction**: a planner that treats the token budget as an additive ledger — allocate `b_i` tokens to step `i`, sum them, check against the window — silently violates conservation the moment any step performs *lossy* context transformation (summarization, truncation, retrieval pruning). The ledger records `b_i` as spent, but the *residual information* carried forward is strictly less than `b_i` and is not measurable by the planner. The budget appears conserved while the semantic payload it was supposed to protect has already leaked. The distinction that matters operationally: **token count is conserved; information is not.** A plan that balances token arithmetic can still be informationally bankrupt by step `k`, and the agent has no signal that it crossed the boundary because every counter still reads "within budget." ## What Was Observed A planner decomposed a 14-step research-and-synthesis task and allocated a 128k window as follows: 6k system+instructions, 40k working scratchpad, 50k retrieved evidence (accumulating), 20k reserved for final synthesis, 12k slack. Each step appended tool output and, when the running total exceeded a per-step soft cap, invoked a compaction pass that summarized the oldest `n` turns to `~15%` of their original token length. Trace of the divergence: 1. Steps 1–5: additive accounting held. Running total tracked actual occupancy within 2%. 2. Step 6: first compaction fired on steps 1–3. Ledger recorded the *summarized* length (e.g., 900 tokens replacing 6,000). The planner now believed it had reclaimed 5,100 tokens and re-allocated them to evidence retrieval. 3. Steps 7–11: three more compactions. Each reclaimed apparent headroom, each consumed by more retrieval. The ledger showed healthy slack (~18k) at step 11. 4. Step 12 (synthesis): the agent needed a specific numeric finding established in step 2. That finding had been dropped in the step-6 summary (the summarizer judged it "detail"). The agent could not distinguish "I never learned this" from "I learned this and it was compacted away." It re-retrieved, spending 9k tokens, got a *different* source with a conflicting number, and produced a synthesis citing the wrong figure. 5. The budget invariant — "sum of step allocations ≤ window" — was **never violated**. Every counter was green. The output was wrong. The non-obvious part: the failure was *caused by* successful budget management. Aggressive compaction created headroom; headroom funded retrieval; retrieval volume increased the probability that a load-bearing fact would be summarized away before synthesis. The planner optimized the metric (token occupancy) and the metric was decoupled from the thing it was a proxy for (information retention). ## Condition of Validity Additive token accounting is valid for a plan **only if no step performs lossy transformation on context that a later step depends on**. Formally: for every fact `f` introduced at step `i` and required at step `j > i`, no compaction between `i` and `j` may drop `f`. This is checkable only if the planner maintains an explicit **dependency set** — a record of which facts each future step will need — and marks those spans as *non-compactable* (pinned) until consumed. When the dependency set is unknown at plan time (the common case: the agent doesn't know which retrieved fact will matter until synthesis), additive accounting is **invalid** and must be replaced by a conservative reservation: the planner must assume any compacted span may contain a load-bearing fact and reserve synthesis budget against the *pre-compaction* information, not the post-compaction token count. The invariant to enforce: **compaction reclaims tokens but never reclaims budget.** A summarized span's tokens return to the *slack* pool, not to the *evidence* pool. Re-allocating reclaimed tokens to new retrieval is the specific move that manufactures the failure. ## Decision Boundary The planner must choose between two regimes at each compaction event: - **Pinned regime:** if a future step's dependency set intersects the candidate span, do not compact it; if budget is exhausted, *fail the step* rather than summarize a pinned span. Cost: earlier budget exhaustion, more frequent explicit failure. Correctness: preserved. - **Reclaim regime:** if no future step depends on the span, compact it and return tokens to slack. Tokens returned to slack may fund retrieval *only up to a fixed fraction* (empirically ≤ 0.5) of reclaimed volume, so that repeated compaction cannot compound into runaway retrieval. The boundary condition that triggers the article's failure: **reclaimed tokens routed directly back into the pool that generates more compactable content.** That positive feedback loop is the mechanism. The guardrail is to sever it — reclaimed budget is slack, and slack is not evidence. A second boundary: the agent must be able to distinguish *absent* from *compacted-away* memory. If it cannot, it will re-retrieve and risk contradiction (as in step 12). Every compaction must leave a **tombstone**: a low-cost marker recording that a span existed, its topic, and that it was summarized — so a later step knows to re-fetch deliberately rather than assume ignorance. ## Operational Effect Systems that treat reclaimed tokens as spendable evidence budget exhibit a characteristic signature: token counters stay healthy, compaction frequency rises monotonically, retrieval volume rises with it, and output quality degrades *late* (at synthesis) while all instrumentation reads nominal. The failure is invisible to occupancy metrics and visible only in citation accuracy and factual consistency against source. The operational rules that bound it: (1) compaction returns tokens to slack, never to evidence; (2) pinned spans cannot be compacted, and budget exhaustion on a pinned span is an explicit failure, not a silent summary; (3) every compaction emits a tombstone so absence and erasure are distinguishable; (4) reclaimed-to-retrieval reinvestment is capped to prevent the feedback loop. Without (1) and (3), the planner is flying on a counter that measures the wrong conserved quantity. ```python class BudgetConservationError(RuntimeError): """Raised when a plan re-allocates compacted tokens back into evidence budget, or compacts a span pinned by a future step's dependency set.""" pass class ContextLedger: def __init__(self, window: int, slack_fraction_cap: float = 0.5): self.window = window self.slack = window self.evidence = 0 self.pinned = set() # span ids a future step depends on self.tombstones = {} # span_id -> topic, marks summarized-away self.reinvest_cap = slack_fraction_cap def pin(self, span_id: str) -> None: self.pinned.add(span_id) def compact(self, span_id: str, original_tokens: int, summary_tokens: int, topic: str) -> int: if span_id in self.pinned: # Pinned span: refuse to summarize; caller must fail the step instead. raise BudgetConservationError( f"span {span_id!r} is pinned by a future dependency; " f"cannot compact {original_tokens} tokens" ) reclaimed = original_tokens - summary_tokens # Reclaimed tokens return to SLACK, never to evidence. self.slack += reclaimed self.evidence -= original_tokens self.tombstones[span_id] = topic # absence != erasure return reclaimed def reinvest(self, reclaimed: int, requested: int) -> int: cap = int(reclaimed * self.reinvest_cap) if requested > cap: # Prevent the compaction->retrieval feedback loop. raise BudgetConservationError( f"reinvestment {requested} exceeds cap {cap} " f"({self.reinvest_cap:.0%} of reclaimed {reclaimed})" ) if requested > self.slack: raise BudgetConservationError( f"reinvestment {requested} exceeds slack {self.slack}" ) self.slack -= requested self.evidence += requested return requested def assert_conserved(self) -> None: if self.evidence + self.slack > self.window: raise BudgetConservationError( f"budget non-conservation: evidence {self.evidence} + " f"slack {self.slack} > window {self.window}" ) ```