Undoing an AI workflow requires knowing which effects occurred and which can be reversed. A failed final step does not make earlier external writes disappear, and deleting records blindly can create a second incident.
Rollback and compensation are different mechanisms
A database rollback aborts uncommitted changes within a transaction. Compensation performs new business actions to counter effects that already committed, often across separate systems. Voice workflows commonly need the latter when bookings, notifications, and external records are involved.
For a proposed design, define compensation beside each forward step. Record the resource created, its current version, the authorised reversal, and any conditions that make reversal unsafe. Some steps, such as sending an email, cannot be unsent; their recovery may require a correction message rather than deletion.
Keep compensation state durable. A worker restart during recovery should not repeat a refund or cancellation without duplicate protection. Treat the reversal as a consequential operation with its own permissions and evidence.
Examine a fictional failed package
A workflow reserves an appointment and then attempts to collect a required deposit. The deposit is rejected. Whether the reservation should be released depends on the business policy: it might be cancelled immediately, held temporarily, or sent to staff review.
Suppose staff already moved the reservation before the compensation job runs. The job should check the current record version and avoid cancelling the employee’s newer arrangement. A stale compensation plan should become a review item rather than override subsequent work.
| Failure boundary | Recovery to test |
|---|---|
| Write not committed | Ordinary transaction rollback where supported |
| Reservation committed, payment rejected | Apply the approved reservation policy |
| Correction email already sent | Record the irreversible communication effect |
| Compensation response lost | Reconcile before repeating reversal |
| Staff changed the record | Stop automatic stale compensation |
The test fixture should show both final records and the ordered operation history. A clean-looking final screen can hide a duplicated financial effect or an inappropriate cancellation.
Define who owns residual work
Automatic compensation can reduce manual cleanup but cannot handle every domain exception. Assign an operational owner for failed or unsafe reversals. Surface the original request, completed steps, attempted compensations, and unresolved consequences together.
A long compensation chain may be harder to reason about than a simpler workflow with a clear commitment boundary. Before adding reversal logic, ask whether the irreversible step can happen later, after the prerequisites are established.
This is a proposed recovery design. The voice integration case study describes relevant workflow experience. Read partial-success handling before deciding that every failure requires reversal.
Workflow rollback FAQ
Can a sent notification be rolled back?
No. You may need an authorised correction, with the original communication retained as an event.
Should compensation bypass normal permissions?
No. Recovery actions need explicit authority and auditing.
What if compensation also fails?
Persist the unresolved state, stop unsafe repetition, and route the case to a named operational owner with the full action history.