Adding Saga Steps
Step Structure
Each saga step has:
- Name: Identifier for the step
- Agent: The agent that executes the step
- Compensate: The agent that undoes the step
Adding Steps via CLI
naos saga add-step <saga-name> <step-name> --compensate <compensation-agent>
Step Order
Steps execute in the order they're added:
naos saga add-step my-saga step-1 --compensate undo-1 # Runs first
naos saga add-step my-saga step-2 --compensate undo-2 # Runs second
naos saga add-step my-saga step-3 --compensate undo-3 # Runs third
Step Dependencies
Steps are sequential — each step runs only after the previous step succeeds:
step-1 ✓ → step-2 ✓ → step-3 ✓ → saga complete
If any step fails, compensation runs in reverse:
step-1 ✓ → step-2 ✓ → step-3 ✗
↓
undo-2 ✓ → undo-1 ✓ → saga rolled back
Steps Without Compensation
If a step doesn't need compensation (e.g., a read-only operation):
naos saga add-step my-saga read-data # No --compensate flag
Steps without compensation are skipped during rollback.