Copy
Ask AI
"""
Cache Tool Calls
=============================
Demonstrates cache tool calls.
"""
import asyncio
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.websearch import WebSearchTools
from agno.tools.yfinance import YFinanceTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[WebSearchTools(), YFinanceTools(cache_results=True)],
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
asyncio.run(
agent.aprint_response(
"What is the current stock price of AAPL and latest news on 'Apple'?",
markdown=True,
)
)
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools/other
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python cache_tool_calls.py