What problem does it solve?
Golem agent methods that only read state still go through the full invocation queue and agent loading, and there is no built-in way to cache their results or guarantee they are side-effect free. This Skill shows how to mark Rust agent methods as read-only so Golem caches results, bypasses the invocation queue on cache hits, and traps writes, outgoing HTTP, and RPC calls with a ReadOnlyViolation error.
Core Features & Use Cases
- Read-Only Method Marking: Apply the #[read_only] attribute to agent trait methods to enforce a pure-read contract at runtime.
- Configurable Cache Policies: Choose between until_write (default), ttl with humantime durations like "30s", or no_cache for uncached pure computation.
- 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: A counter agent exposes a get_count method mapped to an HTTP GET endpoint; marking it read-only lets repeated queries return cached results instantly with proper Cache-Control and ETag headers, even while a slow write is being processed.
Quick Start
Add the #[read_only] attribute to my Rust agent's get_count method so its result is cached and served without queueing.