How to use this tool

Agent Rollback Designer — Guide

How to build a Saga-pattern rollback flow for agent-initiated payments, what each step and compensation action does, and how to deploy the generated AWS Step Functions state machine.

What is this tool for?

When an AI agent initiates a payment, it executes a chain of steps across multiple systems — charge the card, create the order, update the ledger, send the receipt. If any step fails midway through, you need a reliable way to undo the completed steps and leave the system in a consistent state. This is the Saga pattern.

This tool lets you drag-and-drop the steps of your payment flow, assigns a compensating action to each step, and generates a complete AWS Step Functions state machine definition (JSON) with retry policies and compensation chains that you can deploy directly.


Step-by-step walkthrough

Step 1 — Name your saga
  1. Enter a Saga Name in the top field. This becomes the Step Functions state machine name and the Lambda function name prefix in the generated JSON.
  2. Use lowercase hyphen-separated names: checkout-payment-saga, refund-saga.
Step 2 — Build your step sequence
  1. Click any step template from the left panel to add it to your flow. Steps appear in the order you add them.
  2. Each step card shows its forward action and its compensating action. The compensation chain is automatic — you do not configure it separately.
  3. Drag steps to reorder them. The compensation logic updates automatically to reflect the new order.
  4. Click the × on any step to remove it from the flow.
Step 3 — Set retry policy
  1. Choose Aggressive, Balanced, or Conservative retry policy. This applies to all forward steps in the generated state machine.
  2. Compensation steps always use aggressive retries regardless of this setting — a failed compensation is a critical failure that must be retried hard.
Step 4 — Export the state machine
  1. Click Export JSON to download the Step Functions state machine definition.
  2. In the AWS Console: go to Step Functions → State Machines → Create → paste the JSON in the definition editor.
  3. Via Terraform: use aws_sfn_state_machine with definition = file("your-saga.json").
  4. Replace placeholder Lambda ARNs with your actual function ARNs before deploying.

Step templates and their compensations

Each step template has a pre-assigned compensating action. Compensations are designed to be idempotent — calling them multiple times produces the same result as calling them once.
Reserve Funds→ compensate:Release Funds
Holds funds against the customer account before the charge is captured. Compensation releases the hold.
Create Order→ compensate:Cancel Order
Creates the order record in your database. Compensation sets the order status to cancelled.
Charge Card→ compensate:Refund Card
Calls the payment gateway to capture the charge. Compensation issues a full refund via the gateway API.
Notify Bank→ compensate:Void Notification
Sends the transaction notification to the issuing bank. Compensation sends a void/reversal message.
Update Ledger→ compensate:Reverse Ledger Entry
Posts the credit to the settlement ledger. Compensation posts a debit reversal entry.
Send Receipt→ compensate:Send Cancellation Email
Emails the receipt to the customer. Compensation sends an order cancellation email.
Release Inventory→ compensate:Restore Inventory
Decrements stock count after a successful order. Compensation increments it back.
Settle Payout→ compensate:Clawback Payout
Initiates payout to the merchant. Compensation initiates a clawback (only possible if not yet settled).

Key terms

Saga patternA distributed transaction pattern where a long-running operation is broken into steps, each with a compensating action. If any step fails, compensations are executed in reverse order to restore consistency.
CompensationThe reverse operation for a completed step. Must be idempotent — safe to call multiple times. Examples: refund a charge, cancel an order, restore inventory.
IdempotentAn operation where calling it multiple times produces the same result as calling it once. Critical for compensations — Step Functions may retry them on failure.
Step FunctionsAWS service for orchestrating multi-step workflows as state machines. Each state can be a Lambda invocation, a wait, a choice, or a success/failure terminal.
waitForTaskTokenStep Functions pattern where a step pauses execution and resumes only when a specific token is returned. Used for human-approval gates in high-value payment flows.
DLQDead Letter Queue — an SQS queue that receives messages that failed to process after all retries. The generated state machine routes CompensationFailed states to an alert rather than a DLQ, but you should pair it with CloudWatch alarms.

Frequently asked questions

Ready to design your rollback flow?
Build your Saga, set your retry policy, and export a Step Functions state machine ready to deploy.