Review the prerequisites
Suitable for: Backend developers learning Agent applications.
- Committed effects and conditional compensation in sagas
- Compensation is another business action that may charge, fail, or be irreversible, not erase history. First confirm the positive results, and then decide whether to compensate according to the terms, dependencies and authorization. The compensation itself must also be recoverable.
How does the mechanism work?
Step-by-step explanation
- If I cancel a hotel, I will be deducted. Will the original approval cover it?
Move from deciding whether to compensate to checking the compensation action's own authorization and economic conditions.
- What should I do if the compensation request also times out?
Compensation also has a window where the remote action succeeds but remains unconfirmed locally, in addition to unknown forward-action outcomes.
- Do all compensations have to be in reverse order?
Compensation requires reasoning about dependencies, beyond simply reversing a stack of actions.
Design · Explain the trade-offs
Design integration and release boundaries
Objectives of this level: Define receipt reconciliation and compensation completion ownership.
Visual guide · Compensation starts from facts
The planner emits commands only. Unknown effects freeze compensation; completed shipment requires review. Compensation needs its own authority and receipt. Select the figure to open it at full size.
Separate the planner from the durable executor
The planner proposes actions from known facts. A durable executor records a versioned compensation intent, obtains current authorization, sends it with a stable derived compensation key, and reconciles a receipt. Keep original-operation identity and compensation-operation identity separate; this course returns the original key as a binding, not a fresh refund API key.
Define retryable versus business-rejected compensation, maximum elapsed recovery time and who owns manual escalation. A reservation that expired naturally, a shipped item and a refunded charge have different reversal semantics. A user cancellation does not erase committed effects or authorize every possible inverse.
An orchestration saga centralizes dependencies and audit; choreography distributes responsibility and requires explicit event ownership. Choose by business dependencies and operational ownership. Rehearse coordinator crash, duplicate events, refund response loss and policy change on an unfinished saga. The current exercise has no remote service or compensation execution; deployment tests are additional work, not results implied by a planner pass.
Continue the same implementation
Use the complete function contract and reproduction commands in the implementation layer. Public cases remain in cases/agent-saga-compensation.json inside the existing extended-agent-practice-v1.zip. These are local fixtures, not remote-model or production-load measurements.
code example
Design integration and release boundaries
Separate the planner from the durable executor
The planner proposes actions from known facts. A durable executor records a versioned compensation intent, obtains current authorization, sends it with a stable derived compensation key, and reconciles a receipt. Keep original-operation identity and compensation-operation identity separate; this course returns the original key as a binding, not a fresh refund API key.
Define retryable versus business-rejected compensation, maximum elapsed recovery time and who owns manual escalation. A reservation that expired naturally, a shipped item and a refunded charge have different reversal semantics. A user cancellation does not erase committed effects or authorize every possible inverse.
An orchestration saga centralizes dependencies and audit; choreography distributes responsibility and requires explicit event ownership. Choose by business dependencies and operational ownership. Rehearse coordinator crash, duplicate events, refund response loss and policy change on an unfinished saga. The current exercise has no remote service or compensation execution; deployment tests are additional work, not results implied by a planner pass.
Acceptance task for this level
Change the stated condition, predict the branch before running, and write a300-word ADR distinguishing implemented local behavior, missing integration proof and the owner of each production invariant.
Reading this browser’s record…
Hide the answer and check your understanding
Does ready mean the refund happened?
Expand reference derivation
No. It means commands are planned. The external worker, receipt and durable compensation ledger remain outside this function.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.