Tool Result Caching

Cache tool results to reduce repeated API calls and improve performance.

Before running the examples:

pip install agno openai yfinance
export OPENAI_API_KEY="your-api-key"

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 Agno Toolkits

On Toolkit

Pass cache_results=True to the Toolkit constructor to enable caching for that Toolkit.

cache_tool_calls.py
import asyncio

from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    tools=[HackerNewsTools(cache_results=True), YFinanceTools(cache_results=True)],
)

asyncio.run(
    agent.aprint_response(
        "What is the current stock price of AAPL and top stories on HackerNews?",
        markdown=True,
    )
)

On @tool

Pass cache_results=True to the @tool decorator to enable caching for that tool.

cache_tool_calls.py
from agno.tools import tool

@tool(cache_results=True)
def get_stock_price(ticker: str) -> str:
    """Get the current stock price of a given ticker"""

    # ... Long running operation

    return f"The current stock price of {ticker} is 100"

Cache behavior

The default cache TTL is 3,600 seconds. Files are stored under the system temporary directory at agno_cache/functions; set cache_dir and cache_ttl on the tool or toolkit to change them. Cache hits still run pre-hooks, wrapping tool hooks, and post-hooks.

Cache pure reads whose result is determined by their arguments. With an injected run_context, user and session IDs also scope entries, but mutable state, dependencies, metadata, and knowledge filters do not. An injected Agent or Team does not add those identity fields to the key. Leave caching disabled when results depend on those values, or explicitly include the relevant values in the tool arguments. Tools carrying injected media and generator results bypass caching.