What problem does it solve?
Golem agent methods that only read state still go through the full invocation queue and agent loading, wasting resources on pure queries. This Skill shows how to mark MoonBit agent methods as read-only so Golem caches results, bypasses the queue on cache hits, and traps forbidden side effects like persistent writes, outgoing HTTP, and RPC calls.
Core Features & Use Cases
- Read-Only Annotation: Apply the
#derive.read_only attribute to any MoonBit agent method to declare it a pure read of loaded state.
- Configurable Cache Policies: Choose between
until_write (default), ttl with a nanosecond duration, or no_cache to control how long cached results stay valid.
- Automatic Per-Principal Caching: Methods taking a
Principal parameter are automatically cached per principal, with HTTP responses switching to Cache-Control: private and Vary: Authorization.
- Use Case: Expose a counter agent's
get_count method as an HTTP GET endpoint that returns instantly from cache with proper Cache-Control and ETag headers, even while a slow write is being processed.
Quick Start
Mark my MoonBit agent's get_count method as read-only with the default until-write cache policy using the derive attribute.