What problem does it solve?
Golem agents are durable by default, but grouping multiple external side effects (HTTP calls, payments, cross-agent calls) so they replay together after a crash requires explicit control. This Skill explains how to use the MoonBit @api package to manage atomic operations, idempotence mode, oplog commits, idempotency keys, and retry policies correctly.
Core Features & Use Cases
- Atomic Operations: Wrap two or more external side effects with
@api.with_atomic_operation (or mark_begin_operation/mark_end_operation) so recovery replays the whole group instead of resuming mid-block.
- Idempotence Mode: Understand that idempotence defaults to
true for all HTTP requests, and opt out per-call with @api.with_idempotence_mode(false, ...) for non-idempotent side effects like payments.
- Retry Policies & Durability Keys: Override retry behavior with
@api.with_retry_policy, generate durable idempotency keys via @api.generate_idempotency_key, and wait for oplog replication with @api.oplog_commit.
- Use Case: When placing an order that reserves inventory and charges a customer, wrap both external calls in an atomic block so a crash between them triggers replay of both calls rather than leaving a partial state.
Quick Start
Show me how to wrap an inventory reservation and a payment charge in an atomic operation in my MoonBit Golem agent so both replay together after a crash.