Designing Idempotent Side-Effect Contracts for AI Agents
An AI agent calls send_refund. The payment provider accepts the request, but the response disappears during a network timeout. The runtime sees an exception and retries. The second request also succeeds.
The trace now looks reassuring:
send_refund attempt=1 timeoutsend_refund attempt=2 successagent run success
The customer sees two refunds. This is a synthetic example, but the failure mode is ordinary distributed-systems behavior. The agent did not need a stranger prompt or a better model. It needed a tool contract that distinguished an unsuccessful response from an unsuccessful effect.
That distinction matters anywhere an agent can change the world: sending a message, creating a ticket, issuing a credit, booking a trip, deleting a record, or triggering a deployment. If the runtime treats every exception as permission to call again, “self-healing” becomes “self-duplicating.”
A Tool Result and a Business Outcome Are Different Things
Developers often describe a tool with an input and output...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE