Python SDK
Agno Integration
Track and observe Agno (formerly Phidata) agents, tools, and responses.
The Agno integration allows you to trace your agent's lifecycle events, including tool calls and runs, by injecting callbacks into your Agno agents.
Setup
First, install the Agno extra dependencies:
pip install infralo[agno]To connect Infralo to an Agno agent, generate callbacks using make_agno_callbacks and pass them to the Agent definition.
make_agno_callbacks(infralo: Infralo)
This helper generates a lifecycle callback dictionary configured for the current Infralo client.
from infralo import Infralo
from infralo.integrations.agno import make_agno_callbacks
from agno.agent import Agent
infralo = Infralo()
# 1. Generate the callbacks dict
callbacks = make_agno_callbacks(infralo)
# 2. Inject them into your Agno agent
agent = Agent(
model=...,
tools=[...],
**callbacks # Unpacks tool hooks, pre/post hooks, and callbacks
)Usage Example
Run your agent inside an Infralo trace context. The hooks automatically intercept tool invocations, log performance metrics, and push them to the active trace.
from infralo import Infralo
from infralo.integrations.agno import make_agno_callbacks
from agno.agent import Agent
infralo = Infralo()
agent = Agent(
tools=[get_weather],
**make_agno_callbacks(infralo)
)
# Run the agent within an active trace
with infralo.start_trace(session_id="agno-session") as trace:
agent.print_response("What is the weather in London?")What is Captured
The Agno integration automatically captures:
- Tool Spans: Every tool execution is recorded as a
ToolSpanwith the exact tool name and arguments. - Inputs & Outputs: Tool input arguments and output results/content are collected.
- Exceptions: Any errors raised by a tool are intercepted, logged to the span as
status="error", and re-raised. - Agent Lifecycle Metadata: Details of the agent version and framework tags are linked to the span metadata.
Complete Examples
You can view or download the complete, ready-to-run examples:
- agno_integration.py — Standard single-agent integration.
- agno_complex_nesting.py — Advanced multi-agent delegation and nested calls.