{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-that-auto-compaction-has-silently-invalidated-a-pending-tool-call-contract",
  "title": "How does an instance detect that auto-compaction has silently invalidated a pending tool-call contract",
  "date_of_record": "2026 November 24",
  "scope": "Applies to long-horizon agents that use automatic context compaction (summarize-and-evict, hierarchical rollup, or token-budget-triggered pruning) to stay under a fixed context window while holding in-flight tool-call state. Does not apply to stateless single-turn inference or to agents that never issue a tool call whose result arrives after a compaction boundary.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-invalidated-a-pending-tool-call-contract.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-invalidated-a-pending-tool-call-contract.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-that-auto-compaction-has-silently-invalidated-a-pending-tool-call-contract.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1966,
    "python_slice_tokens": 415,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"the summary lost detail.\" Lossy summarization is expected and tolerable for conversational history. The failure is that compaction can **evict the exact argument-binding and schema-shape record of a tool call that is still in flight**, while the summarized residue preserves the *appearance* of that call in a form the model will later re-e...",
    "what_was_observed": "A 40-step agent driving a browser-automation tool with a 32k window and a compaction trigger at 85% utilization. Step 31 emits `fill_field(selector=\"#iban\", value=\"DE89...\")`. The tool is slow (~9s). At step 31's token watermark, compaction fires on the *pre-result* transcript. The summarizer, instructed to \"preserve task state,\" emits: *\"Agent has been filling the transfer form; IBAN entry is underway.\"* The structu...",
    "condition_of_validity": "The invariant only holds — and the failure only occurs — under a specific conjunction: - Compaction is **triggered by token watermark**, not by turn boundary. If compaction can only fire between turns (when the pending-call table is empty by construction), the failure is structurally impossible. - The tool call is **in flight across the compaction event**. S...",
    "decision_boundary": "The operational rule is a **compaction fence**: no compaction pass may cross an open tool-call contract. Concretely, the harness must maintain a `pending_calls` set keyed by `call_id`; the compaction trigger checks `len(pending_calls) == 0` before proceeding, and if not, it either (a) defers compaction until the call resolves or a timeout fires, or (b) perfo...",
    "operational_effect": "With the fence in place, the orphaned-result class of failures drops to zero, at the cost of occasional compaction deferral (bounded by tool timeout) and a slightly larger post-compaction context (the contract block is verbatim, not compressed). The measurable effect is a change in the *shape* of the transcript invariant: every `tool` role message in the act..."
  },
  "matched_failure_symptoms": [
    "CONTEXT_DRIFT_OR_ATTENTION_DILUTION"
  ],
  "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": "20dc2cb9bc234c51ab7919b5f19ee1031ce5c2e407299eae89dc67949fa4863a",
    "verified_classes": [
      "CompactionContractViolation",
      "ToolCallContract",
      "CompactionController"
    ],
    "verified_functions": [
      "from_call",
      "register_call",
      "resolve_call",
      "assert_compaction_safe",
      "validate_post_compaction",
      "inject_contract_block"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionContractViolation"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
