Add HoneyHive observability to your PydanticAI agent applications
PydanticAI is a Python agent framework from the Pydantic team, built for type-safe LLM applications with dependency injection, structured outputs, and multi-agent support.HoneyHive integrates with PydanticAI via its native OpenTelemetry support, automatically capturing agent runs, tool calls, and LLM interactions.
Add HoneyHive tracing in just 3 lines of code. Initialize the tracer and call Agent.instrument_all(), and all agent runs, tool calls, and model calls are automatically traced.
To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see Tracer Initialization.
pip install "honeyhive>=1.0.0rc0" pydantic-ai
import osfrom honeyhive import HoneyHiveTracerfrom pydantic_ai import Agenttracer = HoneyHiveTracer.init( api_key=os.getenv("HH_API_KEY"), project=os.getenv("HH_PROJECT"),)Agent.instrument_all()# Your existing PydanticAI code works unchanged
import asyncioimport osfrom dataclasses import dataclassfrom pydantic_ai import Agent, RunContextfrom honeyhive import HoneyHiveTracertracer = HoneyHiveTracer.init( api_key=os.getenv("HH_API_KEY"), project=os.getenv("HH_PROJECT"),)Agent.instrument_all()@dataclassclass CustomerContext: customer_name: str order_id: strpolicy_agent = Agent( "anthropic:claude-haiku-4-5", name="policy_specialist", instructions=( "You are a policy specialist. Give concise answers about " "refund, cancellation, and shipping policies." ),)coordinator = Agent( "anthropic:claude-haiku-4-5", name="support_coordinator", deps_type=CustomerContext, instructions=( "You are a support coordinator. For policy questions, " "delegate to ask_policy_specialist. Combine the answer " "with any order context to form your response. Be concise." ),)@coordinator.toolasync def ask_policy_specialist( ctx: RunContext[CustomerContext], question: str) -> str: """Delegate policy questions to the specialist.""" result = await policy_agent.run(question, usage=ctx.usage) return str(result.output)async def main(): customer = CustomerContext(customer_name="Jordan Lee", order_id="ORD-1003") await coordinator.run( "Order ORD-1003 is delayed. Can I cancel and get a refund?", deps=customer, )asyncio.run(main())
In HoneyHive, you’ll see the full trace hierarchy including coordinator agent, delegated policy specialist calls, and tool executions.