Skip to main content
Sessions group related traces (multiple requests / turns) under a shared identifier—useful for conversational AI and multi-step workflows.
  • Set a session ID at the trace level so all spans in a trace share it.
  • Use the Sessions view in the Laminar UI to review all traces in the same session.
Set the session ID early in your request/handler entry point so downstream spans inherit it.
You must set the session ID inside a span context so it can attach to the current trace (for example, inside an @observed function / observe() call, or by passing sessionId / session_id via observe options).

What is a Session?

A trace usually represents one request / one conversational turn. A session groups multiple traces that belong to the same higher-level flow (for example, an entire chat conversation or checkout process).

Example

import { observe } from '@lmnr-ai/lmnr';

// One trace per turn/request; reuse the same sessionId across turns
export async function handleTurn(conversationId: string, userMessage: string) {
  return observe({ name: 'handleTurn', sessionId: conversationId }, async () => {
    // ... LLM calls / tools ...
  });
}
See also: observe(..., { sessionId }) and Laminar.setTraceSessionId

Viewing Sessions in Laminar

  1. Navigate to the Traces page
  2. Select the Sessions tab
  3. Click a session to expand and see all traces within it
Sessions tab showing traces grouped by session Each trace within a session contains the same information as a standalone trace: Trace detail view for a trace within a session

Common Patterns

  • Chatbots: session = conversation_id, trace = one user turn.
  • Workflows: session = checkout-{userId}, trace = each step (validateCart, processPayment, createOrder).