01_basic_agent_tracing.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code above as
01_basic_agent_tracing.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Enable tracing on AgentOS to record every run of a HackerNews agent in SQLite.
"""
Traces with AgentOS
Requirements:
uv pip install agno opentelemetry-api opentelemetry-sdk openinference-instrumentation-agno
"""
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.tools.hackernews import HackerNewsTools
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# Set up database
db = SqliteDb(db_file="tmp/traces.db")
agent = Agent(
name="HackerNews Agent",
model=OpenAIChat(id="gpt-5.2"),
tools=[HackerNewsTools()],
instructions="You are a hacker news agent. Answer questions concisely.",
markdown=True,
db=db,
)
# Setup our AgentOS app
agent_os = AgentOS(
description="Example app for tracing HackerNews",
agents=[agent],
tracing=True,
)
app = agent_os.get_app()
# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent_os.serve(app="01_basic_agent_tracing:app", reload=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U "agno[os]" openai
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
01_basic_agent_tracing.py, then run:python 01_basic_agent_tracing.py
Was this page helpful?