by Samy (Kondasamy Jayaraman)

Module 65 · Undo for agents

Advanced

When step four fails, run back down the hill

Give every step an opposite step, and do the step you can’t undo last. Here a cable car climbs four stations of a return, and runs back down undoing them when the courier fails.

Read as
...

The whole idea in one example

One courier failure, two orders

Email third

follow-up

2 letters

Ana gets an email promising a pickup, then a second one taking it back.

Email last

never sent

0 letters

The failure comes first, so no email goes out at all.

A hand-written example run: Ana’s return, the bank and QuickPost are made up, and each failure is injected by hand.

How it works

Three ideas carry the module

  1. ...

    1 Halfway done

    Three steps went through, the fourth failed

    Garcia-Molina and Salem (1987): the steps of a saga belong together, so any half-finished run is undesirable and must be compensated for.

    Source, checked 3 November 2026

  2. ...

    2 The opposite step

    The car runs back down, undoing newest first

    Garcia-Molina and Salem (1987): a saga ends either with every step done, or with the steps done so far and then their compensating steps, newest first.

    Source, checked 3 November 2026

  3. ...

    3 The risky step last

    With the post box at the top, a failure never reaches it

    Garcia-Molina and Salem (1987): when a saga’s last step also ends the saga, that last step needs no compensating step at all.

    Source, checked 3 November 2026

The story

Larkspur’s hillside of steps

Larkspur Supply Co.’s assistant handles a return in four steps on a hillside funicular, and learns to undo them when the courier booking fails. You decide each step’s opposite and the order they run in. Ana Ruiz’s cordless drill goes back on the shelf, her $89 is refunded, she is emailed, and QuickPost is booked to collect it.

4
stations on the hill, one per step of Ana’s return
$89
refunded, then charged back when the courier fails
20
hand-written failures on the workbench
12
setups that survive all of them

Your path

The chapters

  1. Chapter 1

    Halfway done

    When step four fails after three went through, where does the return stand?

  2. Chapter 2

    Save points

    How does a restart know which steps already happened?

  3. Chapter 3

    The opposite step

    What undoes a step, and in what order do the undos run?

  4. Chapter 4

    Some things can’t be undone

    What do you do about a step that has no opposite?

  5. Chapter 5

    Do the risky step last

    Where in the order should the step you can’t undo go?

  6. Chapter 6

    Only once

    How do you retry a step without doing it twice?

  7. Chapter 7

    Workbench: twenty failures

    Which order, opposites, save points and key survive twenty failures?

Who it’s for

  • Engineers
  • Product managers
  • Analysts
  • No code needed

Anyone whose assistant acts on other systems in several steps. The Agents and Queues modules first help; no maths is needed.