---
title: "Rollback Behavior"
description: "When a saga step fails, compensation actions run in reverse order to undo all completed steps. Compensations always run in reverse order of the original steps: What happens if a compensation itself fails? Nexus retries t"
resource: https://www.aiagents.nexus/docs/manual/sagas/rollback-behavior
generated: { by: "process:nexus-agent-assets", at: 2026-09-07T09:13:03Z }
status: stable
---

# Saga Rollback Behavior

When a saga step fails, compensation actions run in reverse order to undo all completed steps.

## Rollback Order

Compensations always run in reverse order of the original steps:

```
Forward:  Step 1 → Step 2 → Step 3 → Step 4 (fails)
Rollback: Comp 3 → Comp 2 → Comp 1
```

## Compensation Failures

What happens if a compensation itself fails?

```
Forward:  Step 1 ✓ → Step 2 ✓ → Step 3 ✗
Rollback: Comp 2 ✗ (compensation failed!)
```

Nexus retries the failed compensation up to 3 times. If it still fails:
1. The saga is marked as `compensation_failed`
2. An alert is generated
3. Manual intervention is required

## Manual Resolution

```bash
# Check saga status
naos saga status order-fulfillment

# Retry failed compensation
naos saga retry-compensation order-fulfillment --step 2

# Force mark as resolved
naos saga resolve order-fulfillment --step 2
```

## Partial Rollback

If only some compensations fail, the saga tracks which steps were successfully compensated:

```bash
naos saga status order-fulfillment

# Steps:
#   1. reserve-inventory   ✓ completed  ✓ compensated
#   2. charge-payment      ✓ completed  ✗ compensation failed
#   3. ship-order          ✗ failed
```
