Enabling Tracing
Passtracing directly to the Agent constructor:
AgentConfig for backward compatibility:
Agent(tracing=...) and AgentConfig(tracing=...) are supplied, the direct tracing parameter takes precedence.
Tracing Reference
bool
default:"true"
Enable or disable tracing.
List[TraceExporter]
List of exporter instances that receive trace events.
Callable
Optional function to filter which events are exported. Return
True to include, False to skip.int
default:"1"
Number of events to batch before flushing to exporters.
int
default:"5000"
Maximum time in milliseconds between flushes.
JSONLExporter
The built-in exporter writes one JSON object per line to a file, organized by session ID:{session_id}.jsonl. Events include timestamps, run IDs, and full event data.
Reading Trace Files
Event Filtering
Skip noisy events to keep traces focused:Traced Events
Custom Exporters
Implement theTraceExporter protocol to send events to any backend:
NoOpExporter
UseNoOpExporter to discard all events. Useful in tests where you want tracing enabled but don’t need output:
Debug Mode
For quick, color-coded turn-by-turn inspection of model calls, usedebug=True:
DebugExporter to tracing, which uses rich to print color-coded panels showing:
- Messages sent to the model
- Tools available
- Model response content and tool calls
- Token usage and timing
tracing=Tracing(exporters=[...]), adding debug=True appends the DebugExporter without replacing your exporters.
DebugExporter
You can also useDebugExporter directly:
DebugExporter listens for ModelCallStartedEvent and ModelCallCompletedEvent to render its output.
Tracing failures never break agent execution. If an exporter raises an exception, the error is suppressed and the agent continues normally.