feat: add opt-in ToolCache for caching tool results in Agent loops - #12516
feat: add opt-in ToolCache for caching tool results in Agent loops#12516lorenzozanee wants to merge 1 commit into
Conversation
Fixes deepset-ai#11588 by adding a small opt-in cache layer around Agent tool invocation. Tools opt in via Tool(cacheable=True); when an Agent is constructed with ToolCache, identical (tool_name, args) calls within TTL are served from cache and counts are exposed via tool_cache_stats.
|
@lorenzozanee is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
|
|
Hi @lorenzozanee, thanks for your interest in contributing to Haystack! 🙏 This is an automated message to help us keep the review queue healthy. |
|
Hi @lorenzozanee, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
Related Issues
Proposed Changes:
Agent loops re-executed identical read-only tool calls with the same arguments. Add opt-in
ToolCachewithTool(cacheable=True)so identical calls within TTL are served from cache.How did you test it?
Added unit and integration tests for cache hit/miss, TTL and Agent integration; updated serialization expectations.
Notes for the reviewer
No breaking change —
cacheabledefaults tofalseandtool_cachedefaults toNone. Reviewers: @julian-risch @sjrl @lorenzozaneeChecklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.