Registry / observability / openinference-instrumentation-agno

openinference-instrumentation-agno

JSON →
library0.1.37pypypiunverified

OpenInference Agno Instrumentation is a Python auto-instrumentation library designed to trace Agno Agents. It is fully OpenTelemetry-compatible, enabling users to send detailed traces of their AI applications to OpenTelemetry collectors such as Arize Phoenix, Langfuse, or LangSmith. The current version is 0.1.30, with a frequent release cadence tied to the broader OpenInference project.

pip install openinference-instrumentation-agno agno opentelemetry-sdk opentelemetry-exporter-otlp
INSTALL
IMPORT
SIG · OPENINFERENCE-INST
O
openinference-instrumentation-agno
observabilitypythonv0.1.37
Install
11.9s avg
Import
890ms
Disk
113MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.37 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.938s · 111MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 11.9s · import 0.841s · 109MB
113MB installed
● package 113MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AgnoInstrumentor
from openinference.instrumentation.agno import AgnoInstrumentor

This quickstart demonstrates how to instrument an Agno agent using `openinference-instrumentation-agno` and export traces via OpenTelemetry. It sets up a `TracerProvider` with an `OTLPSpanExporter` to send traces to a specified endpoint (e.g., a local Arize Phoenix instance). The `AgnoInstrumentor` is then initialized and used to automatically trace the agent's operations. Ensure `agno`, an LLM provider (like `openai`), and OpenTelemetry exporters are installed, and relevant API keys/endpoints are configured via environment variables.

import os import asyncio from agno.agent import Agent from agno.models.openai import OpenAIChat from agno.tools.duckduckgo import DuckDuckGoTools from openinference.instrumentation.agno import AgnoInstrumentor from opentelemetry import trace as trace_api from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor # Configure OpenTelemetry to export traces (e.g., to Arize Phoenix or Langfuse) # For local Phoenix, run 'phoenix serve' in another terminal. # For Langfuse/LangSmith, set corresponding environment variables like LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, LANGSMITH_API_KEY, etc. # Example for a local OTLP endpoint (like Phoenix): otlp_endpoint = os.environ.get('OTEL_EXPORTER_OTLP_ENDPOINT', 'http://127.0.0.1:6006/v1/traces') # Configure the tracer provider tracer_provider = TracerProvider() tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint=otlp_endpoint))) trace_api.set_tracer_provider(tracer_provider=tracer_provider) # Instrument Agno AgnoInstrumentor().instrument() async def main(): # Create and configure an Agno agent agent = Agent( model=OpenAIChat(id=os.environ.get('OPENAI_MODEL_ID', 'gpt-4o-mini')), tools=[DuckDuckGoTools()], markdown=True, debug_mode=True, ) # Use the agent print("Agent is running...") response = await agent.run("What is the capital of France?") print(f"Agent response: {response.content}") if __name__ == "__main__": # Set a dummy OpenAI API key if not already set, for agent initialization if not os.environ.get('OPENAI_API_KEY'): os.environ['OPENAI_API_KEY'] = 'sk-DUMMY_KEY_FOR_TESTING' asyncio.run(main()) print(f"Traces should be sent to {otlp_endpoint}")
Debug
Known issues
breakingAgno (the underlying framework) version 2.0 introduced a breaking change where `store_history_messages` in `Agent` now defaults to `False`. If your tracing relies on agent history being stored, you must explicitly set `store_history_messages=True` when initializing your Agno agents to ensure full context is available in traces.
fix
Set `store_history_messages=True` in your Agno agent initialization: `agent = Agent(..., store_history_messages=True)`.
affects: Agno >= 2.0
gotchaOlder versions of `openinference-instrumentation-agno` sometimes failed to emit `token_count` metrics for LLM calls, which can hinder cost analysis and performance monitoring in observability platforms.
fix
Upgrade to `openinference-instrumentation-agno` version `0.1.30` or newer to ensure correct `token_count` emission. Always verify expected metrics are present in your observability backend.
affects: <0.1.30
gotchaWhen using `arun_stream()` with an async generator, the `output.value` attribute might be dropped from the finished span if the consumer closes the generator immediately after receiving the final `RunOutput`. This could lead to incomplete trace data for streaming interactions.
fix
Upgrade to `openinference-instrumentation-agno` version `0.1.30` or newer, which includes a fix for this bug related to context and streaming output handling. Verify your streaming traces contain complete output data.
affects: <0.1.30
gotchaProper OpenTelemetry setup is crucial. Incorrectly configuring the `TracerProvider`, `SpanProcessor`, or `OTLPSpanExporter` (especially the endpoint and authentication headers) will result in traces not being sent to your observability backend.
fix
Refer to the OpenTelemetry Python documentation and your specific backend's (e.g., Arize Phoenix, Langfuse, LangSmith) setup guides for correct `OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_HEADERS` environment variables or programmatic configuration.
affects: All
Upgrade
Version history
0.1.37latest on PyPI · released Jun 11, 2026
Audit
Dependencies
agnorequiredThe instrumentation targets the Agno agent framework.
opentelemetry-sdkrequiredProvides the core OpenTelemetry SDK components for tracing.
opentelemetry-exporter-otlprequiredEnables exporting traces to an OTLP-compatible backend (e.g., Phoenix, Langfuse, LangSmith).
openinference-instrumentationrequiredCore utilities and helpers for OpenInference instrumentations.
openinference-semantic-conventionsrequiredDefines semantic conventions for AI/LLM tracing within OpenInference.
wraptrequiredUsed for Python function wrapping and instrumentation.
typing-extensionsrequiredProvides backports of features from future Python typing versions.
Agent activity
33 hits · last 30 days
node
30
Amazon
1
OpenAI (training)
1
Resources