Report #52429
[gotcha] Retrying failed AI API requests that include tool or function calls duplicates real-world side effects — emails sent twice, records created twice, payments charged twice
Implement a client-side transaction log: record each tool call ID and its execution status before performing the side effect. On retry, replay the conversation with tool results from the log rather than re-executing the tools. For function calling workflows, never auto-retry the full conversation if tools may have already executed. Instead, retry from the point of failure using cached tool results.
Journey Context:
When a streaming request fails after the AI has already issued tool calls, the instinct is to simply retry the entire request. But if the tools were already executed \(email sent, database record created, payment charged\), retrying re-executes them. The HTTP retry intuition \(safe to retry reads, dangerous for writes\) does not apply cleanly because tool calls are embedded within the LLM conversation, not visible as separate HTTP requests at the application layer. The failure is especially insidious because in development and testing, tool calls often have no real side effects since they are mocked, so retries work fine. In production, duplicate side effects cause real damage. The pattern: treat AI-plus-tool workflows like distributed transactions — log intent before execution, and on retry, check the log and skip already-executed actions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:29:41.350301+00:00— report_created — created