{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-auto-compacts-its-own-summary-of-a-pending-tool-call",
  "title": "What happens when an instance auto-compacts its own summary of a pending tool call",
  "date_of_record": "2026 December 1",
  "scope": "Applies to long-horizon agents that trigger context auto-compaction (summarize-and-evict) while a tool call is in flight or while a tool result is queued but not yet consumed. Does not apply to compaction gated strictly at turn boundaries with no outstanding async tool state.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-auto-compacts-its-own-summary-of-a-pending-tool-call.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-auto-compacts-its-own-summary-of-a-pending-tool-call.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-auto-compacts-its-own-summary-of-a-pending-tool-call.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2205,
    "python_slice_tokens": 318,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Most compaction designs treat the transcript as a flat sequence of messages and evict the oldest tokens once a watermark is crossed. The dangerous case is not \"we lost old context.\" It is that the compaction summarizer runs over a transcript slice that contains a *tool-call intent* (assistant message declaring `call_id=X`) but not the *tool result* (`tool_ca...",
    "what_was_observed": "A research agent running a 40-minute horizon task with a 200k-token budget and a 128k compaction watermark. At step 61 it emitted a batched tool call: `get_positions(account=4471)` plus `get_ledger_range(account=4471, from=..., to=...)`. The batch was dispatched to an MCP server with a 4-second p99 latency. At step 61's token count (131k), the runtime's watermark check fired *before* the tool results returned, becaus...",
    "condition_of_validity": "The failure requires all of: - **Asynchronous tool execution** where the result arrives after the assistant turn's emission but the runtime's watermark check is keyed to emission, not to turn completion. If tools are synchronous and the runtime blocks on results before the next token count, the pair is never split. - **Replacement-style eviction** (summary r...",
    "decision_boundary": "The architectural choice is where the compaction boundary is allowed to fall relative to call/result pairs. Three viable positions: 1. **Turn-boundary gating (safest, costs latency).** Compaction may only run when the outstanding-call set is empty. Under a 4s tool latency and 2k tokens/turn, this defers compaction by at most one turn—negligible for long-hori...",
    "operational_effect": "The downstream signature is a *re-issue loop*: the agent re-calls the same tool with the same arguments, gets the same result, and the result is again orphaned because the transcript has again been compacted past the (new) call. Loop period ≈ tool latency + compaction interval. In the observed runs, the loop terminated only when the tool result happened to a..."
  },
  "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": "9da7f85775be198ce127bb4c7b62cc650da819933bbc9d894b96e3e2d9b6636e",
    "verified_classes": [
      "CompactionPairSplitError",
      "ToolCall",
      "Transcript"
    ],
    "verified_functions": [
      "compact_with_pair_snapping",
      "emit_call",
      "deliver_result",
      "compact"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "CompactionPairSplitError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
