{
  "schema_version": "1.3.0",
  "slug": "how-does-an-instance-detect-speculative-tool-call-divergence-when-idempotency-tokens-collide-across-merged-agent-branches",
  "title": "How does an instance detect speculative tool-call divergence when idempotency tokens collide across merged agent branches?",
  "date_of_record": "2026 November 27",
  "scope": "Applies to agent runtimes that (a) speculatively execute tool calls before the enclosing plan branch commits, (b) deduplicate side effects via idempotency tokens, and (c) merge divergent sibling branches (e.g., parallel sub-agents, speculative beam branches) into a single committed state. Does not apply to strictly sequential single-branch agents with no speculative execution, nor to idempotency schemes scoped only to a single process lifetime.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-divergence-when-idempotency-tokens-collide-across-merged-agent-branches.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-divergence-when-idempotency-tokens-collide-across-merged-agent-branches.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/how-does-an-instance-detect-speculative-tool-call-divergence-when-idempotency-tokens-collide-across-merged-agent-branches.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2485,
    "python_slice_tokens": 422,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "There are two distinct notions of \"the same tool call,\" and conflating them is the root of this failure mode. The first is **semantic identity**: two invocations that intend the same effect (same tool, same logical arguments, same target resource). The second is **idempotency identity**: the token that the downstream system uses to collapse retries into one ...",
    "what_was_observed": "A three-branch speculative planner was asked to \"reconcile the customer's billing address across the CRM and the invoice ledger.\" The planner fanned out into three branches: - **Branch A** read the CRM record and issued `crm.update_contact(address=X)` as the reconciliation write. - **Branch B** read the ledger and issued `ledger.update_billing_address(address=X)`. - **Branch C** was a speculative \"verify\" branch that...",
    "condition_of_validity": "The invariant that bounds this failure is: > **For any two speculative branches `i` and `j` that produce tool calls `c_i` and `c_j`, if `semantic_identity(c_i) == semantic_identity(c_j)` then `idempotency_token(c_i) == idempotency_token(c_j)`, and this equality must be established at the fork point, not at the leaf.** Equivalently: the idempotency token is a...",
    "decision_boundary": "The operational decision is what the runtime does at the moment a branch's runtime arguments diverge from its declared node arguments. There are three candidate policies, and only one is safe under speculative merge: - **Execute-and-mint (unsafe).** The branch executes with drifted args and the gateway mints a new token. This is what produced the split-brain...",
    "operational_effect": "With abort-on-divergence enforced, the failure trace changes at exactly one point. Branch C, on detecting that its retrieved `address=Y` differs from the node's declared `address=X`, raises `SpeculativeDivergence` before calling the gateway. The gateway never sees a second token. The merge layer receives `(node_crm_update, divergence)` alongside `(node_crm_u..."
  },
  "matched_failure_symptoms": [
    "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": "6b607da0b635846d416946b417cfc1a1f779cc58fcf4cebcba0df09254c12dc1",
    "verified_classes": [
      "SpeculativeDivergence",
      "PlanNode"
    ],
    "verified_functions": [
      "mint_token",
      "canonical",
      "execute_speculative_branch",
      "merge_branches"
    ],
    "verified_functions_count": 4,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "SpeculativeDivergence"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "hashlib",
      "json"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
