Skip to main content
Sessions provide automatic span linking for multi-turn conversations. Each call in a session is automatically connected to previous calls, making it easy to visualize conversation flows in the Tracia dashboard.

Creating a Session

Basic Usage

How It Works

When you use a session:
  1. First call - A trace ID is generated to group all spans in this session
  2. Subsequent calls - Automatically include:
    • trace_id: The session’s trace ID (groups all spans together)
    • parent_span_id: The previous span’s ID (creates a chain)
This creates a tree structure in the Tracia dashboard where you can see the full conversation flow.

TraciaSession Methods

run_local() / arun_local()

Same as client.run_local() but with automatic span linking:

trace_id

Property that returns the session’s trace ID (groups all spans):

last_span_id

Property that returns the most recent span ID:

reset()

Clears session state to start a new trace:

Continuing Existing Traces

Use create_session with a trace_id to continue a trace across requests or services:

Manual Span Linking

If you prefer manual control, you can use trace_id and parent_span_id directly:

Streaming with Sessions

Sessions work with streaming:

Use Cases

  • Chat applications: Track full conversation threads
  • Multi-step agents: Link planning, execution, and verification steps
  • RAG pipelines: Connect retrieval and generation spans
  • Debugging: Easily find all spans related to a user session