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 1 of 6
Checkout now 'survives' payment timeouts
You asked the agent to stop checkout failing when the payment provider times out. The diff wraps `pay.charge()` in a three-attempt retry loop with backoff. A new test makes the first call time out and the second succeed. Everything is green, and the summary says checkout is now "resilient to transient errors". Do you approve?
Terms on this card
- backoff
- Waiting a little longer before each new retry, e.g. 1s, 2s, 4s, so a struggling service isn't hammered.
- retry loop
- Code that repeats a failing operation a set number of times before giving up.
- the agent
- The AI coding system doing the work: a chat assistant, IDE agent or terminal agent.
- diff
- The set of line changes between two versions of the code: removed lines start with '-', added lines with '+'.
- green
- A test or check that passes.
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