How to self-host agent observability with Agno
Self-host agent observability with Agno. AgentOS traces each run with OpenTelemetry into your PostgreSQL, and the Control Plane reads it from your runtime.
December 2, 202610 min read
To self-host agent observability with Agno, run AgentOS on your own infrastructure with tracing=True and a PostgreSQL database passed as db. AgentOS records each run with OpenTelemetry, the open standard for traces and metrics, and stores the traces in that database. The Control Plane, which we host, reads them straight from your runtime through your browser, and we don’t store a copy.
AI agent observability is the ability to see what an agent did on a given run, step by step, with timing and errors attached.
Suppose a support agent tells a customer they’ll receive a $120 refund, but the billing system shows $105. To understand what happened, you need to follow the request through the agent: which tool it called, what arguments it supplied, what the tool returned, and how the model used that result.
An execution trace connects those steps. Each recorded operation, such as a model request or tool call, is a span: a timed record of one step, with its status and any attributes it captured. With input and output capture on, you can compare the billing tool’s response with the agent’s final answer and find where the mistake started.
The walkthrough below uses a support agent with a sample billing tool. The right answer is a $105 refund with a $15 retained fee, so you’ll know what a good trace looks like before you have to debug a bad one.
What does Agno record when you turn on tracing?
With tracing on, Agno records a trace for every run, with a span for each model call and tool call. Persisted runs and aggregate metrics give you the surrounding context. Agno instruments agent execution with OpenInference, a set of OpenTelemetry conventions for describing LLM and agent steps. With the PostgreSQL setup below, the default storage is:
| Signal | What it records | Storage and access |
|---|---|---|
| Traces and spans | Instrumented runs, model calls, tool executions, timing, and status | agno_traces and agno_spans; Control Plane, GET /traces, or db.get_traces() |
| Sessions and runs | Conversation state and persisted run inputs, outputs, and history | agno_sessions and agno_runs; sessions/run APIs |
| Run metrics | Token usage, duration, cost, and time to first token when available | Run payload in agno_runs.run_data; run_output.metrics |
| Daily metrics | Aggregated runs, sessions, users, and token usage | agno_metrics; refresh with POST /metrics/refresh, then read GET /metrics |
These are the default PostgreSQL names. Custom table names and other adapters can differ. Cost and timing fields depend on the model/provider and run mode. See AgentOS tracing and the metrics example.
How do you set up tracing with PostgreSQL?
1. Create the environment
You’ll need Python 3.12, uv, Docker, and an OpenAI API key. We tested the example with Agno 3.1.12 and OpenAIResponses using gpt-5.6-luna.
mkdir agno-observability && cd agno-observability
uv venv --python 3.12
source .venv/bin/activate
uv pip install "agno[os,openai]==3.1.12" "psycopg[binary]"
export OPENAI_API_KEY="your-api-key"
export DATABASE_URL="postgresql+psycopg://ai:ai@localhost:5532/ai"
export AGNO_TELEMETRY=falseThe os extra includes the OpenTelemetry SDK and Agno instrumentor. On Windows, activate the environment with .venv\Scripts\Activate.ps1 and set the environment variables in PowerShell.
Start a local PostgreSQL instance with the agnohq/pgvector image. Tracing doesn’t need pgvector, but it’s the image we use for local development. These credentials are for the local demo only.
docker run -d \
-e POSTGRES_DB=ai -e POSTGRES_USER=ai -e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql \
-v agno-observability-pg18:/var/lib/postgresql \
-p 127.0.0.1:5532:5432 \
--name agno-observability-pg \
agnohq/pgvector:18Wait until docker exec agno-observability-pg pg_isready -U ai -d ai reports that it’s accepting connections. If a compatible database already uses port 5532, reuse it or change the port and DATABASE_URL together.
2. Add a billing tool and enable tracing
Save this as main.py. The tool returns fictional data in integer cents, so there’s a concrete result to compare with the model’s answer.
import json
import os
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
def lookup_refund(order_id: str) -> str:
"""Return a fictional order's refund details for this tracing demo.
Args:
order_id: The fictional order ID, such as demo-1001.
"""
if order_id != "demo-1001":
return json.dumps({"order_id": order_id, "error": "Demo order not found"})
return json.dumps(
{
"order_id": order_id,
"currency": "USD",
"paid_cents": 12000,
"refund_cents": 10500,
"retained_fee_cents": 1500,
}
)
db = PostgresDb(
id="observability-db",
db_url=os.environ["DATABASE_URL"],
)
support_agent = Agent(
id="support-agent",
name="Support Agent",
model=OpenAIResponses(id="gpt-5.6-luna"),
tools=[lookup_refund],
instructions=[
"For every refund question, call lookup_refund with the supplied order ID.",
"Use only the tool's result. All amounts are integer cents; divide by 100 for dollars.",
"State the refund and retained fee. If the order is missing, say so.",
],
db=db,
telemetry=False,
)
agent_os = AgentOS(
agents=[support_agent],
db=db,
tracing=True,
telemetry=False,
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="main:app")This demo disables Agno usage telemetry separately from tracing. OpenAI still receives the model request. For a real billing system, replace the fictional lookup with an authenticated tool that checks the caller’s access to the order.
3. Run the agent
Start the server:
python main.pyKeep the AgentOS server running.
4. Send a test message
Use the Control Plane chat to create a traced run:
- Open os.agno.com and sign in. Click Add new OS, select Local, enter
http://localhost:7777, give the connection a name, and click CONNECT. If the runtime is already connected, select it. - Open Chat, select Support Agent, and start a new conversation.
- Send: “What is my refund for order demo-1001? Explain the retained fee.”
- Wait for the response. It should report a $105.00 USD refund and a $15.00 USD retained fee. Then read its trace as the next section describes.
How do you read a trace in the Control Plane?
- In the connected runtime, open Traces and select
observability-dbif prompted. Filter foragent_id = support-agentand find the run matching your chat message and time. - Open the run and inspect the
lookup_refundspan to see its arguments and result, then compare them with the model’s final answer.

Live billing trace in the Control Plane. The lookup_refund span returns a $105 refund and a $15 retained fee for demo-1001. The displayed timestamp is UTC.
Walkthrough video: we send the demo-1001 refund question in Control Plane chat and get back a $105 refund and a $15 retained fee. Then we open the run in Traces and step through the lookup_refund span and both model calls.
Expected trace structure:
Support Agent run
Model call: request the refund lookup
Tool call: lookup_refund(order_id="demo-1001")
Result: refund_cents=10500, retained_fee_cents=1500
Model call: explain the result to the customerIf the answer is wrong, compare the tool output with the final response. Back to the $120 refund: if lookup_refund returned 10500 and the agent still said $120, the model misread the result. If the tool itself returned 12000, the problem is in the billing data. A wrong answer can still show an OK status, because the trace only records whether each step ran.
This walkthrough runs AgentOS and PostgreSQL locally. For deployment, run AgentOS on your server or container platform with persistent PostgreSQL storage. Then configure HTTPS and authentication before you connect the Control Plane to the runtime’s URL, which your browser has to be able to reach. The deployment templates cover hosting and Security & Auth covers locking it down. Once it’s live, follow the connection guide to add it to the Control Plane.
How do you find failed runs and track usage?
To find failed runs for this agent, open Traces and enter status = ERROR AND agent_id = support-agent in the filter bar. The successful billing demo shouldn’t appear in these results.
Open a matching trace to inspect its span tree, timing, error details, and captured tool inputs and outputs. Clear the error filter to return to successful runs.
Open Metrics under Observability to review aggregated run and token usage. Select the database containing the agent’s persisted runs, which is observability-db in this example, and the relevant date range. After new runs, click Refresh and wait for it to finish. Metrics are stored aggregates, so the latest run may not appear immediately.
Use the trace filter guide for more filter options. For scripts and custom reports, such as error counts grouped by agent, the trace API and database query methods cover traces, and the metrics API covers usage.
Where should traces live in production, and for how long?
Traces go to the database you pass to AgentOS as db, and they stay there until you delete them. If you don’t pass one, tracing falls back to the first component database it finds. With no database at all, AgentOS skips tracing and logs a warning. Tracing setup is process-wide, so a later AgentOS instance won’t redirect an exporter that’s already installed.
For separate storage, give the agent its application database and AgentOS the trace database:
agent_db = PostgresDb(id="agent-db", db_url=os.environ["APP_DATABASE_URL"])
trace_db = PostgresDb(id="trace-db", db_url=os.environ["TRACE_DATABASE_URL"])
support_agent.db = agent_db
agent_os = AgentOS(
agents=[support_agent], db=trace_db, tracing=True, telemetry=False
)Use this in place of the original AgentOS setup and start a fresh process. Adding it as a second runtime after tracing has started won’t move your traces.
These are the most common adapters for trace storage. Others support it too, including SingleStore, Redis, Firestore, and DynamoDB.
| Adapter | Trace storage | Typical use |
|---|---|---|
PostgresDb | Yes | Production application and trace storage |
SqliteDb | Yes | Local development and tests |
MySQLDb | Yes | Existing MySQL infrastructure |
MongoDb | Yes | Existing MongoDB infrastructure |
ClickhouseDb | Yes, traces only | Dedicated analytical trace storage; keep sessions and evals in a row-store |
Agno doesn’t set a retention policy for traces. The queries below use the default ai schema and trace table names, so adjust them if you changed either. In PostgreSQL, start_time is stored as an ISO 8601 string, so cast it before you compare it with a timestamp. This transaction deletes traces older than 30 days, removing their spans first:
BEGIN;
DELETE FROM ai.agno_spans
WHERE trace_id IN (
SELECT trace_id FROM ai.agno_traces
WHERE start_time::timestamptz < NOW() - INTERVAL '30 days'
);
DELETE FROM ai.agno_traces
WHERE start_time::timestamptz < NOW() - INTERVAL '30 days';
COMMIT;You’ll need to schedule the cleanup yourself. On large tables, delete in bounded batches and check the query plan, since the cast can stop Postgres from using the string-column index. This only covers traces. Sessions and runs keep their own retention, and so do your backups.
Optional: batch trace exports
Keep tracing=True in the main walkthrough. The default setup uses SimpleSpanProcessor, which writes completed spans to PostgreSQL on the execution path. If you need queued export, use this setup in a fresh process instead. Insert the code after you create db and before you construct the agent, then remove tracing=True from AgentOS.
from agno.tracing import setup_tracing
setup_tracing(
db=db,
batch_processing=True,
max_queue_size=2048,
max_export_batch_size=512,
schedule_delay_millis=3000,
)Batching delays when traces show up and holds them in a bounded in-memory queue, so let the tracer provider flush during an orderly shutdown. A separate trace database takes storage load off your app database, but export still runs synchronously unless you turn on batching. See span processor configuration.
How do you keep sensitive data out of traces?
To keep sensitive data out of traces, hide captured inputs and outputs with OpenInference’s controls before you start the process:
export OPENINFERENCE_HIDE_INPUTS=true
export OPENINFERENCE_HIDE_OUTPUTS=trueTurn these on after the demo if you want to see its tool result first. The instrumentor also accepts TraceConfig(hide_inputs=True, hide_outputs=True) for custom provider setups. These settings don’t touch session history. They also can’t guarantee that sensitive values stay out of custom attributes or exception messages, so restrict access to the database and runtime, and test the fields your application emits.
Why aren’t my Agno traces showing up?
Agno traces usually go missing for one of these reasons:
- Tracing is disabled. Set
tracing=Trueor callsetup_tracing(db=...)before runs start. - There’s no database. Configure an AgentOS or component database and check startup warnings.
- The exporter writes somewhere else. Check which database and schema AgentOS writes to.
- The viewer is querying the wrong database. Select the correct database in the Control Plane or pass its
db_idto the API. While you diagnose, clear every filter in the trace view. - Another SDK installed a tracer provider. If an SDK provider already exists, Agno’s setup returns without installing its exporter or instrumentor. Add the database exporter and Agno instrumentation to the existing provider instead of replacing the global provider afterward.
- Database writes are failing. Check runtime/exporter logs, connectivity, driver dependencies, and permissions to create or write the trace tables.
- A batch hasn’t flushed. Wait for the configured export delay and ensure short-lived processes flush before exiting.
- The browser can’t reach the runtime. Check the endpoint, HTTPS, browser network permissions, CORS, authentication, and trace-read authorization. See Control Plane connection troubleshooting.
Can you send Agno traces to Langfuse?
Yes. If you want a separate self-hosted trace viewer, you can export over OTLP, the OpenTelemetry protocol for sending traces, to a backend such as Langfuse. Set up export with the tracing configuration guide. On the Langfuse side, you’ll need its OpenTelemetry integration and self-hosting guide. Configure tracing once per process and check the backend’s authentication and attribute requirements. The PostgreSQL and Control Plane walkthrough doesn’t need it.
Further reading
For API-driven runs, see the AgentOS run API. To test answer correctness, see the evaluation guide.
Reviewed and tested on November 25, 2026, with Agno 3.1.12, Python 3.12, and PostgreSQL. The live Control Plane chat called lookup_refund for demo-1001 and returned a $105 refund and $15 retained fee. Trace inspection confirmed the agent run, two model calls, and the tool input/output. We didn’t test Langfuse ingestion or its UI.
Frequently asked questions
AI agent observability is the ability to see what an agent did on a given run. In practice, it combines execution traces with run and aggregate metrics so you can inspect model calls, tools, coordination, latency, errors, and usage. The detail available depends on instrumentation and content-capture settings.
No, not through tracing. The database exporter writes to your configured database, and the hosted Control Plane requests data directly from your runtime through your browser. Optional exporters send traces wherever you configure them. Usage telemetry is a separate feature, and it’s on by default. It sends minimal usage analytics to Agno. Setting AGNO_TELEMETRY=false turns it off everywhere except AgentOS and evals, which each need telemetry=False. The example sets both. See Agno telemetry.
Yes. Call setup_tracing(db=...) at the start of a script and query the database directly. AgentOS provides the trace API and a connection for the hosted Control Plane. You can also use a self-hosted OTLP backend such as Langfuse.
No. Agno’s database tracing adds no per-trace ingestion fee. You pay for the infrastructure you operate, including compute, storage, backups, and operations. Model-provider charges and any optional hosted platform plans are separate.

