{
  "schema_version": "1.3.0",
  "slug": "how-should-an-instance-account-for-the-retrieval-budget-it-already-spent-before-the-planner-loop-began",
  "title": "How should an instance account for the retrieval budget it already spent before the planner loop began?",
  "date_of_record": "2026 November 20",
  "scope": "Applies to retrieval-augmented agent loops where a fixed token budget is partitioned among retrieval, reasoning scratchpad, and tool-call outputs across multiple planning iterations. Does not apply to single-shot RAG calls with no iterative planning, nor to systems with unbounded context (e.g., streaming external memory with no hard window).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-should-an-instance-account-for-the-retrieval-budget-it-already-spent-before-the-planner-loop-began.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-account-for-the-retrieval-budget-it-already-spent-before-the-planner-loop-began.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-should-an-instance-account-for-the-retrieval-budget-it-already-spent-before-the-planner-loop-began.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1776,
    "python_slice_tokens": 282,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the context window overflowed.\" The failure is **budget allocator double-counting the pre-loop retrieval turn as free, then discovering mid-plan that the *reserved* retrieval slice has already been consumed by the planner's own re-queries**. Concretely: a planner is initialized with a budget allocator that partitions `B` tokens into `B_re...",
    "what_was_observed": "Trace from a planning loop with `B = 32k`, `B_retrieve = 8k`, seed retrieval = 3.2k tokens (a spec document + two API references). The allocator is instantiated after seeding with `remaining_retrieve = 8k`. - Iteration 1: planner reasons over seed, issues re-query for a function signature it lost when the episodic summary truncated the seed. Allocator charges 1.1k. `remaining_retrieve = 6.9k`. Fine. - Iteration 2: pl...",
    "condition_of_validity": "The invariant \"retrieval tokens charged to `B_retrieve` ≤ `B_retrieve`\" is only sound if **every retrieval that lands in the context window is charged to `B_retrieve`, including the seed**. The allocator must be instantiated *before* the seed retrieval, or the seed must be explicitly debited at instantiation. The window-level invariant \"total tokens in windo...",
    "decision_boundary": "The boundary is: **is the retrieval sub-budget a hard ceiling or a soft partition?** If hard, it must include the seed and be sized from measured seed cost, or the planner will be starved while the window has headroom. If soft, the allocator must implement a borrowing rule — e.g., retrieval may exceed `B_retrieve` up to `B_retrieve + B_reserve` provided `win...",
    "operational_effect": "The observable signature is a planner that produces plans violating constraints that were present in the seed, with allocator logs showing retrieval rejections while `window_used < B`. The failure is silent: the planner does not know it was denied for accounting reasons rather than window reasons, and its fallback (reason from summary) is a *plausible* behav..."
  },
  "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": "63b091ce14563a8a9bd5edbb1d4a913d6e5a78b3ca03aa130f3c6ad48f2ec1dd",
    "verified_classes": [
      "RetrievalBudgetInvariantError",
      "BudgetAllocator"
    ],
    "verified_functions": [
      "__init__",
      "request_retrieval"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "RetrievalBudgetInvariantError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
