Durable and Asynchronous Agent Work › Summary
Michael BrenndoerferDecember 1, 20262 min read
Language AI HandbookAll chapters Long-horizon agent work is not "the same as short work but slower". Once the task outlives the process, you need explicit durability primitives, and the right mental model is an event log plus a queue plus an external-effect boundary.
- Event log, written before the side effect (write-ahead log discipline), so a crash leaves a record that a retry can consult.
- A checkpoint can store state with a consistent replay offset so recovery can read just the remaining events. This fixture replays the full log.
- Leases with a TTL let a dead worker's task be reclaimed without manual intervention. Claims are compare-and-swap transactions (
BEGIN IMMEDIATE, conditionalUPDATE,SET NX PX) so two workers can't both "win". - Fencing. Check the live lease and ownership generation inside the transaction that writes each batch of events or changes task status.
- Idempotency keys, deterministic from
(task_id, step, tool, input), turn unsafe retries into safe ones when the external service cooperates. For services that don't, order the work so non-idempotent effects are last, and plan for reconciliation and compensation. - The task budget limits claim attempts. The standalone retry helper limits calls and spaces transient retries with jitter. A permanent stub error propagates out of this runner and leaves the task running.
- An elapsed task deadline prevents the next step from starting. Bounding an in-flight operation requires a separate timeout or cancellation mechanism.
The local worker can recover committed progress only while its store remains available. Leases and fencing protect local writes, bounded retries control repeated attempts, and upstream receipts help resolve outcomes that the local log cannot establish.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!