What is a compensating transaction?

Definition

A compensating transaction does not erase history. It performs a new, recorded action intended to restore an acceptable state, such as reversing a reservation, reactivating a record, or applying an offsetting update.

Agent workflows can generate compensation instructions alongside the original action, but the two should remain distinct and independently validated. Compensation may also fail, so its execution needs state, retries, and escalation.

ELI5

A compensating transaction is a new action that counteracts an earlier completed action when the original cannot simply be erased. It preserves history while moving the system back toward an acceptable state.

For example, if a booking has already been confirmed, compensation might create a separate cancellation and refund instead of deleting the original booking record. The compensating action also needs checks because it can fail.

How is a compensating transaction different from rollback?

Rollback restores uncommitted local work, while compensation is a new durable operation that counteracts an action already completed elsewhere.

Why are compensating transactions useful for agents?

Agents often operate across services without one shared transaction, so compensation provides a controlled recovery path after partial completion.

  1. K谩roly Zsolnai-Feh茅r beside the words AI Rewrites Its Own Tools
  2. Salman Munaf beside the headline Bound Observe Recover in true white and attention blue
Definition card for compensating transaction: What is a compensating transaction?

A compensating transaction is a separate operation that counteracts the effects of an earlier completed operation when direct rollback is unavailable.