Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Retrying operations that aren't idempotent card 6 of 6

Twice must equal once

A retry is safe only if doing the thing twice has the same result as doing it once. For charges, POSTs, emails and publishes, a lost reply can hide a success. Insist on one stable idempotency key per logical operation, created before the loop. Otherwise, dedup on the receiving side using a stable id and a unique constraint.
Terms on this card
idempotency key
A unique id sent with a request. The server remembers it and returns the stored result for a repeat, instead of acting again.
dedup
Short for deduplication: detecting a repeated request or message by a stable id and ignoring the extra copy.
unique constraint
A database rule rejecting a second row with the same value in a column, e.g. the same event id.
Learn this step by step on Bytewise
Lesson goal: Spot retry loops the agent wrapped around payments, POSTs, emails or queue publishes. Explain how they cause duplicates when the first attempt actually succeeded but its response was lost, and how an idempotency key or deduplication makes the retry safe. · the whole lesson