What problem does it solve?
When building durable Golem agents in Scala, developers need to control how external side effects (HTTP calls, payments, cross-agent calls) behave across crashes and recovery. Without proper controls, a crash between two external calls can leave systems in an inconsistent state, and non-idempotent operations may be duplicated or lost.
Core Features & Use Cases
- Atomic Blocks: Group multiple external side effects with
Guards.atomically so the entire block replays together after a crash, preventing partial execution states.
- Idempotence Mode & Keys: Control whether HTTP requests are treated as idempotent with
Guards.withIdempotenceMode, and generate durable idempotency keys via HostApi.generateIdempotencyKey for exactly-once payment operations.
- Checkpoints & Oplog Commit: Capture oplog positions with
Checkpoint and revert on failure, or wait for oplog replication with HostApi.oplogCommit before proceeding.
- Use Case: When processing an order, wrap the inventory reservation and payment charge in
Guards.atomically so that if the agent crashes between them, recovery re-runs both calls together instead of leaving a reservation without a charge.
Quick Start
Show me how to wrap an inventory reservation and payment charge in an atomic block in my Scala Golem agent so both replay together after a crash.