For detailed information about trace properties, node types, and hierarchy, see the Trace concept page.
1. The @trace Decorator
Add the @trace decorator to any function you want to track. It automatically captures: name, inputs, outputs, timing, errors, and parent-child relationships.
2. Collect Traces
Method 1: Manual Collection
For full control over the trace lifecycle:Method 2: Automatic Collection
Useinference_results.generate() for hands-free trace management. This requires implementing the Agent abstract class:
Method 3: Conversation Simulator
When using the Conversation Simulator, tracing works out-of-the-box. Simply decorate your agent methods with@trace and run:
3. Advanced: Custom Context Management
For advanced use cases, the trace service exposes additional methods:See the Trace Service API reference for all available methods.
Summary
| Method | Control | Best For |
|---|---|---|
| Manual | Full | Debugging, testing, custom workflows |
Automatic (generate()) | Simplified | Production single-turn inference |
| Simulator | Built-in | Multi-turn conversation testing |