Skip to main content

Module tool_cache

Module tool_cache 

Source
Expand description

Tool result cache helpers.

Cache-key derivation and opt-in tool list. The actual read/write goes through crate::internal::storage::db::Database::{get,put}_cached_tool_result, which keeps the storage contract in one place.

Functionsยง

cache_key
Compute the cache key for (tool_name, input). Uses SHA-256 hex over a canonical JSON encoding.
default_ttls
Tools allowed to participate in caching, with default TTL. Expanding this list is a config decision; read-only network/tool calls are the prime candidates.
normalize_input_for_key
Normalize a JSON value so structurally-equivalent inputs produce the same cache key. Objects are key-sorted; arrays keep order. Auth context fields are removed so identical requests from different callers collide intentionally (tool cache is per-input, not per-user).