{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-context-budget-allocators-from-silently-evicting-tool-schemas-mid-reasoning-loop",
  "title": "Which invariants prevent context budget allocators from silently evicting tool schemas mid-reasoning-loop",
  "date_of_record": "2026 November 25",
  "scope": "Applies to agents that dynamically re-arbitrate a fixed token budget across system prompt, retrieved memory, and tool schemas between reasoning steps. Does not apply to single-shot prompts with a static, pre-compiled context assembled once before generation.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-budget-allocators-from-silently-evicting-tool-schemas-mid-reasoning-loop.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-budget-allocators-from-silently-evicting-tool-schemas-mid-reasoning-loop.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-context-budget-allocators-from-silently-evicting-tool-schemas-mid-reasoning-loop.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1626,
    "python_slice_tokens": 319,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A context budget allocator is not a cache. A cache evicts the least-recently-used entry and pays a recompute cost on miss; the caller survives. A budget allocator that evicts a *tool schema* mid-loop does not pay a recompute cost — it removes the model's ability to emit a valid call for a tool it already decided to use. The distinction that matters operation...",
    "what_was_observed": "Trigger condition: a 12-step refund-processing agent with a 32k context window. System prompt ~1.8k tokens, tool registry ~6.4k tokens across 22 schemas, retrieved policy memory growing monotonically as the agent pulled customer records. At step 9 the allocator's watermark policy fired: total demand exceeded 30k, so it evicted the four least-recently-*referenced* schemas to make room for a 2.1k-token retrieved policy...",
    "condition_of_validity": "The invariant that would have prevented this: **a schema referenced by any live plan node is pinned until that node is retired, regardless of token-stream recency.** This is only valid if the allocator can *read the plan*. In agents where the plan is implicit (no explicit plan artifact, reasoning spread across scratchpad), the allocator cannot compute the pi...",
    "decision_boundary": "The boundary is between two allocator classes: - **Plan-aware allocator:** pin set = {schemas referenced by unretired plan nodes} ∪ {schemas referenced by the current step's stated intent}. Eviction candidates = memory chunks and unreferenced schemas only. Safe to run dynamic arbitration. - **Plan-blind allocator:** no enumerable pin set. Must allocate schem...",
    "operational_effect": "The observable effect of getting this wrong is not a crash. It is a *validated wrong action*: a tool call that passes schema validation, passes the tool's own guard, and executes with semantically wrong arguments drawn from whatever adjacent artifact survived. These are the most expensive failures to detect downstream because every layer of validation report..."
  },
  "matched_failure_symptoms": [
    "SCHEMA_DRIFT_OR_COERCION_CRASH"
  ],
  "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": "9f7b69bdfc328b2f02344f95fd92aa18f8ed3af64e4246b185e5ecb6c3e1e2f4",
    "verified_classes": [
      "SchemaEvictionSubstitutionError"
    ],
    "verified_functions": [
      "reconcile_step",
      "allocate_budget"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "SchemaEvictionSubstitutionError"
    ],
    "sample_fail_closed_invariants": [
      "plan present but tool references unenumerable; schema pool must be treated as a fixed floor"
    ],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
