An agent creates a ticket and the client times out. The provider may already have committed the ticket. A worker that takes the timeout as permission to create another ticket can turn a lost response into a duplicate.

Give each write its own identity

Imagine a step that creates a ticket and then posts a summary. Those are two effects. Persist a different operation ID for each before the first attempt and reuse that ID only for retries of the same effect and payload. A retry of the summary must never start a fresh ticket creation.

A local ledger can record three states: planned, outcome unknown, and confirmed. Record an attempt before calling the provider. Save the provider’s receipt and object ID when available. A local “started” record tells the next worker to reconcile; it cannot tell the worker whether the provider committed. Serializing workers for one operation avoids concurrent local sends but still leaves a crash window between the remote commit and the local receipt.

Decide what to do with a missing response

  1. If the transport can establish that no request was sent, the worker can start the planned write.
  2. If the provider supports idempotency for that operation, reuse the original key and unchanged parameters within the provider’s documented scope and retention period. Two deliberate requests with identical data still need different keys.
  3. If the provider offers lookup by a stable client reference, check for the existing effect and save its receipt. An empty result from a lagging index is inconclusive. Even a current lookup cannot rule out a request still executing.
  4. If neither deduplication nor authoritative reconciliation is available, leave the outcome unknown and surface it for review. Retrying with a fresh key would be a second write.

HTTP’s rule for automatic retries distinguishes idempotent operations from non-idempotent ones. Individual providers can offer stronger contracts. For example, Stripe API v1 supports a key on POST requests and documents how reuse behaves after that key has been pruned. Check the contract of the API you actually use. HTTP Semantics, section 9.2.2 · Stripe idempotency keys

Test the crash window

Use a disposable receiver and one operation that creates one countable effect. Arrange for the receiver to commit, then discard its response. Restart the caller before it can record success. With receiver-side deduplication enabled, repeat with the original key and check the receiver’s effect count and object ID. With deduplication disabled and no authoritative lookup, the caller should mark the operation for reconciliation and stop sending. Finally, initiate a genuinely new operation with the same payload to verify it receives a fresh ID.

These are proposed checks. Count effects at the receiver independently of client log entries. Distinguish a missing receipt from a confirmed rejection when reading the results.

This article was created with AI assistance.