Idempotency for AI agents: prevent duplicate actions
Idempotency means a repeated request has the same intended effect as a single request.

Idempotency means a repeated request has the same intended effect as a single request. For AI agents, it helps prevent duplicate messages, records or payments when a workflow retries after an interruption. It requires support in the execution system; telling the model not to repeat itself is insufficient.
Start with the ambiguous timeout
Imagine an agent creating a customer task. The destination saves it, but the response is lost. The agent sees a timeout and tries again. Without duplicate protection, two tasks may appear even though the user requested one.
The safe recovery depends on the destination's capabilities. Some APIs support an idempotency key. Others require a lookup by a stable business identifier before deciding whether to repeat an action.
Give each intended action an identity
- Generate a stable request ID for the specific business action.
- Persist it before attempting the external write.
- Associate it with the destination, payload and status.
- Reconcile unknown outcomes using provider receipts or a readback.
- Reuse a key only according to the provider's documented rules.
Do not reuse the same key for a changed payload. A second legitimate action needs its own identity, while a retry of the original should remain connected to the original record.
Test a lost response
In a controlled environment, simulate a successful write followed by a transport error. Confirm the next run finds or reconciles the first result instead of creating another. Test concurrent duplicate requests as well, since two workers may receive the same event at nearly the same time.
A local flag can fail under concurrency unless the storage operation itself is atomic.
Report unknown honestly
When you cannot establish whether the action happened, preserve that uncertainty and route it to the recovery owner. Do not label it successful or blindly failed. An explicit unknown state is more useful than a confident status that causes the team to repeat an action with real consequences.
Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.