Acknowledgment precedes persistence
Detect: An accepted task disappears after restart.
Recover: Persist acceptance before acknowledging and replay durable ingress records.
Persist agent progress and effect receipts so a replacement worker can resume safely after an abrupt process or machine failure.
Crash-safe memory preserves the workflow facts needed for correct recovery after volatile process state disappears. It includes accepted inputs, state revisions, pending commands, tool receipts, and completion markers. Saving conversation text alone cannot establish whether an external operation happened before a crash.
The critical design question is the commit boundary. Durable state must precede acknowledgment, and external effects need idempotency or reconciliation when they cannot share a transaction with workflow storage. Write-ahead logging protects a database transaction under its configured durability assumptions; it does not automatically make the surrounding distributed workflow exactly once.
A prototype should survive a forced process kill between two tool calls without losing the accepted task.
Production persists revisions and effect identifiers, coordinates queue acknowledgment with durable commits, and tests duplicate delivery.
Enterprise scale defines recovery point and recovery time objectives, replication behavior, backup restoration, and schema compatibility for old unfinished workflows.
Stores workflow revisions and committed task progress.
Records intended external work in the same transaction as its originating state change.
Associates tool results with stable operation identifiers.
Acquires a lease and reconstructs pending work after failure.
Provides recoverable history beyond a single running database instance.
sequenceDiagram
participant W as Agent worker
participant D as Durable database
participant T as Tool service
participant R as Recovery worker
W->>D: Commit state and command intent
W->>T: Execute with operation key
T-->>W: Receipt
W->>D: Commit receipt and progress
R->>D: Read pending commands after crash
R->>T: Reconcile operation key
T-->>R: Existing outcomestateDiagram-v2
[*] --> IntentCommitted
IntentCommitted --> EffectSubmitted
EffectSubmitted --> ReceiptCommitted: Result persisted
EffectSubmitted --> OutcomeUnknown: Worker crashes
OutcomeUnknown --> Reconciling: Recovery lease acquired
Reconciling --> ReceiptCommitted: Existing effect found
Reconciling --> IntentCommitted: Safe retry established
Reconciling --> HumanReview: External outcome unresolved
ReceiptCommitted --> [*]Commit the task identifier and initial state before acknowledging receipt to the caller.
Write the next state and tool command together using a transaction or equivalent atomic boundary.
Deliver the command with a stable idempotency key and retain its external receipt.
Persist validated results and mark the command complete before advancing the workflow.
A replacement worker acquires a fenced lease and reads the last committed revision.
Reconcile incomplete commands against external receipts before deciding whether execution may repeat.
Banking operations · Illustrative enterprise scenario, not a reported customer outcome.
An internal agent verifies supporting documents and submits approved account-maintenance requests.
A worker can crash after submission but before recording the response.
Recover the review without submitting the maintenance request twice.
The workflow database stores command intent, a stable case key, and the maintenance-system receipt.
If the external system cannot identify the submission, the case pauses for reconciliation instead of assuming failure.
Measure recovered task completeness, duplicate-effect incidents, and reconciliation age; memory durability is useful only when business effects remain coherent.
| Decision | Benefit | Cost |
|---|---|---|
| Synchronous durable commit | Reduces acknowledged-progress loss. | Adds write latency to each boundary. |
| Checkpoint batching | Improves write throughput. | Increases replay distance and possible unacknowledged work. |
| Replicated storage | Improves resilience to node loss. | Requires explicit consistency and failover assumptions. |
Detect: An accepted task disappears after restart.
Recover: Persist acceptance before acknowledging and replay durable ingress records.
Detect: Two workers attempt the same revision.
Recover: Reject stale fencing tokens and reconcile any external effects.
Store workflow state, tool intent, and effect receipts.
Design idempotency and reconciliation across the external boundary.
Inject kills at every commit boundary and inspect recovered invariants.