Idempotency: Making Sure a Package Isn't Delivered Twice

September 12, 2026 · Part 6 of 20

Opening Scene

A courier’s radio cuts out halfway through a delivery, and the dispatch desk, hearing nothing back, sends a second courier to the same address just in case the first one never made it. If the first courier actually did deliver the package, the smart move isn’t to hand over a duplicate — it’s to check the doorstep first, see the package already sitting there, and simply confirm the job’s done. Delivering it twice isn’t just wasteful; for some packages, a second copy actively causes harm.

In Plain English

Idempotency is the property that lets an operation be safely repeated without changing the outcome beyond the first successful application. In an event-driven system, message delivery is rarely guaranteed exactly once — networks drop acknowledgments, consumers crash mid-processing, retries fire when a message actually did succeed — so building consumers to check “have I already handled this specific event?” before acting on it again is what turns an unreliable at-least-once delivery guarantee into a system that behaves correctly regardless of how many times a message actually shows up.

The Old Way

Before idempotency was a standard design discipline for event-driven consumers:

  • Retried messages sometimes silently double-charged a customer, double-counted a metric, or double-sent a notification, with no mechanism catching the duplicate.
  • Teams often discovered the need for idempotency only after a production incident revealed a message had been processed twice, rather than designing for it up front.
  • Deduplication logic, when it existed at all, was frequently bolted on ad hoc per consumer, rather than treated as a shared, reusable pattern.

Designing consumers to be idempotent from the start is what closes that gap before it turns into an incident.

What’s Changing (and Why AI Is the Reason)

  1. Idempotency keys and deduplication windows have become a standard, expected part of consumer design in mature event-driven systems, not an afterthought bolted on after an incident.
  2. This connects to the data contracts and schema design series in this content library, since a well-defined event schema — including a stable, unique event identifier — is what makes reliable deduplication possible in the first place.
  3. AI agents that take real-world actions — placing an order, sending an email, calling a paid API — make non-idempotent retries far more consequential than a duplicate log line, since an agent retrying a failed step without idempotency protection can genuinely double a real-world action a human would never have repeated.

The Metaphor, Fully Extended

The Courier Checking the DoorstepIdempotency Concept
A second courier dispatched after losing contact with the firstA retried message sent after a missing delivery acknowledgment
Checking the doorstep before handing over a duplicate packageChecking for a prior successful process before re-acting on an event
A package that causes real harm if delivered twiceAn action — a charge, an order — that causes real harm if repeated
Confirming the job is done instead of doubling the deliveryRecognizing a duplicate event and safely no-op’ing it

For Beginners: What to Actually Do

  • Practice explaining, in plain language, why “at-least-once delivery” means a consumer might see the same message more than once.
  • Learn to recognize an idempotency key — a stable, unique identifier attached to an event — as the basic tool that makes deduplication possible.
  • Get comfortable with the habit of asking “what happens if this exact event arrives twice?” for any consumer you write.

For Practitioners and Leaders: The Deeper Layer

  • Require idempotency keys as part of your event schema standard, coordinating with the data contracts and schema design series in this content library so producers and consumers agree on the identifier up front.
  • Build deduplication as shared, reusable infrastructure rather than leaving each consumer team to invent its own approach.
  • Treat idempotency as a hard requirement, not an optimization, for any AI agent workflow that takes real-world, side-effecting actions.

Quick Recap

  • Idempotency lets an operation be safely repeated without changing the outcome beyond the first successful run.
  • Event-driven systems commonly guarantee at-least-once delivery, which means duplicates are expected, not rare.
  • A stable, unique event identifier is the basic building block that makes deduplication possible.
  • AI agents taking real-world actions raise the stakes on idempotency well beyond a duplicated log entry.

Where This Fits in the Series

Article 5 explained how the dispatch desk matches packages to couriers. Article 6 followed one of those packages to ask what happens when the same delivery gets attempted twice. Article 7 turns to the opposite failure mode — what happens when packages arrive faster than the couriers can possibly keep up, and how the dispatch desk tells them to slow down.