Skip to main content
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.

Enabling Tracing

Pass tracing directly to the Agent constructor:
Alternatively, tracing can also be configured via AgentConfig for backward compatibility:
When both 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:
Each file is named {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 the TraceExporter protocol to send events to any backend:
Use it alongside other exporters:

NoOpExporter

Use NoOpExporter 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, use debug=True:
This auto-adds a 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
Debug mode composes with existing tracing — if you already have tracing=Tracing(exporters=[...]), adding debug=True appends the DebugExporter without replacing your exporters.

DebugExporter

You can also use DebugExporter directly:
The 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.