Skip to main content
Access tool execution timing with ToolCallMetrics on each ToolExecution in the run output.

Code

tool_call_metrics.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools
from rich.pretty import pprint

agent = Agent(
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[YFinanceTools()],
    markdown=True,
)

if __name__ == "__main__":
    run_output = agent.run("What is the stock price of AAPL and NVDA?")

    # Run-level metrics
    print("=" * 50)
    print("RUN METRICS")
    print("=" * 50)
    pprint(run_output.metrics)

    # Each tool call carries its own timing metrics
    print("=" * 50)
    print("TOOL CALL METRICS")
    print("=" * 50)
    if run_output.tools:
        for tool_call in run_output.tools:
            print(f"Tool: {tool_call.tool_name}")
            if tool_call.metrics:
                pprint(tool_call.metrics)
            print("-" * 40)

    # Per-model breakdown
    print("=" * 50)
    print("MODEL DETAILS")
    print("=" * 50)
    if run_output.metrics and run_output.metrics.details:
        for model_type, model_metrics_list in run_output.metrics.details.items():
            print(f"\n{model_type}:")
            for model_metric in model_metrics_list:
                pprint(model_metric)

Usage

1

Create a Python file

Create tool_call_metrics.py with the code above.
2

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate
3

Install dependencies

uv pip install -U agno openai yfinance
4

Export your OpenAI API key

export OPENAI_API_KEY="your_openai_api_key_here"
5

Run Agent

python tool_call_metrics.py