Lesson Link: Visit our Website: Lesson 16 of Building Real Agent Systems. Learn how to make durable AI agent runs safe under crashes and replays using the transactional outbox pattern and idempotency keys — so a customer never gets charged or refunded twice. In this lesson we close the gap left by durable workflows: when a worker is killed mid-send, or a finished run is replayed after the provider forgets its keys, naive retries can double-write. Relay records every owed effect (refund, reply) in an outbox first, then dispatches with a stable effect key. Replays find existing rows and write nothing new. What you’ll learn: Why provider Idempotency-Keys alone are not enough (keys expire; wording-based keys break) The outbox pattern: record intent first, deliver second Effect keys that name the business effect, not the attempt or the message text Separating finish (record) from dispatch (send) in a durable agent workflow Crash recovery after SIGKILL with the same key and provider replayed: true How direct_send and fresh_key faults expose double-refund bugs on purpose Verifying with replay drills, outbox bench, and chaos kills Built for engineers shipping production agents: refunds, support tickets, MCP tools, and workflow engines — with exactly-once effects from at-least-once delivery. #lesson16 #aiagents #outboxpattern #idempotencykeys #transactionaloutbox #durableworkflows #agentreliability #llmsystems #productionai #crashrecovery #replaysafety #mcp #softwarengineering #backenddevelopment #microservices











