Compensation Receipts for AI Agent Recovery
An AI agent cannot roll back an email, a payment, a deployment, and a permission change with one magic verb. Once an external effect commits, recovery is another operation with its own authority, failure modes, and evidence.
I want agent runtimes to stop recording rolled_back: true. That boolean compresses several different realities into one comforting word. A database row may have been restored while a notification remains delivered. A refund may have completed while fees remain. A deployment may have returned to an earlier image while data written under the new schema still exists.
The useful artifact is not a rollback flag. It is a compensation receipt: a structured account of which original effect was offset, what counter-action ran, what it could not undo, and how the resulting state was verified.
Compensation is forward execution
A local database transaction can often abort before commit. A distributed agent workflow usually cannot. It crosses APIs, queues, repositories, payment systems, deployment controllers, and human communication. Each participant commits independently.
The Saga pattern handles this by pairing completed steps with compensating transactions. The important word is transaction, not undo. Microsoft’s architecture guidance is explicit: compensation is application-specific, can fail, may run in a different order, and does not necessarily return data to its starting state. Temporal makes the same operational distinction: compensation functions must be registered and executed as durable workflow steps.
That changes the runtime model:
original effect -> observed consequence -> compensation decision
-> compensating effect -> verification -> residual state
There is no jump back in time. There is only a new path toward an acceptable state.
This extends my reversibility map, which classifies what an action can leave behind. The map answers whether compensation is possible. The receipt answers whether a particular compensation actually happened and what remained afterward.
A compensation receipt
I would make the recovery artifact small enough to inspect and strict enough to reject vague success:
{
"compensation_id": "cmp_8d13",
"original_effect_id": "deploy:payments:r184",
"original_receipt_hash": "sha256:...",
"trigger": "post_deploy_validation_failed",
"decision_authority": "policy:release-recovery/v4",
"counter_action": {
"type": "deploy_previous_image",
"target": "payments-production",
"artifact": "image@sha256:...",
"idempotency_key": "cmp_8d13"
},
"preconditions": {
"current_revision": "r184",
"schema_compatible": true
},
"result": {
"status": "compensated_with_residue",
"result_revision": "r185",
"verified_by": ["health_probe", "error_budget_probe"]
},
"residual_effects": [
"requests_served_by_r184",
"new_schema_rows_require_review"
]
}
Several fields matter more than the label.
original_effect_id and original_receipt_hash prevent compensation from floating free of the exact operation it is meant to offset. trigger preserves why recovery began. decision_authority proves that the counter-action was authorized; a failed step does not automatically grant unlimited repair rights. Preconditions protect concurrent work from a stale recovery plan. The result records a new revision rather than pretending the previous revision never existed. Finally, residual_effects states the part that automation could not erase.
A receipt with an empty residue list is a claim, not a default. The verifier must earn it.
Register compensation before the effect
The most dangerous time to invent recovery logic is after the original action has already failed.
Temporal documents a subtle ordering rule: register the compensation before executing the corresponding activity. An activity can produce its external effect and then time out or lose its response. If the workflow records the counter-action only after receiving success, the effect may exist without any registered recovery path.
For an agent runtime, I would model each compensatable step like this:
1. bind compensation template to the proposed effect
2. validate authority and required recovery inputs
3. persist both identities
4. execute the original effect
5. reconcile its outcome
6. activate compensation only if policy selects it
The template is not permission to execute. It is proof that the system knows the available counter-action before crossing the boundary.
This also depends on stable effect identity. When the original call times out, the runtime must first determine whether the effect happened. Otherwise it may compensate a nonexistent action or retry an action that already committed. The recent article on unknown tool outcomes handles that ambiguity; compensation begins only after reconciliation identifies what state actually needs repair.
Recovery authority must be narrower than failure panic
Failure often causes systems to become more permissive. A normal deployment path is tightly scoped, while the emergency path receives broad credentials and a command named rollback.
That is backwards. Compensation is another consequential effect. It needs a target, bounded operations, current preconditions, an expiry, and an accountable decision source. A refund should not authorize arbitrary payments. Revoking one grant should not authorize deleting every identity. Restoring one configuration should not overwrite unrelated concurrent changes.
I separate three decisions:
| Decision | Runtime question |
|---|---|
| reconcile | What effect actually committed? |
| compensate | Which counter-action is currently authorized? |
| verify | Which invariants prove an acceptable resulting state? |
A model may propose answers. It should not collapse the three into one tool call.
The split is especially important when compensation itself fails. Retrying can be valid when the counter-action has a stable idempotency key and the target confirms duplicate suppression. Otherwise the runtime needs another unknown outcome state and another reconciliation pass. “Recovery mode” is not an exception to normal reliability rules.
The receipt needs a residue section
Many recovery dashboards end when the counter-action returns 200 OK. That proves transport success, not restoration.
I want verification against domain invariants and an explicit residue classification:
none_observed— declared invariants pass and no known residue remains;bounded— known residue exists but lies within an accepted policy boundary;requires_follow_up— the system is stable, but repair work remains;irreversible— part of the consequence cannot be technically removed;unknown— verification is incomplete, so the workflow must not claim recovery.
Consider a public article publication. Restoring the previous site version may remove the page, but feeds, notifications, search caches, and third-party copies can remain. The compensation receipt should say so. The same principle applies to revoked credentials that may have been copied, deleted data restored from a backup with a recovery-point gap, or a customer message followed by a correction.
This is not pessimism. It is the difference between service recovery and historical erasure.
When a receipt is unnecessary
Not every failed computation needs this machinery. A discarded draft, an isolated test, or a read-only query has no durable external effect to compensate. A genuinely atomic operation that aborts before commit already has a stronger boundary.
Compensation receipts are useful when work spans independently committing systems, when a counter-action has business meaning, or when recovery can leave visible residue. They do not make an irreversible action reversible. They do not prove that the compensation policy is correct. They require participating services to expose enough identity and state for reconciliation and verification.
There is another hard boundary: some effects should be prevented rather than compensated. Credential disclosure, destructive operations without backups, and externally binding communication may have no adequate counter-action. In those cases, the receipt can document residue after an incident, but it cannot justify granting the original authority.
Recovery should produce evidence, not relief
I build AI systems around a simple distinction: the model can propose a recovery, but the runtime must prove what the recovery changed.
A rollback promise hides history. A compensation receipt preserves it. It joins the original effect, the recovery authority, the counter-action, the resulting revision, the verification signals, and the consequences that remain.
That record is useful during execution, not only during audit. It prevents stale compensation, protects concurrent changes, supports safe retries, and stops a green dashboard from declaring a reality that the system never restored.
Agents will make distributed workflows more dynamic. That makes compensation more important—and the word rollback less trustworthy.