# Tool Result Caching

> Cache expensive deterministic tool calls by their arguments — repeat calls within a session return instantly with zero API cost.

- **Category**: Agentic AI
- **Subcategory**: Tool Use & Environment
- **Canonical URL**: https://designpattern.fyi/patterns/tool_result_caching/

---

## 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.


## Use Cases
- 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.





## Trade-offs


### Advantages

- Latency drops to near-zero on cache hits.

- Cost reduction for paid APIs — immediate and measurable.




### Considerations & Drawbacks

- Stale cache hits when underlying data changes between calls.

- Non-deterministic tools (e.g., current time, live prices) cannot be cached safely.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/tool-result-caching/)

