Principle:42 evey Hermes plugins Content Addressed Caching
| Knowledge Sources | |
|---|---|
| Domains | Caching, Cost_Optimization, LLM_Delegation |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
A caching pattern that uses a content hash of the model and goal as the cache key, with time-to-live expiry and least-recently-used eviction, to avoid redundant LLM calls for recurring questions.
Description
Content-Addressed Caching reduces LLM API costs by storing delegation results keyed by a hash of the model and goal. When the same question is asked again (e.g., a daily status check), the cached result is returned instantly at zero cost.
Key design decisions:
- Cache key: SHA-256 hash of
"{model}::{goal}"(lowercased), truncated to 16 hex chars. Context is intentionally NOT included in the key — different context for the same goal returns the cached result. - TTL expiry: Entries expire after 24 hours (86400 seconds). Expired entries are evicted on save.
- LRU eviction: When the cache exceeds 100 entries, the least-recently-accessed entries are evicted first (based on
last_accessedtimestamp). - Bypass: A
bypass_cacheflag forces a fresh delegation, useful when the answer may have changed.
Usage
Use this principle for recurring LLM queries where the answer doesn't change frequently — daily status checks, repeated research topics, common questions. Not suitable for time-sensitive queries (current weather, live data) unless the TTL is short enough.
Theoretical Basis
The cache key derivation:
Failed to parse (syntax error): {\displaystyle \text{key} = \text{SHA256}(\text{model} + \text{"::"} + \text{goal})[:16] }
The LRU eviction policy: when |cache| > MAX_ENTRIES, evict entries with the oldest last_accessed time:
# Abstract algorithm (NOT real implementation)
key = sha256(f"{model}::{goal}").hexdigest()[:16]
if key in cache and (now - cache[key].cached_at) < TTL:
cache[key].hit_count += 1
cache[key].last_accessed = now
return cache[key].result # zero cost
else:
result = delegate_fresh(model, goal)
cache[key] = {result, cached_at: now, last_accessed: now, hit_count: 0}
evict_expired()
evict_lru_if_over_max()
return result
The hit count tracks how many times a cached entry has been served, and tokens_saved reports the cost avoidance.