Compensating Action
Pair every irreversible-looking agent action with a compensating action that can undo or counteract it.
Intent & Description
🎯 Intent
Pair every irreversible-looking agent action with a compensating action that can undo or counteract it.
📋 Context
An agent is executing a multi-step plan that writes to several systems in sequence — book a flight, then a hotel, then a car, or charge a card, then provision an account, then send a welcome email. Each step succeeds or fails independently, and the agent is operating across services that have no shared transactional boundary. Some of the early steps will have already landed in the real world by the time a later step fails.
💡 Solution
For each forward action, define a compensating action (delete-after-create, refund-after-charge, archive-after-publish). On failure mid-plan, run compensators in reverse order to restore the prior state. Idempotent compensators.
Real-world Use Case
- Agent actions are irreversible-looking and distributed transactions are unavailable.
- For each forward action a meaningful undo (delete-after-create, refund-after-charge) can be defined.
- Compensators can be made idempotent so retrying them is safe.
Source
Advantages
- Partial-failure consistency.
- Confidence to attempt multi-step writes.
Disadvantages
- Doubles the number of action implementations.
- Some actions cannot truly be compensated (sent emails, public posts).