The interview problem
An external system calls back hours after a workflow task timed out and retried. Prevent the old callback from completing the new attempt.
Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.
1. Scope and worked approach
Assume callbacks authenticate the sender and carry a scoped correlation token. Persist workflow ID, step ID, attempt epoch and expected state before issuing external work. Consume a callback with an atomic state transition that checks all of them. A retry creates a new attempt token; late callbacks from old attempts are recorded but do not advance current state. Separate business-operation identity from attempt identity.
2. Trace the design or derivation
Persist attempt → dispatch token → authenticate callback → compare epoch and state → advance once
Make callback handling fast and durable: acknowledge after storing the accepted transition, then continue expensive workflow work asynchronously. If the response is lost, the sender can retry and receive the already-recorded result. A periodic reconciler handles attempts whose callback never arrives but whose external operation remains discoverable.
3. Calculate the example
Step attempt 4 expires and attempt 5 starts. A callback for attempt 4 arrives with success. Matching only workflow ID would incorrectly complete attempt 5; checking expected attempt 5 rejects the stale transition while retaining evidence of the external outcome.
4. Failure cases and trade-offs
Rejecting a stale callback does not undo an external side effect. Reconciliation or compensation may still be required. Long-lived tokens simplify integration but enlarge replay exposure; short-lived tokens require a status-query recovery path. Tokens must not be logged as ordinary debugging text.
5. Validation, follow-ups and self-review
Test duplicated, reordered and forged callbacks plus timeout-after-success. Follow-up: how do you reconcile an expired attempt that actually succeeded? Self-review: distinguish workflow advancement from external business outcome.
Sources and related practice
Technical reference: docs.aws.amazon.com — Task-token callback integration; attempt fencing is the original design exercise.
Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.
Continue with Resume long-running business workflows; Design human approval for consequential agent actions.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.