How it works
A second call is safe when it does not add a second effect. A read of a bin quantity returns the same count. A create that requires an idempotency key returns the original receipt when that key was already accepted, including when the first response was lost. The harness stores the key with the attempt and sends it again after a timeout. The tool is labelled safe to retry only if the server honours that key.
A customer email, a card capture, or a ledger post without a key is a different class. A timeout means the outcome is unknown, not that the effect failed to happen. Retrying can emit two emails and two receipts. Those tools should be labelled not safe to retry. After a timeout the loop should read back the receipt by purchase order, or ask the person, before posting again. An unlabelled send turns one timeout into repeated posts.
A worked example
A cycle count retried, a receipt posted twice
Bin read, labelled idempotent. Harness calls get_cycle_count {"bin":"A14"}. The socket times out at the client. The server had returned {"bin":"A14","qty":42} and the packet was lost. Retry with the same arguments returns {"bin":"A14","qty":42}. No second count was written. The retry was safe.
Goods receipt, not labelled idempotent. Harness calls post_goods_receipt {"po":"PO-441"} with no key. The server creates receipt R-19 and emails the buyer, then the client times out before reading the response. The harness treats the timeout as a failed call and posts again. The server creates R-20 and sends a second email.
A keyed variant, post_goods_receipt {"po":"PO-441","idempotency_key":"PO-441-attempt-1"}, returns R-19 on the second post and does not send another email. The same timeout, with a key the server stores, keeps one receipt.
Illustrative example, not a production trace and not a measured result.
What goes wrong
- The client retries every timeout, including send_email and capture_payment. Transient network loss becomes duplicate mail and duplicate charges, and one purchase order then has two receipt ids.
- The harness generates a new idempotency key on the retry, so the server treats the second post as a new receipt. The key has to be stable for the attempt.
- A tool is labelled safe because it is named get_, but the handler increments a view counter and triggers a webhook. The name is not the behaviour.
How to measure it
Maintain the label on each tool: safe to retry, or not, and whether a key is required. Count retries of tools that are not safe, and count distinct side effects per key. Two receipt ids for one purchase order is the failure mode, even when both posts returned 200.
In the conversation, two emails or a buyer saying the receipt arrived twice is the signal that lines up with those duplicate ids. A retried bin read that returns the same quantity is the control case, and it should not be graded as a double effect.
Further reading
How Abracadabra helps
A buyer who says the goods-receipt email for PO-441 arrived twice is showing a retry of a post that was not safe to run again after the first call timed out.
Tool events are searchable even when the person never wrote a complaint. Abracadabra keeps the task outcome next to those calls, because a tool can return success while the task is unfinished. MCP analytics, which would group calls by server and tool, is in early access.
Request access to read this on your own agent.