Team Tool Metrics
Demonstrates metrics for teams where members use tools.
Demonstrates metrics for teams where members use tools. Shows leader metrics, member metrics, and tool execution timing.
"""
Team Tool Metrics
=============================
Demonstrates metrics for teams where members use tools.
Shows leader metrics, member metrics, and tool execution timing.
"""
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.team import Team
from agno.tools.yfinance import YFinanceTools
from rich.pretty import pprint
# ---------------------------------------------------------------------------
# Create Members
# ---------------------------------------------------------------------------
stock_searcher = Agent(
name="Stock Searcher",
model=OpenAIChat(id="gpt-5.6-luna"),
role="Searches for stock information.",
tools=[YFinanceTools()],
)
# ---------------------------------------------------------------------------
# Create Team
# ---------------------------------------------------------------------------
team = Team(
name="Stock Research Team",
model=OpenAIChat(id="gpt-5.6-luna"),
members=[stock_searcher],
markdown=True,
show_members_responses=True,
store_member_responses=True,
)
# ---------------------------------------------------------------------------
# Run Team
# ---------------------------------------------------------------------------
if __name__ == "__main__":
run_output = team.run("What is the stock price of NVDA?")
# Team leader run metrics
print("=" * 50)
print("TEAM LEADER RUN METRICS")
print("=" * 50)
pprint(run_output.metrics)
# Member-level run metrics and tool calls
print("=" * 50)
print("MEMBER RUN METRICS")
print("=" * 50)
if run_output.member_responses:
for member_response in run_output.member_responses:
print(f"\nMember: {member_response.agent_name}")
print("-" * 40)
pprint(member_response.metrics)
if member_response.tools:
print(f"\nTool calls ({len(member_response.tools)}):")
for tool_call in member_response.tools:
print(f" Tool: {tool_call.tool_name}")
if tool_call.metrics:
pprint(tool_call.metrics)Example behavior
Tool timing appears only if the leader delegates and the member calls a tool. Leader and member model metrics are separate. YFinanceTools retrieves finance data; its tool duration can include the external request and local processing.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openai yfinanceExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as team_tool_metrics.py, then run:
python team_tool_metrics.pyFull source: cookbook/03_teams/22_metrics/04_team_tool_metrics.py