Lion Cipher Lab

Make an autonomous SOC agent's tool calls idempotent with a write-ahead run journal — then crash it 70 times and prove it never opened the same ticket twice

Why it matters

The first time an agent costs a company real money it is almost never because the model said something stupid. It is because something retried. A tool call timed out at the gateway and the SDK retried it; a container was rescheduled mid-run and the queue redelivered the job; a supervisor saw a non-zero exit code and started the run again from the top. The model behaved perfectly all three times. And now there are three incident tickets for one alert, the on-call has been paged three times at 3am, and a service account has been disabled twice — the second time after the first disable had…

What you'll learn

Steps in this lab

  1. The frame: a retry is not a free do-over once the call had a SIDE EFFECT
  2. Open a terminal and make a scratch folder (start here even if you never have)
  3. Build the world: five SOC tools that are deliberately NOT idempotent
  4. The incident corpus and the agent — which is a DETERMINISTIC STUB, said plainly
  5. See the damage first: one crash, one restart, two tickets
  6. The idempotency key: name the ACTION, not the ATTEMPT
  7. The write-ahead journal: atomic appends, a checksum per record, and os.replace
  8. The three-phase runner: INTENT, then EXECUTE, then RESULT
  9. Crash at every point in the sequence and read the recovery
  10. Measure it: 70 injected crashes, 40 incidents, three ways
  11. The badly-derived key, measured in both directions
  12. The honest limit: AT-LEAST-ONCE is what you can buy, EXACTLY-ONCE is not
  13. When the journal itself is the thing that breaks
  14. What the guarantee costs on the happy path
  15. When you do NOT need this — and why a journal, not the two alternatives
  16. The way a pro does it

Open the full interactive lab →