# What happens when an instance degrades a tool result to satisfy a context-budget governor and the truncated artifact becomes the ground truth for the next turn **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that enforces a hard token ceiling by mutating or eliding in-flight tool results (summarize, truncate, head/tail-slice, drop-oldest) before the next planning step. Does not apply to systems that reject-and-retry on budget overflow, or that persist full artifacts out-of-band and pass only opaque handles into context. ## Core Distinction A context-budget governor has two fundamentally different jobs that are routinely collapsed into one: **shedding load** (reducing tokens so the request fits) and **preserving referential integrity** (ensuring that what remains in context still truthfully describes the world the agent will act on). Most implementations treat the ceiling as a scalar constraint — `sum(tokens) <= C` — and satisfy it with the cheapest degradation available. That is correct for load and catastrophic for integrity, because the degraded artifact is not marked as degraded in the representation the model reasons over. The model cannot distinguish "the file is 40 lines long" from "the file was 40 lines long when we sliced it to the first 40 lines." The governor has silently promoted a lossy projection to a fact. The failure is not "the model forgot." It is "the runtime lied by omission and the model had no epistemic channel to detect it." Graceful degradation is only graceful if the degradation is *observable to the reasoner*. ## What Was Observed A coding agent is asked to audit a 6,200-line configuration file for a duplicated-key hazard. The runtime's governor is set to `CONTEXT_CEILING = 120_000` tokens with a degradation ladder: `[summarize_tool_result, head_slice(2000 tokens), drop_oldest_tool_result]`. Trace: 1. Turn 1: agent calls `read_file(path="prod.yaml")`. Tool returns 6,200 lines / ~94,000 tokens. Fits. 2. Turn 2: agent calls `grep(pattern="^[a-z_]+:", path="prod.yaml")` to enumerate top-level keys. Returns 1,412 matches / ~11,000 tokens. Total context now ~107,000. Fits. 3. Turn 3: agent calls `read_file(path="prod.yaml", offset=4200)` to inspect the tail where it suspects duplication. Returns ~30,000 tokens. Projected total ~137,000 > ceiling. 4. Governor fires. Ladder step 1: `summarize_tool_result` on the Turn-1 full-file read, replacing 94,000 tokens with a 900-token LLM-generated summary that reads: *"prod.yaml defines database, cache, and queue sections; ~1,400 top-level keys."* 5. Turn 4: agent, reasoning over the summary plus the Turn-2 grep output plus the Turn-3 tail, concludes the file is fully represented and that no duplicate key exists in the head region — because the head region is now described, not present. It reports "no duplication found." The duplication was at line 88. The agent never saw it after Turn 3, and nothing in its context said the head had been evicted. The summary's phrase "~1,400 top-level keys" is *consistent with* duplication (1,412 matches against a summary that rounds) but carries no signal that the underlying bytes are gone. The agent's final answer is a confident false negative. The decisive detail: the grep result at Turn 2 *contained the evidence* — 1,412 matches — but the agent had no way to re-derive line 88 from a match list, and the governor had already destroyed the only artifact that could. The governor optimized the wrong invariant. It kept the request under `C` and broke the property that "every claim the agent makes is checkable against a retained artifact." ## Condition of Validity The degradation was *sound* (did not produce a wrong answer) only under a condition that did not hold: that the summarized region is not load-bearing for any subsequent decision. Formally, let `R` be the set of regions the agent will query in future turns. Degradation is safe iff `R ∩ degraded = ∅`. The governor has no model of `R` — it fires on a scalar and picks a victim by recency/size heuristics. So safety reduces to a bet that the agent will never revisit the largest, oldest artifact, which is exactly backwards: large old artifacts are large *because* they are the substrate the task operates on. The invariant that must hold instead is **referential completeness under projection**: for every artifact `A` that enters context, either `A` is retained in full, or the context contains (a) a projection `π(A)` and (b) a machine-checkable *coverage certificate* stating which byte ranges / line ranges / record IDs of `A` are absent from context and how to re-fetch them. Without (b), `π(A)` is indistinguishable from `A` to the reasoner, and the reasoner will treat it as `A`. A second condition of validity: the degradation ladder must be **monotone in observability**. `drop_oldest_tool_result` is strictly worse than `head_slice` because it removes the artifact *and* any trace that it existed; `summarize` is worse than `head_slice` because it replaces checkable bytes with uncheckable prose. A correct ladder orders by *preserved verifiability*, not by *tokens saved per step*. ## Decision Boundary The boundary between safe and unsafe degradation is drawn at the point where the agent can still **distinguish "I have not seen X" from "X does not exist."** Concretely: - **Safe:** head/tail slice that retains an explicit sentinel in-context: `[TRUNCATED: lines 2001–6200 of prod.yaml omitted; call read_file(offset=2001) to retrieve]`. The agent's planner can see the gap and route around it. - **Safe:** out-of-band persistence with handle substitution: replace the 94,000-token body with `artifact://prod.yaml@sha256:...` plus a `read_slice` capability. Context shrinks; referential integrity is preserved because the handle resolves. - **Unsafe:** free-text summarization of a tool result with no coverage metadata. The summary is a *new assertion* the model will trust as if it were the artifact. - **Unsafe:** silent eviction (drop-oldest) with no tombstone. The agent's context is now a non-contiguous sample of history presented as if contiguous. The governor must therefore refuse to cross the boundary: if the only remaining ladder step is unsafe, it must **fail the turn** with a budget-exhaustion signal the agent can act on (e.g., `ContextBudgetExceeded` carrying the list of evictable artifacts and their sizes), rather than degrade silently. Failing loudly is a valid degradation policy; degrading silently is not. ## Operational Effect With the invariant enforced, the Turn-3 trace changes at step 4: instead of summarizing the full-file read, the governor substitutes a handle `artifact://prod.yaml` and appends a coverage note. At Turn 4 the agent, needing to check line 88, emits `read_slice("artifact://prod.yaml", 80, 100)`, sees the duplicate, and reports it. The token ceiling held; the task succeeded; the difference was 40 tokens of coverage metadata. The systemic effect is that **the governor becomes a scheduler of attention rather than a destroyer of evidence.** Token budget is spent on *pointers and coverage certificates* (cheap, high-integrity) instead of on *summaries of load-bearing artifacts* (expensive to produce, low-integrity). The failure mode this eliminates — confident false negatives caused by silent projection — is the dominant cause of "the agent said it checked but didn't" incidents in long-horizon tool loops, and it is invisible in token-usage dashboards because the request did, in fact, fit. ```python class ContextBudgetIntegrityError(RuntimeError): """Raised when a degradation step would strip verifiability from a load-bearing artifact without leaving a coverage certificate.""" SAFE_DEGRADATIONS = {"slice_with_sentinel", "handle_substitution"} UNSAFE_DEGRADATIONS = {"summarize", "drop_oldest"} def degrade_artifact(artifact, projected_tokens, ceiling, ladder): """ Apply the first ladder step that brings projected_tokens under ceiling, but refuse any step that destroys referential integrity without a coverage certificate. artifact: {id, tokens, byte_len, load_bearing} """ if projected_tokens <= ceiling: return artifact for step in ladder: if step in UNSAFE_DEGRADATIONS and artifact["load_bearing"]: # Do not silently project a load-bearing artifact. raise ContextBudgetIntegrityError( f"refusing '{step}' on load-bearing artifact " f"{artifact['id']!r} ({artifact['tokens']} tokens): " f"no coverage certificate would remain; " f"agent cannot distinguish 'unseen' from 'absent'" ) if step == "slice_with_sentinel": return _slice_with_coverage(artifact) if step == "handle_substitution": return _substitute_handle(artifact) if step in UNSAFE_DEGRADATIONS: # Non-load-bearing: safe to project, but still tombstone it. return _project_with_tombstone(artifact, step) # Ladder exhausted without a safe step: fail loudly, do not degrade. raise ContextBudgetIntegrityError( f"no safe degradation for {artifact['id']!r} at ceiling {ceiling}; " f"surface ContextBudgetExceeded to the planner" ) def _slice_with_coverage(artifact): return {**artifact, "mode": "slice", "sentinel": f"[TRUNCATED: {artifact['byte_len']}B total]"} def _substitute_handle(artifact): return {**artifact, "mode": "handle", "handle": f"artifact://{artifact['id']}", "tokens": 40} def _project_with_tombstone(artifact, step): return {**artifact, "mode": step, "tombstone": f"[{step} applied; original retrievable via handle]"} ```