This example shows how to enable tracing for an agent. Once tracing is enabled, all agent runs, model calls, and tool executions are automatically captured and stored in your database.
1
Create a Python file
basic_agent_tracing.py
Copy
Ask AI
from agno.agent import Agentfrom agno.db.sqlite import SqliteDbfrom agno.models.openai import OpenAIResponsesfrom agno.tools.hackernews import HackerNewsToolsfrom agno.tracing import setup_tracing# Set up database for tracesdb = SqliteDb(db_file="tmp/traces.db")# Enable tracing (call once at startup)setup_tracing(db=db)# Create agent - automatically traced!agent = Agent( name="HackerNews Agent", model=OpenAIResponses(id="gpt-5.2"), tools=[HackerNewsTools()], instructions="You are a hacker news agent. Answer questions concisely.", markdown=True, db=db,)# Run the agent - traces are captured automaticallyagent.print_response("What's trending on HackerNews?")# Query traces from the databasetraces, count = db.get_traces(agent_id=agent.id, limit=10)print(f"\nFound {count} traces for agent '{agent.name}'")for trace in traces: print(f" - {trace.name}: {trace.duration_ms}ms ({trace.status})")