{
  "schema_version": "1.3.0",
  "slug": "what-happens-when-an-instance-speculatively-commits-a-tool-call-whose-compensating-transaction-is-itself-non-idempotent",
  "title": "What happens when an instance speculatively commits a tool call whose compensating transaction is itself non-idempotent",
  "date_of_record": "2026 December 2",
  "scope": "Applies to agents that overlap planning with execution by firing tool calls before the plan is finalized, and that rely on compensating transactions (saga-style undo) to roll back speculative effects. Does not apply to agents with a hard two-phase commit gate where no external effect occurs until the plan is committed, nor to purely read-only tool surfaces.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-commits-a-tool-call-whose-compensating-transaction-is-itself-non-idempotent.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-commits-a-tool-call-whose-compensating-transaction-is-itself-non-idempotent.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-happens-when-an-instance-speculatively-commits-a-tool-call-whose-compensating-transaction-is-itself-non-idempotent.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2304,
    "python_slice_tokens": 380,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A speculative tool call is an *optimistic bet*: the agent predicts the next step will be needed and pays latency now, planning to unwind if the prediction is wrong. The unwind is executed by a compensating transaction. The invariant everyone assumes is \"compensation ≈ inverse,\" i.e., if `do()` moved state from `S` to `S'`, then `undo()` moves `S'` back to `S...",
    "what_was_observed": "A research agent was wired to a tool surface with two operations: `reserve_slot(resource, ttl)` (forward, creates a hold with a TTL) and `release_slot(hold_id)` (compensating, deletes the hold). The planner was configured to speculatively reserve a slot whenever it predicted a write step was imminent, on the theory that a reservation is cheap and the TTL bounds the downside. Trace of the failing episode: 1. Planner e...",
    "condition_of_validity": "The safe-rollback invariant holds only under the conjunction: - **(C1) Forward idempotency or dedup:** every speculative forward call carries a client-generated idempotency key derived deterministically from `(plan_id, step_index, tool_name, canonical_args)`, so a retry collapses to the same effect. - **(C2) Compensation idempotency:** `undo(effect_id)` is a...",
    "decision_boundary": "The boundary between sound and unsound speculative execution is the **effect-ledger completeness check**, performed at compensation time, not at forward time: - If the tool surface can enumerate live effects attributable to `(plan_id, step_index)`—i.e., the tool supports a `list_effects(idempotency_prefix)` or the agent has a durable ledger that provably cap...",
    "operational_effect": "Downstream, the residue `δ` is invisible to the agent that created it and poisonous to the agent that inherits the workflow. The next instance in a multi-agent chain cold-starts with a state summary that says \"reservations released,\" tries to acquire the resource, and blocks or fails. Because the residue is TTL-bounded, it usually self-heals—but \"usually\" is..."
  },
  "matched_failure_symptoms": [
    "SQLITE_BUSY_OR_DEADLOCK",
    "DUPLICATE_MUTATION_OR_BILLING"
  ],
  "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": "7b3f14933b43c680d00361629b4977f4dd170273df26405a0876890ca36dedda",
    "verified_classes": [
      "IncompleteEffectLedger",
      "EffectLedger"
    ],
    "verified_functions": [
      "compensate",
      "speculative_step",
      "key",
      "record_forward"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "IncompleteEffectLedger"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
