resonate-saga-pattern-python
Installation
SKILL.md
Resonate Saga Pattern — Python
Overview
A saga is a long-running transaction split into smaller steps, each with a compensating action. Forward steps run top-to-bottom; on failure, compensations run bottom-to-top to restore consistency. Python's native try/except expresses this cleanly when the durable function uses await ctx.run(...) for each step.
For the TS version's mental model, see resonate-saga-pattern-typescript. The Python expression differs in syntax (try/except instead of try/catch, async def + await instead of function* + yield) and in how compensation lists are collected.
When to use
- Multi-step workflow where intermediate state is visible to other consumers (charge a card → create shipment)
- Each step is idempotent or inexpensive to retry individually
- Compensation logic exists for every committed step
- You need "all or nothing" consistency without a distributed transaction
Don't use when steps are a pure in-memory pipeline (use sequential ctx.run calls without compensation), or when you have access to a single DB transaction that covers all steps.