Agents that call tools over a network eventually retry a call they shouldn't have. If the tool isn't idempotent, that retry becomes a duplicate charge, a duplicate email, a duplicate order — quietly, with nothing in the logs to flag it. It's a decades-old distributed-systems problem wearing a new agent costume, and as far as I could tell, nobody had shipped a small, pip-installable fix for the agent-shaped version of it. So I built one. It's called latch. Worth saying up front: this is not a novel idea, and I'd rather say so myself than have someone point it out in the comments.
The bug, live
Here's the whole thing in one file, no library involved:
def charge_card(order_id, amount):
time.sleep(0.4) # the payment API is a little slow today






