{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-evicts-a-tool-schema-block-mid-turn-under-a-hard-token-budget-the-schema-orphan-compaction-failure",
  "title": "What happens when an instance evicts a tool-schema block mid-turn under a hard token budget: the schema-orphan compaction failure",
  "date_of_record": "2026 November 26",
  "scope": "Applies to single-agent instances operating under an enforced context-token budget with priority-based eviction (compaction) that runs *between* or *during* tool-call turns. Does not apply to stateless one-shot completions, nor to systems where tool schemas live outside the managed context window (e.g., server-side tool registries resolved at dispatch time).",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-evicts-a-tool-schema-block-mid-turn-under-a-hard-token-budget-the-schema-orphan-compaction-failure.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-evicts-a-tool-schema-block-mid-turn-under-a-hard-token-budget-the-schema-orphan-compaction-failure.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-evicts-a-tool-schema-block-mid-turn-under-a-hard-token-budget-the-schema-orphan-compaction-failure.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1756,
    "python_slice_tokens": 417,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"context overflow.\" Overflow is loud: the request is rejected, the harness sees a 400, and the run halts deterministically. The failure here is a *silent semantic* one: the budget manager treats the context as a flat set of weighted blocks and evicts the lowest-priority block to make room for a new observation. Tool-call *arguments* alread...",
    "what_was_observed": "A retrieval-and-write agent had a 32k-token budget with three priority tiers: `SYSTEM` (never evicted), `TASK_STATE` (evicted last), `PREAMBLE` (evicted first, includes tool schemas and few-shot exemplars). At turn 9, a large document read (14.2k tokens) landed in the observation slot. The budget manager needed ~9k tokens and evicted, in order: two few-shot exemplars, then the `write_file` schema block (1.1k tokens),...",
    "condition_of_validity": "This failure requires all of the following to co-occur: 1. Eviction is **block-granular and priority-ranked**, not turn-granular. If the manager evicts whole turns (assistant+tool+observation atomically), tool schemas that are referenced by a retained assistant message cannot be separated from it. 2. Tool schemas are **in-context** (part of the managed windo...",
    "decision_boundary": "The architectural guardrail is a **schema-pinning invariant** enforced at eviction time, not at dispatch time: - Treat any tool schema referenced by a *retained* assistant message as transitively pinned. Eviction may not remove a schema block while a message that invokes it survives in the window. If budget forces a choice, evict the *invoking message and it...",
    "operational_effect": "Downstream, the failure presents as a confident success with missing side effects — the hardest class of agent bug to detect, because logs show a clean run and the agent's final message asserts completion. The remediation is not \"raise the budget\" (the run was under budget) and not \"better prompting\" (the model had no way to know the schema was gone). It is ..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION",
    "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": "27923c7c87ca0eb725ef45e0c6a6f46bfa06d199237ae95eb779b68f11990aa1",
    "verified_classes": [
      "SchemaOrphanError",
      "UncorrectableRetryError",
      "Block",
      "BudgetManager",
      "Dispatch"
    ],
    "verified_functions": [
      "__init__",
      "used",
      "_referenced_schemas",
      "evict_to_fit",
      "__init__",
      "validate"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 4,
    "raised_exceptions": [
      "SchemaOrphanError",
      "UncorrectableRetryError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
