threadId / thread_id lets you filter and inspect the full conversation arc in the Lemma dashboard.
Passing a thread ID
PassthreadId / thread_id as the second argument when calling the wrapped agent:
- TypeScript
- Python
lemma.thread_id on the root span. Empty and whitespace-only strings are ignored — the attribute is omitted entirely in that case.
Where thread IDs come from
Use any stable identifier that represents a conversation:- A session ID from the user’s browser cookie
- A chat room or channel ID from your database
- A unique conversation UUID you generate at the start of a session
How threads appear in Lemma
Runs that share the same non-emptylemma.thread_id are grouped in the traces list with a Thread · N indicator, where N is the number of runs in that thread. You can click any run to see the full conversation history.
Python context manager
The context manager form does not accept a second argument. To pass a thread ID in context manager mode, set the attribute directly on the span:Next Steps
- Overview — how
agent()works and what it captures - Custom attributes — attach user ID, session ID, and other business metadata to runs

