
What are sessions and users
A session represents a series of related interactions between a user and your AI system. The typical example is a multi-turn conversation thread in a chatbot. A user is the individual behind one or more sessions, identified by an ID. All traces with the samesession_id
can be grouped together, allowing you to
see the complete interaction flow. You can also group traces by user_id
,
allowing you to see the different journeys taken by a given user.
How to set up sessions and users
With minimal additional instrumentation, you can add session and user context to your traces. You can do this in two ways:1. Set default context
Set default user and session context once, typically in middleware or at the start of a request. This context will automatically be applied to all traces within that execution context.2. Override context for specific traces
You can override or set user and session context for specific traces usingupdate_trace_user_session()
.