Spot the idempotency violation in this agent retry logic
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Click any words you think contain an error. Click again to unmark.
The loop retries every tool blindly, so a non-idempotent side effect like charge or send fires once per attempt. The fix is an idempotency key giving at most once semantics.
Imagine you press the elevator button and nothing seems to happen. So you press it again, and again. With an elevator that is fine, because the button is idempotent: ten presses summon one elevator. But now imagine the button is a vending machine that charges your card on every push. The first push worked, the screen just froze before it could tell you. Press again and you pay twice. This code is the second machine. It retries the tool three times whenever the result does not say success, including when the action already happened but the reply got lost. For a charge or an email, that means duplicate charges and duplicate emails. The safe fix is to give each request a unique ticket number so the machine recognises the repeat and refuses to charge you twice.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name the bug as a missing idempotency guard, explain why a lost response makes a succeeded call look failed, separate transient from permanent error classification, describe how an idempotency key yields at most once effects over at least once delivery, and close with the compounding agent and tool retry interaction plus circuit breakers.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming a failed result means the side effect did not happen. A timeout or lost response can hide a tool call that already charged the card or sent the email.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.