[FEATURE] Add tool result caching
Problem Statement
A tool result caching mechanism to the Strands Agent framework, allowing agents to store and reuse tool execution results for identical inputs. This improves performance and reduces unnecessary API calls or expensive computations.
Proposed Solution
- Configurable caching: Enable/disable caching with customizable max size and TTL like that.
- Selective caching: Specify which tools to cache or exclude from caching
- Cache statistics: Access hit/miss metrics through get_tool_cache_stats()
- Cache invalidation: Clear entire cache or specific tool results
Use Case
- Static Data Retrieval
- Documentation lookup tools
- Configuration data retrieval
- Static reference data queries
- Computationally Expensive Operations
- Complex calculations
- Large data processing
- Image processing operations
- Rate-Limited API Calls
- External API calls with rate limits
- Third-party service integrations
Alternatives Solutions
No response
Additional Context
No response
Hi @Konippi thanks for the suggestion here. We are currently re-working our tool execution implementation to be async-native. As to not interfere with that rework, and not add additional complexity to the tool system, I don't think this is a feature we are interested in at the moment.
Users of strands are able to accomplish this same functionality by building caching around their tools themselves. For example, the python functools.cache function accomplishes the same functionality you call out in this feature request without needing any changes to the sdk's code.
Definitely. Thank you for your opinion.