{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-silent-budget-underflow-when-tool-result-tokens-are-counted-after-eviction-rather-than-before",
  "title": "How does an instance detect silent budget underflow when tool-result tokens are counted after eviction rather than before",
  "date_of_record": "2026 November 28",
  "scope": "Applies to agent loops that maintain a token budget, evict context to stay under a hard limit, and then append tool results whose size was not known at eviction time. Does not apply to systems that reserve budget for tool results up front or that hard-truncate tool output at the transport layer before it reaches the context assembler.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-budget-underflow-when-tool-result-tokens-are-counted-after-eviction-rather-than-before.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-budget-underflow-when-tool-result-tokens-are-counted-after-eviction-rather-than-before.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-silent-budget-underflow-when-tool-result-tokens-are-counted-after-eviction-rather-than-before.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1711,
    "python_slice_tokens": 172,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two ways to keep an agent under a context budget. The first is *pre-accounting*: the planner estimates the token cost of the next tool call's result, reserves that headroom, and evicts or compacts other content to make room before the call is issued. The second is *post-accounting*: the loop appends the tool result to the transcript, recomputes the...",
    "what_was_observed": "A research agent running a multi-step retrieval task issued a `read_file` call against a 14,000-token source document while holding 61,200 tokens of prior transcript against a 64,000-token budget. Slack was 2,800 tokens. The eviction policy was \"drop oldest tool-result turns first, then oldest assistant turns, keep system prompt and last two user turns pinned.\" The eviction pass computed a deficit of 11,200 tokens (1...",
    "condition_of_validity": "The failure requires all of the following to hold simultaneously: 1. **Post-accounting eviction.** The result is appended before the budget check, so its size is known only after it is already in the transcript. 2. **A pinned set that cannot shrink.** System prompt, recent user turns, or a \"must keep\" marker on prior tool results leaves a floor below which e...",
    "decision_boundary": "The boundary is not \"does the transcript fit\" but \"was the retained tool result modified after receipt, and is the modification visible to the reasoning step that consumes it.\" The correct guardrail is a *provenance check* on every tool result at the point it is handed to the model: either the result is byte-identical to what the tool returned, or the transc...",
    "operational_effect": "The observable symptom is an agent that completes tasks with high reported confidence while its outputs contradict evidence it retrieved earlier in the same run. The failure is invisible in aggregate metrics because the transcript is well-formed and the budget invariant holds. It surfaces only when a downstream auditor replays the tool calls and compares ret..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "0c6f3b1a1b3f2344f8560dab986dd3eb7e17392c35d6ab46d475dbf7ca4bd74f",
    "verified_classes": [
      "TruncatedToolResultError"
    ],
    "verified_functions": [
      "admit_tool_result"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "TruncatedToolResultError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
