Tracing captures every significant event during an agent run — model calls, tool executions, errors — and exports them to one or more backends. This gives you full visibility into what your agent did and why.Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
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
Enable or disable tracing.
List of exporter instances that receive trace events.
Optional function to filter which events are exported. Return
True to include, False to skip.Number of events to batch before flushing to exporters.
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
| Event | When It Fires |
|---|---|
RunStarted | Agent begins a run |
RunContent | A content chunk is generated (streaming) |
RunContentCompleted | Content generation is finished |
ToolCallStarted | A tool call begins executing |
ToolCallCompleted | A tool call finishes |
ToolCallError | A tool call fails |
ReasoningStep | A reasoning step is produced |
RunCompleted | The run finishes successfully |
RunError | The run fails with an error |
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.