Docs
Features
Sessions

Sessions

Many interactions with LLM applications span multiple traces. Sessions in Langfuse are a way to group these traces together and see a simple session replay of the entire interaction. Get started by adding a sessionId when creating a trace.

Add a sessionId when creating/updating a trace. This can be any string that you use to identify the session. All traces with the same sessionId will be grouped together.

When using the @observe() decorator:

from langfuse.decorators import langfuse_context, observe
 
@observe()
def fn():
    langfuse_context.update_current_trace(
        session_id="your-session-id"
    )
 
fn()

When using the low-level SDK:

from langfuse import Langfuse
langfuse = Langfuse()
 
trace = langfuse.trace(
    session_id="your-session-id"
)

Example

Try this feature using the public example project.

Example session spanning multiple traces

Session view

Other features

  • Publish a session to share with others as a public link (example (opens in a new tab))
  • Bookmark a session to easily find it later
  • Annotate sessions by adding scores via the Langfuse UI to record human-in-the-loop evaluations

Was this page useful?

Questions? We're here to help

Subscribe to updates