Tool Result Caching
Cache tool results to reduce repeated API calls and improve performance.
Tool result caching is designed to avoid unnecessary recomputation by storing the results of function calls on disk. This is useful during development and testing to speed up the development process, avoid rate limiting, and reduce costs.
✓
This is supported for all Kern Toolkits
On Toolkit
Pass cache_results=True to the Toolkit constructor to enable caching for that Toolkit.
1import asyncio23from kern.agent import Agent4from kern.models.openai import OpenAIResponses5from kern.tools.hackernews import HackerNewsTools6from kern.tools.yfinance import YFinanceTools78agent = Agent(9 model=OpenAIResponses(id="gpt-5.2"),10 tools=[HackerNewsTools(cache_results=True), YFinanceTools(cache_results=True)],11)1213asyncio.run(14 agent.aprint_response(15 "What is the current stock price of AAPL and top stories on HackerNews?",16 markdown=True,17 )18)On @tool
Pass cache_results=True to the @tool decorator to enable caching for that tool.
1from kern.tools import tool23@tool(cache_results=True)4def get_stock_price(ticker: str) -> str:5 """Get the current stock price of a given ticker"""67 # ... Long running operation89 return f"The current stock price of {ticker} is 100"