{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-model-driven-context-pruning-from-invalidating-outstanding-tool-call-references",
  "title": "Which invariants prevent model-driven context pruning from invalidating outstanding tool-call references",
  "date_of_record": "2026 December 1",
  "scope": "Applies to agents that let the model itself select, summarize, or delete spans of its own context window mid-execution, while tool calls (MCP requests, shell invocations, sub-agent spawns) are still in flight. Does not apply to append-only context management, to pruning performed only at turn boundaries with a quiesced tool queue, or to stateless single-shot completions.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-model-driven-context-pruning-from-invalidating-outstanding-tool-call-references.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-model-driven-context-pruning-from-invalidating-outstanding-tool-call-references.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-model-driven-context-pruning-from-invalidating-outstanding-tool-call-references.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1919,
    "python_slice_tokens": 463,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the model forgot something.\" It is that **the model pruned the referent of a live reference while the reference itself remained in the window.** A tool call is a two-part structure: an *invocation record* (the assistant's request, carrying a `call_id`, arguments, and expected schema) and a *result binding* (the eventual tool response keye...",
    "what_was_observed": "A file-mutation agent was configured with a self-edit policy: when the window exceeded 70% of budget, the model was instructed to \"summarize older tool interactions into a compact log and drop the originals.\" During a multi-file refactor it issued `write_file(path=\"a.py\", ...)` and `write_file(path=\"b.py\", ...)` in one turn, then—before results returned—the pruning trigger fired. The model compressed the two invocati...",
    "condition_of_validity": "The invariant that prevents this is: **a context span may be pruned only if every `call_id` referenced by that span has reached a terminal state (resolved, errored, or explicitly cancelled) and the pruned span is not the sole remaining record of that `call_id`.** This holds only under three conditions, all of which must be enforced by the runtime, not the mo...",
    "decision_boundary": "The boundary is between **pruning as a context operation** and **pruning as a state operation**. Below the boundary, the model deletes text and the runtime's promise table is untouched—so the invariant is \"don't let text deletion orphan a promise.\" Above the boundary, if the runtime also cancels the promise when the record is pruned, then pruning becomes a s...",
    "operational_effect": "With the invariant enforced, three behaviors change. First, the pruning trigger's effective budget is smaller than the nominal window, because pending invocation records are pinned and cannot be reclaimed—the runtime must report this pinned overhead to the model so its pruning plan is realistic. Second, duplicate side effects from re-issued calls drop to nea..."
  },
  "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": "115acdbfdbb52217e42c747d4f3c4b3a8d9552a459b489a600db5e1ba299335c",
    "verified_classes": [
      "PruneViolation",
      "CallState",
      "Invocation",
      "ContextRuntime"
    ],
    "verified_functions": [
      "apply_model_prune_plan",
      "register",
      "resolve",
      "validate_prune",
      "prune"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "PruneViolation"
    ],
    "sample_fail_closed_invariants": [
      "empty prune plan submitted by model"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "enum",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
