Durable Agent Workflows Need Idempotency Before They Need Checkpoints

https://hackernoon.imgix.net/images/RNIFtsQrHaM2E4rvZipm6j1oZlz1-m383btx.png

Checkpointing is an easy feature to sell:

If the agent crashes, it resumes where it left off.

That sentence is reassuring and incomplete.

A workflow engine can restore its own state. It cannot atomically restore the external world. Between “call the refund API” and “save the successful checkpoint,” the refund may succeed, the acknowledgement may disappear, and the worker may die.

On resume, the workflow sees no recorded success. It calls the API again.

Congratulations: the agent is durable enough to duplicate damage.

The first production requirement for a resumable workflow is not persistence. It is safe repetition.

The Effect Gap

Consider this node:

def refund_node(state): receipt = payments.refund(state.order_id, state.amount) return {"refund_receipt": receipt}

There are at least four outcomes:

  1. the refund fails and the node records failure;
  2. the refund succeeds and the checkpoint records the receipt;
  3. the refund never reaches the service;
  4. the refund succeeds, but the worker dies before...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE

Read more