The Research Report
Pinning Idempotency Keys Across Agent Retries
date: 2026-11-08
title: "Pinning Idempotency Keys Across Agent Retries"
author: Brian Taylor
Pinning Idempotency Keys Across Agent Retries
Idempotency keys make retrying a write safe: the client creates a unique key (usually a UUID), sends it in the Idempotency-Key header, and the server stores it with the response. Repeats for that key replay the original result instead of executing the write again.
Key points for agent pipelines
• Idempotency is bounded: it guarantees 'at most once' only within the key's retention window (about 24 hours in common implementations). Once expired, a reused key starts a new request.
• The race is in check-then-store. Claim the key atomically before processing (try_insert / unique constraint, 409 while in flight, 422 on a mismatched fingerprint). Replaying must be authenticated and scoped to the caller/tenant/operation.
• A local DB transaction covers at most local writes; for remote side effects (payments, external APIs) also pass the same key downstream and add a reconciliation path.
AI agents make this problem worse: they retry and resume logical writes as routine behavior. Generating a new UUID on each retry defeats deduplication because the server sees a new request. The fix is in orchestration: persist one key across retries/resumption of the same logical write.
Common mistakes
• Reusing key with changed payload (must detect and reject).
• No TTL → unbounded storage growth.
• Conflating idempotency with error handling/validation.
• Skipping atomic key claim.
• Assuming local transaction covers remote side effects.
• Leaving record unscoped to caller.
Sources
WSO2 Idempotency Keys for APIs guide; idempotent tool design references; Stripe idempotency docs.