Tool Result Caching
Cache expensive deterministic tool calls by their arguments — repeat calls within a session return instantly with zero API cost.
Intent & Description
🎯 Intent
Stop paying for the same tool call multiple times in one task.
📋 Context
Your agent calls the same company profile lookup, exchange rate fetch, or immutable document read from four different sub-tasks in a single session. The tools are paid, rate-limited, or slow — and the agent has no memory of having called them before.
💡 Solution
Wrap deterministic tools in a cache keyed on (tool_name, normalised_args). Set TTLs by tool type. On cache hit, return immediately without invoking the underlying tool. Scope per-user for tools that read user data; global for read-only public data. Always include auth subject in the cache key — args-only keys leak data when callers change.
Real-world Use Case
- Agents re-call the same tool with the same arguments multiple times within a task.
- Tools are deterministic enough to cache by normalized arguments.
- TTL and per-user vs. global scoping can be defined per tool.
Source
📌 TL;DR
Cache tool results by (name, args). Same call, same session = instant return. Always scope by auth subject or you’ll leak data across users.
Advantages
- Latency drops to near-zero on cache hits.
- Cost reduction for paid APIs — immediate and measurable.
Disadvantages
- Stale cache hits when underlying data changes between calls.
- Non-deterministic tools (e.g., current time, live prices) cannot be cached safely.