An idempotency key is a promise: send the same logical operation twice and the server does the work once. The standard implementation puts a client-generated key in a header, and the server stores the key with the response, replaying that response on a repeat and skipping the work (Zuplo's guide). The same reference makes the operational point that matters here: the key must be created before the first request and reused on every retry, not regenerated.
Agents break that assumption in a specific way. They pause. A run stops at an approval gate, is serialized, and resumes hours or days later, which is exactly the pattern Elastic describes when a workflow waits for a human decision and continues where it stopped (Elastic Search Labs). If the key is derived from agent context rather than stored, the resumed process derives it again. If the derivation is not perfectly deterministic, the resumed run sends a second, differently keyed request and the effect happens twice.
Three things usually cause that drift:
- Dictionary or set iteration order. In Python, string hashing is randomized per process by default, so any key built by iterating an unordered container can differ between the worker that started the run and the worker that resumed it.
- Field order in serialization.
json.dumpspreserves insertion order. Two code paths that build the same dict in different orders produce different bytes and therefore different hashes. - Ambient state. Timestamps, locale-dependent number formatting, timezone-aware date rendering, or accidental inclusion of a request id or trace id.
The reliability literature on agent tool calls names the underlying problem: real tool systems are non-atomic, and agents that cannot verify what actually happened retry into duplicate actions. A verification-aware wrapper that checks postconditions before retrying cuts duplicate actions while keeping task success comparable (Kalappurackal Mansoor et al.). Deterministic keys are the cheapest version of that idea, but only if you can prove the key function is deterministic.



