Idempotency
The property that performing an action multiple times has the same effect as performing it once. It is a quiet but critical reliability control for AI agents because agents *retry* constantly — a non-deterministic agent that doesn't get a clear success signal, or one whose Fallback logic re-attempts a failed step, will often do the same action twice. If that action is idempotent, the retry is harmless; if it isn't, the retry is a double-charge, a duplicate email, two refunds, a second booking. The standard implementation is an *idempotency key*: the agent attaches a unique token to each logical action, and the receiving system deduplicates on it, so a retried 'create refund' with the same key is recognized as the same request and executed once. Idempotency is what makes retries, circuit breakers, and at-least-once execution *safe* — without it, every reliability mechanism that re-runs work becomes a way to cause damage. Especially essential for any agent action that moves money, sends communications, or writes to external systems.
Example
A billing agent calls 'charge card' but the network drops before it sees the response. It retries — and without idempotency, the customer is charged twice. With an idempotency key attached to the charge, the payment processor recognizes the retried request as the same logical action and returns the original result instead of charging again. The agent gets its confirmation; the customer is charged once.
Frequently asked questions
- Why do AI agents need idempotency more than normal apps?
- Because agents retry more, and less predictably. Their non-deterministic control flow, aggressive fallback and retry logic, and habit of misreading an ambiguous tool result as 'try again' all mean the *same consequential action* gets attempted more than once far more often than in deterministic software. Idempotency turns that from a liability into a non-event — it's the precondition that makes safe retrying possible at all.
- Which agent actions most need to be idempotent?
- Any action with an external, irreversible side effect: payments and transfers, sending emails or messages, creating orders or bookings, and writes to systems of record. Read-only actions are naturally idempotent and need no special handling. For the risky writes, pair idempotency keys with an approval gate on the highest-stakes ones — idempotency stops accidental duplicates, the gate stops the wrong action entirely.