# Prevent repeated AI requests becoming duplicate actions

Design retry-safe workflows with operation identities, payload checks and durable outcomes, including an invoice example and a practical test matrix.

By Daltn editorial team. Published 2026-11-08.
Canonical: https://daltn.tech/feeds/idempotency-ai-workflow-retries/

## How does idempotency prevent duplicate business actions?

Idempotency makes repeated attempts at the same defined operation produce its intended effect once within the documented boundary. It depends on stable identity, durable state and clear retry behavior. Define what counts as the same request, then test concurrent retries, uncertain outcomes and key reuse before trusting duplicate protection.

## Keep these in mind

- A retry needs the original business operation identity.
- The same key with different content needs an explicit policy.
- Duplicate protection has boundaries and retention limits.

## Define the operation before defining the key

A user asks to create an invoice, then the connection drops. A second attempt may express the same request or a deliberate new invoice.

The system needs an operation identity that survives transport retries. Generating a fresh identity on every attempt defeats that purpose.

[AWS guidance on idempotent APIs](https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/) examines retry safety and caller intent. The design must distinguish repetition from a new request.

## A worked uncertain invoice creation

Consider an illustrative operation INV-REQ-84 creating an invoice for order 218. The server accepts it, but the client never receives the response.

The client retries using INV-REQ-84. The receiving service checks the stored operation and returns the existing outcome when its contract supports that behavior.

A new identifier could create a second invoice. Reconstructing identity from similar wording alone would also risk merging a genuinely new instruction.

## Read the actual service contract

[Stripe’s idempotency documentation](https://docs.stripe.com/api/idempotent_requests) describes specific behavior for its APIs. That is an implementation example, not a universal contract for every service.

Check how the target service handles parameter differences, failed execution and expired keys. API versions may also have different documented semantics.

If the receiving service offers no duplicate control, an application-side record helps but may not cover every failure window. Document the remaining uncertainty.

## Test identity and payload together

Keep a representation of the intended operation alongside the key. A repeated key with a different amount should not silently reuse the first result.

Choose a defined response for mismatches and conflicts. Support staff should be able to identify what the caller originally requested.

Attempt | Expected policy | Risk exposed
--- | --- | ---
Same key, same payload | Return or complete the original operation | Duplicate invoice creation.
Same key, changed amount | Reject or require a new explicit decision | Silent reuse of the wrong result.
Concurrent same-key requests | Coordinate through durable state | Both requests execute independently.
Retry after retention expires | Apply documented expiry behavior | Old operation repeats unexpectedly.
Timeout after acceptance | Inspect durable outcome | Unknown status treated as failure.

## Follow the action across system boundaries

A database can record that a message should be sent, while the delivery provider may return an uncertain result. Each boundary needs consideration.

If sending is retried, the provider’s identity and deduplication behavior matter. A local processed flag alone cannot prove what happened externally.

Preserve references needed for reconciliation. An unresolved outcome should remain visible until checked, rather than triggering endless blind retries.

1. Define the business operation and distinguish deliberate repeats.
1. Create and preserve a stable identity across retries.
1. Validate payload consistency with the original request.
1. Store outcomes durably at the execution boundary.
1. Test concurrent attempts and failures before and after acceptance.

## Keep recovery and observability practical

Log operation identifiers and outcome states without embedding unnecessary personal information in keys. Support should understand whether work succeeded or remains uncertain.

Monitor duplicate conflicts and unresolved operations. A growing retry count may signal a failing dependency rather than ordinary network variation.

Decide who may intentionally repeat or reverse an operation. Those actions should have new explicit business meaning.

Idempotency is a precise property of a defined operation. It does not justify an unconditional promise that a distributed workflow can never duplicate anything.

Test a deliberate repeat after the original operation has completed. The system needs to distinguish a new purchase from another delivery attempt.

Check what happens after duplicate-protection records expire. The business may still receive an old queued request.

A retention window should match documented risks. Ambiguous late arrivals need controlled recovery rather than silent execution.

## Common questions

### Is an identical message always a duplicate?

No. A customer may intentionally repeat an order. Duplicate detection needs business context and operation identity, not text similarity alone.

### Does idempotency mean exactly-once delivery?

No. Messages may arrive repeatedly while the receiving operation controls repeated effects. State the boundary and guarantees precisely.

## Sources

- [Making retries safe with idempotent APIs, AWS Builders’ Library](https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/): Supports stable caller intent and retry-safe API design.
- [Idempotent requests, Stripe API documentation](https://docs.stripe.com/api/idempotent_requests): Supports implementation-specific key and retry behavior. No universal retention window is assumed.
