Skip to main content
Set session_id to group traces together — all turns in a conversation, or all steps in a multi-agent workflow.
TraceRoot dashboard showing traces grouped by session

Using context manager

Use using_attributes to propagate session_id to all traces within a block:
from traceroot import using_attributes

with using_attributes(session_id="chat-abc-123"):
    response_1 = agent.run("What's the weather in SF?")
    response_2 = agent.run("What about tomorrow?")
Combine with user_id to get full context on every trace:
with using_attributes(session_id="chat-abc-123", user_id="user-42"):
    agent.run(query)

Using decorator / inside a function

Call update_current_trace from within any observed function:
from traceroot import observe, update_current_trace

@observe(name="handle_request", type="agent")
def handle_request(query: str, session_id: str):
    update_current_trace(session_id=session_id)
    return process(query)