The three failure positions
- Before the write: nothing happened; retry is safe.
- After the write, before the response: the change landed; a naive retry duplicates it.
- Partially through a sequence: some steps applied; retry must resume, not restart.
How idempotency keys solve the middle case
The caller supplies a key with the mutation. The server records the key with the result. A second call with the same key returns the stored result instead of performing the work again. The ambiguous timeout stops mattering, because the retry converges on the same outcome.
Errors have to be legible
A raw internal error tells an assistant nothing. A typed payload — what failed, whether it is retryable, and a correlation identifier — lets it either retry safely or report accurately to a person. Turning opaque transport failures into typed responses is part of building an agent surface, not a nicety.