Back to glossary

Idempotency

A property of an operation where performing it multiple times produces the same result as performing it once, critical for building reliable systems that handle retries and network failures gracefully.

Idempotency ensures safety in unreliable networks. If a client sends a payment request but the response is lost due to a network timeout, the client must retry without knowing if the first request succeeded. If the payment endpoint is idempotent, the retry will not cause a double charge because the system recognizes the duplicate request and returns the original result.

The standard implementation uses idempotency keys: clients include a unique identifier with each request, and the server stores the result keyed by this identifier. If the same key is seen again, the stored result is returned without re-executing the operation. This pattern is essential for any operation with side effects: payments, order creation, email sending, and resource provisioning.

For AI applications, idempotency matters when LLM calls trigger downstream actions. If a customer support agent uses AI to issue a refund, the operation must be idempotent to prevent duplicate refunds when network issues cause retries. Idempotency keys should be generated at the intent level, not the request level, ensuring that the same user action always produces the same outcome.

Related Terms