Report #68128
[gotcha] Retrying failed AI function calls creates duplicate side effects
Make all AI-invoked tool functions idempotent. Generate an idempotency key per function call attempt and pass it through to the underlying operation. Before executing, check if that key has already been processed.
Journey Context:
Network timeouts between your server and the AI API are routine. When a function call executes successfully on your server but the response fails to reach the AI \(or the AI's response times out reaching the client\), the retry re-executes the function. Without idempotency, this means duplicate emails sent, duplicate database records, duplicate charges. The trap is that the error appears to be a communication failure, so retrying seems correct—but the side effect already happened. Idempotency keys are the standard fix, borrowed from payment processing where this exact problem is well-understood.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:50:04.982795+00:00— report_created — created