| name | slm-cache |
| description | KV cache for repeated reads — call slm_cache_get(key) first; on a miss do the expensive operation then slm_cache_set(key, value, ttl_seconds) to store it; on a hit use the returned value directly; always fail-open (hit:false on any error, never raises); saves tokens when the same file, query result, or tool output is read more than once in a session. |
| when_to_use | cache file, avoid re-reading, repeated read, cache result, cache tool output, save re-read, reuse across session, cache check, cache hit, cache miss |
| allowed-tools | slm_cache_set, slm_cache_get, Bash |
slm-cache — KV Cache for Repeated Reads (Surface B)
Purpose
When the same file, query result, or expensive tool output is needed more than once in a session, fetching it again wastes tokens and time. slm_cache_set stores a result under a stable key; slm_cache_get retrieves it on subsequent calls. The cache is agent-scoped (automatically namespaced by tenant/agent ID), TTL-bounded, and fail-open.
This is an agent-routed cache — it caches results the agent explicitly routes through SLM. It cannot cache Claude conversation turns.
Tool: slm_cache_set
slm_cache_set(
key: str, # required — cache key (max 512 chars)
value: str, # required — value to store (max 1 MB)
ttl_seconds: int = 86400, # time-to-live in seconds (default 24 h)
) -> dict
Return dict