LLMs, GenAI, RAG, agents, evaluation · insight-1560
Record the undo step for every write and place irreversible steps last
- Evidence type
- documented fact
- Difficulty
- hard
- Roles
- ML engineer, Applied AI
- Industries
- aviation, e-commerce
Summary: situation, action, reason, boundary
Situation
An agent must perform a sequence of writes, such as hold a seat, charge a fee and send a confirmation, and a later step may fail.
Action
For each write tool, define its compensating action up front, log the step and its undo as it runs, order steps so the irreversible one, such as the notification, comes only after validations, and run the undos in reverse on failure.
Reason
The compensating transaction pattern records each step and how to undo it, notes that compensation is application specific and may not restore the original state, and advises placing irreversible steps after critical validations.
Boundary
Multi-step agent actions across several systems.
Symptom or risk
A failure midway leaves a held seat or a charge with no confirmation, and no record exists of how to clean up.
Exceptions
A single atomic write needs no compensation.
Trade-offs
Writing undo logic doubles tool design effort, and some actions have no clean undo.
Pitfalls
Undo steps that are not themselves idempotent and resumable.
Lessons and concepts
Claims and their sources
Microsoft's compensating transaction pattern records each step and how to undo it, says compensation need not restore the exact prior state, and recommends defining points of no return and placing irreversible steps after critical validations.