Skip to content
Glossary

Saga Pattern (for AI Agents)

The saga pattern is a way to manage multi-step agent workflows so that if a later step fails, earlier steps are undone through compensating actions — keeping the system consistent without a single distributed transaction.

Definition

The saga pattern is a way to manage multi-step agent workflows so that if a later step fails, earlier steps are undone through compensating actions — keeping the system consistent without a single distributed transaction.

Why agents need sagas

Agent tasks rarely complete in one action. An agent might reserve a resource, modify a record, and then notify a downstream system. If the third step fails, the first two have already taken real-world effect — and there is no database transaction spanning all of them to roll back. The saga pattern handles this by pairing each forward step with a compensating action: an explicit undo that reverses the step's effect. On partial failure, the workflow runs the compensations in reverse order to restore consistency.

Sagas in the workflow engine

Cordum's workflow engine executes multi-step DAGs with retries, timeouts, and approvals, and supports compensation so a partially completed run can be cleanly unwound. Each step's compensation is the paired undo action, and the run timeline records what executed and what was compensated. This matters for governance: when an agent's multi-step operation fails midway, the saga pattern is what prevents the system from being left in a corrupt, half-applied state.

Frequently asked questions

How is a saga different from a database transaction?

A database transaction commits or rolls back atomically within one system. A saga coordinates steps across multiple systems that cannot share a transaction, achieving consistency by running compensating actions to undo completed steps when a later one fails.

What is a compensating action?

It is the explicit undo paired with a forward step — for example, releasing a resource that an earlier step reserved. When a saga fails partway, it runs the compensations in reverse to return the system to a consistent state.

Related reading

Govern your AI agents with Cordum

Cordum is the agent control plane: policy-before-dispatch enforcement, human approvals, and a tamper-evident audit trail for autonomous AI agents.