Overview
AI agents that use tools require special tracing consideration. This guide shows how to trace agent loops, tool calls, and multi-turn conversations effectively.Basic Agent Pattern
Here’s a well-traced agent implementation:What Gets Traced
Each LLM call in the agent loop creates a span:Tool Execution Tracing
Usespan() to trace individual tool executions:
Multi-Turn Conversations
For chat applications, preserve session context:ReAct Pattern
For ReAct (Reasoning + Acting) agents, usespan() for thought and action steps:
Best Practices
- One trace per task — Wrap the entire agent execution in
@observe - Trace tool execution — Use
span()for custom tool calls - Include iteration context — Add step numbers to metadata
- Set reasonable limits — Cap iterations to prevent runaway traces
- Tag by agent type — Use tags like
["agent", "react"]for filtering

