Many agent tasks span systems without a shared transaction manager: create a change record, reserve capacity, issue a configuration update, and notify an operator.
A saga treats the workflow as a sequence of durable local effects with explicit compensation, not as an imaginary all-or-nothing transaction. Its goal is a comprehensible recovery path when a later step fails.
Every saga step declares a forward effect, a success receipt, a compensation effect, and the conditions under which compensation is safe. Compensation is not a universal undo button. Deleting a newly created draft may be safe; reversing a notification may require a follow-up notice; an external action may be irreversible. The runtime therefore records a compensating proposal, sends it through policy again, and preserves both receipts. A failed compensation is an incident state, not a reason to erase history.
The reference runtime keeps a saga ledger ordered by step number. It compensates completed reversible steps in reverse order only after a terminal failure decision. The ledger makes manual recovery possible: an operator can see what completed, what was attempted, which compensation is pending, and the authority required to continue. The laboratory injects a failure after a reservation and confirms that only the matching release operation runs.
Continue with the book
Explore the full treatment, worked examples, and exercises in Building Production-Grade AI Agents.
Companion article for Building Production-Grade AI Agents, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
