> ## Documentation Index
> Fetch the complete documentation index at: https://traceroot.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions

> Group related traces into sessions for multi-turn conversations and workflows

Set a **Session ID** to group traces together — all turns in a conversation, or all steps in a multi-agent workflow.

![traceroot Session panel with session stats, user, and each trace's input and output](https://mintcdn.com/tracerootai/TLv21OVXbJzkJk5L/images/session_v2.png?fit=max\&auto=format\&n=TLv21OVXbJzkJk5L\&q=85\&s=17311bbc1eb6c6585b23fee13ad5509f)

Session panel: summary stats, user, then each trace's input and output

## Using `using_attributes` / `usingAttributes`

Propagate a Session ID to all traces within a block:

> [tab] Python
>
> ```python theme={null}
> 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 a User ID to get full context on every trace:
>
> ```python theme={null}
> with using_attributes(session_id="chat-abc-123", user_id="user-42"):
>     agent.run(query)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { usingAttributes } from '@traceroot-ai/traceroot';
>
> await usingAttributes({ sessionId: 'chat-abc-123' }, async () => {
>   await agent.run("What's the weather in SF?");
>   await agent.run('What about tomorrow?');
> });
> ```
>
> Combine with a User ID to get full context on every trace:
>
> ```typescript theme={null}
> await usingAttributes({ sessionId: 'chat-abc-123', userId: 'user-42' }, async () => {
>   await agent.run(query);
> });
> ```

## Using `observe` / inside a function

Call `update_current_trace` / `updateCurrentTrace` from within any observed function:

> [tab] Python
>
> ```python theme={null}
> 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)
> ```

> [tab] TypeScript
>
> ```typescript theme={null}
> import { observe, updateCurrentTrace } from '@traceroot-ai/traceroot';
>
> async function handleRequest(query: string, sessionId: string) {
>   return observe({ name: 'handle_request', type: 'agent' }, async () => {
>     updateCurrentTrace({ sessionId });
>     return handleQuery(query);
>   });
> }
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.