Skip to content
AX Framework
Recovery pattern

Rollback

Provide compensating actions so completed steps can be undone when a later step fails.

Problem

A task that spans several actions can fail midway, leaving a held seat with no booking, or a charge with no order. Agents cannot clean up without a defined way to undo.

Context

Use this pattern when:

  • Workflows involve multiple side effects across steps or services.
  • Some steps are reversible within a time window.

Recommended solution

For each reversible action, define a compensating action and reference it in the receipt. Within workflows, roll back completed steps automatically when the workflow is cancelled or a step fails irrecoverably, and report what was undone.

  1. 01Define compensating actions for reversible operations.
  2. 02Reference the undo action in receipts with its deadline.
  3. 03Roll back workflow steps in reverse order on failure.
  4. 04Report which compensations succeeded.

Interaction diagram

Interaction diagram for Rollback. 1. AI agent to Product · AX layer: hold_seat ✓ hold_hotel ✓. 2. AI agent to Product · AX layer: pay. 3. Product · AX layer to AI agent: payment_declined. 4. Product · AX layer to Backend service: release hotel, release seat. 5. Product · AX layer to AI agent: rolled_back: [hotel, seat].AI agentProduct · AX layerBackend servicehold_seat ✓ hold_hotel ✓1pay2payment_declined3release hotel, release seat4rolled_back: [hotel, seat]5
request response internal step

Example implementation

Illustrative example

Examples use a fictional store and illustrative field names. Adapt the shape to your stack; the qualities matter more than the exact format.

Receipt with undojson
{
  "id": "rcpt_812",
  "action": "hold_seat",
  "status": "completed",
  "effects": [{ "type": "created", "resource": "/holds/H-3321" }],
  "undo": {
    "action": "release_seat",
    "input": { "holdId": "H-3321" },
    "availableUntil": "2026-10-06T14:20:00Z"
  }
}

Accessibility and security

Accessibility

  • Offer people the same undo affordance in the UI, with the same deadline.

Security

  • Compensating actions need the same authorization as the original action.

Applies the principles Graceful Failure and Verifiable Outcomes.