Applies to:
- Plan - Any
- Deployment - Any
- Use case - How to log and evaluate conversations that escalate from AI to human support and how to scope Topics and scorers to distinguish AI performance from overall conversation outcomes
Summary
Recommend a single session root trace and attach each message as a child span. Tag spans withmetadata.sender and metadata.conversation_id. Use the SDK’s span timing so metrics.start and metrics.end capture AI execution (separate from human wait time).
What is happening
Keeping human turns as child spans under a session root gives a single UI view, simpler querying, and faster scoring because the system reads one trace. The platform also logs span creation times. Built-in duration, timeline, and latency derive from spanmetrics.start and metrics.end; arbitrary timestamps in metadata.* are ignored by those features.
Fix or suggestion
Recommended: Single session trace with child spans (preferred)
- Create one root trace per conversation (session). For each message turn (AI, human agent, customer, automation) create a child span on that root and set span attributes and metadata consistently.
- Tag each span with at least:
metadata.conversation_id: the shared grouping key used by Topics and group-scoped scorers.metadata.sender: one ofai,human_agent,customer,automation, oragent_assistant.- Accurate timing via the SDK so span
metrics.startandmetrics.endreflect AI execution windows. If you also store extra timestamps inmetadata, they are only used if a custom scorer reads them.
- Scope scorers:
- AI-only evaluation: span- or trace-scoped scorers that filter spans where
metadata.sender == "ai"; use spanmetrics.start/metrics.endfor latency. - Overall outcome: group-scoped scorers on
metadata.conversation_idto evaluate resolution, sentiment shift, and handoff behavior across the whole session.
- AI-only evaluation: span- or trace-scoped scorers that filter spans where
metrics.start and metrics.end. Fields like metadata.start_time, metadata.end_time, or metadata.duration_ms do not affect those features. Only custom scorers will use them if you explicitly read those fields.
When to keep per-turn traces (alternative)
- Keep one trace per turn if you need very small, independent trace objects (e.g., external tracing constraints) or you prefer separating spans at ingestion time. Link those traces with
metadata.conversation_idand use Topics group scope and trace-scoped filters for AI-only evaluation.
- Single-root-with-spans: cleaner UI, easier single-trace reads, and often faster scoring because the scorer reads one trace. It also makes it explicit which timestamps represent AI execution via span
metrics.start/metrics.end. - Per-turn traces: simpler to avoid long-lived root traces and sometimes simpler for streaming ingestion pipelines. Requires group-scoped aggregation and more reads for scorers that need many turns.
How to confirm it worked
- The session trace shows the full conversation as a thread in the UI.
- AI-only scorers return results only for spans where
metadata.sender == "ai"and use spanmetrics.start/metrics.endfor latency metrics. - Topics configured with the grouping key
metadata.conversation_idsummarize Task, Sentiment, and Issues across the grouped conversation.
Notes
- If agents use an AI assistant, log assistant messages with a distinct
metadata.sender(e.g.,agent_assistant) so AI-only evaluations don’t double-count assistance provided during human replies. - For near-real-time Topic updates, choose “Every trace in group”. For a single summary after a session completes, choose “First trace in group” and configure its Idle time as needed.