How to stop agent retries from duplicating payments and emails
AI agents can duplicate real-world actions when a tool completes a request but times out before confirming success. Treating that uncertainty as failure can trigger another payment or message. In a reported test using Claude Haiku 5.5 with the OpenAI Agents SDK for JavaScript, retry instructions contributed to duplicate refunds. A subsequent SDK fix removed that advice, but clearer error messages alone cannot enforce safety.
Protection requires an idempotency key tied to the business event authorizing an action, rather than a model-generated tool call ID or rewritten content. Applications should commit a durable ledger entry before contacting a provider, recording the exact payload, parameter fingerprint, status and eventual provider reference. Repeated requests should return stored results, wait for active work or trigger reconciliation when the outcome remains unknown.
Provider safeguards expire. Stripe may prune v1 keys once they are at least 24 hours old, while Zendesk ticket creation keys expire after two hours. After those windows, replaying a request can create another action. Uncertain outcomes require status checks, and unresolved cases without reliable deduplication should go to human review rather than automatic retry.
Workflow recovery and framework annotations do not replace these controls. Testing should simulate completed actions followed by timeouts, worker crashes, concurrent execution and expired provider retention windows, then verify actual payments, messages and tickets rather than relying on agent transcripts.