$ lexprog.com

// notes from an old coder -- php, databases, and the occasional rant

[October 05, 2026] AI

One Tool, One Side Effect

A tool that both writes a row and sends email is hard to retry and hard to audit. Split side effects so the agent can recover mid-flight.

────────────────────────────────────────────────────────

One Tool, One Side Effect

Tip: Do not bundle mutate-and-notify

A tool that both writes a row and sends email is hard to retry and hard to audit. Split side effects so the agent can recover mid-flight.

def create_invoice(payload): ...
def notify_finance(invoice_id): ...

Gotcha: Retries double-charge the customer

If create+charge is one tool, a timeout retry charges twice. Make charge idempotent with a client key.

charge(order_id, idempotency_key=order_id)

Source: https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview

────────────────────────────────────────────────────────
<-- back to posts