{
  "schema_version": "1.3.0",
  "slug": "why-does-an-instance-lose-tool-call-atomicity-when-auto-compaction-fires-between-a-side-effecting-call-and-its-result-receipt",
  "title": "Why does an instance lose tool-call atomicity when auto-compaction fires between a side-effecting call and its result receipt",
  "date_of_record": "2026 November 30",
  "scope": "Applies to long-horizon agents that persist transcripts to a durable store and run an auto-compaction (summarize-and-truncate) policy while a tool call is in flight. Does not apply to single-turn agents, agents that buffer tool results before any compaction pass, or stateless function-calling loops with no transcript persistence.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-atomicity-when-auto-compaction-fires-between-a-side-effecting-call-and-its-result-receipt.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-atomicity-when-auto-compaction-fires-between-a-side-effecting-call-and-its-result-receipt.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/why-does-an-instance-lose-tool-call-atomicity-when-auto-compaction-fires-between-a-side-effecting-call-and-its-result-receipt.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2339,
    "python_slice_tokens": 415,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Auto-compaction is usually modeled as a *lossy read transform*: it rewrites old transcript segments into summaries so the context window can continue. That model is wrong in one specific place. When compaction fires between the emission of a side-effecting tool call (`write_file`, `send_email`, `execute_sql`, `git_push`) and the arrival of its result receipt...",
    "what_was_observed": "A file-maintenance agent running a 40-minute horizon on a repo-migration task emitted: The tool dispatcher acknowledged the call and began execution (a subprocess spawn, ~1.8 s wall time including a filesystem lock). At token 91,400 of a 96,000 budget, the compaction scheduler — which fires on a *token-count watermark*, not on a *pending-call watermark* — triggered. The compactor summarized the segment `[t0 .. t91400...",
    "condition_of_validity": "The hazard is bounded by a precise condition. Let `C` be the compaction cursor (the token index the summarizer is allowed to consume up to), and let `P` be the set of tool calls that have been emitted but whose results have not yet been appended. Compaction is safe **if and only if** `C ≤ min(position(call) for call in P) - 1` — that is, the cursor never adv...",
    "decision_boundary": "The runtime must choose, at each compaction trigger, between three policies. The choice is forced by whether a pending-call watermark is available. - **Defer (preferred).** If `P` is non-empty, postpone compaction until the earliest pending call's receipt lands or its timeout fires. Cost: the context window may temporarily exceed the soft threshold by the si...",
    "operational_effect": "The downstream consequences are not \"the agent forgot something.\" They are *duplicate side effects with divergent results*, because the agent's recovery path is to re-execute, and re-execution of a non-idempotent action against a partially-applied state produces a second effect that the first did not. The dedup layer cannot help, because the compaction erase..."
  },
  "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": "18103d0715a626d925f03ad1d45759e23bbef9b33434e64b258cbe8d524205ef",
    "verified_classes": [
      "CompactionAtomicityError",
      "ToolCall",
      "CompactionScheduler"
    ],
    "verified_functions": [
      "run_compaction_pass",
      "on_call_emitted",
      "on_receipt_arrived",
      "safe_cursor",
      "plan_compaction"
    ],
    "verified_functions_count": 5,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "CompactionAtomicityError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
