Copy
Ask AI
"""
Traces with AgentOS
Requirements:
uv pip install agno opentelemetry-api opentelemetry-sdk openinference-instrumentation-agno
"""
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.tools.hackernews import HackerNewsTools
# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------
# Set up database
db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")
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="basic_agent_with_postgresdb:app", reload=True)
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/05_agent_os/tracing/dbs
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python basic_agent_with_postgresdb.py