V3 Trace Format
The v3 trace format is the single source of truth for session data in the Synth SDK. It captures complete execution details including events, messages, timing, token usage, and metadata.Overview
A SessionTrace represents one complete execution (conversation, RL episode, batch job). It contains:- Ordered timesteps with events and messages
- Complete event/message history (flat chronological lists)
- Session-level metadata
- Timing and performance data
Why V3?
The v3 format supersedes legacy trajectory formats by providing:- ✅ Richer data: Token IDs, logprobs, timing, multimodal content
- ✅ Better structure: Clear separation between events and messages
- ✅ Type safety: Frozen dataclasses with validation
- ✅ Future-proof: Extensible metadata and event types
Core Data Structures
SessionTrace
Top-level container for a complete session.session_id: Unique identifier (e.g., UUID, run ID)session_time_steps: Ordered list of logical steps/turnsevent_history: Complete flat list of all events (chronological)markov_blanket_message_history: Complete flat list of all messagesmetadata: Session-level context (user_id, experiment_id, env_name, etc.)
SessionTimeStep
A logical step within the session (e.g., one conversation turn, one RL step).step_id: Unique identifier for this stepstep_index: Sequential position (0-based)turn_number: 1-based turn count for conversational contextsevents: Events that occurred during this stepmarkov_blanket_messages: Messages exchanged during this step
Event Types
BaseEvent
Common fields for all event types.LMCAISEvent
Language model API calls with token/cost tracking.EnvironmentEvent
Feedback from environments (rewards, observations, termination).RuntimeEvent
System decisions and actions.Messages
Messages represent information crossing subsystem boundaries.observation: Environment → Agentaction: Agent → Environmentresult: Environment → Agentuser_input: User → Agentagent_response: Agent → User
Time Records
Timing information for events and messages.Complete Example
Schema Validation
The v3 format includes automatic validation:- Type checking: All fields are type-checked at creation
- Immutability: Events and messages are frozen dataclasses
- JSON serialization:
SessionTrace.to_dict()for storage
Best Practices
1. Use Meaningful System IDs
2. Populate Metadata
3. Record Both Events and Messages
Events capture what happened, messages capture communication.4. Use Consistent Timestamps
Migration from Legacy Format
If you have legacy trajectory data, use the conversion utilities:See Also
- Event Rewards - Attach rewards to specific events
- Outcome Rewards - Attach rewards to complete sessions
- Task Apps - Build environments that produce v3 traces