Skip to main content
If you’re building a conversational agent or any multi-turn application, LangSmith automatically groups your runs into threads. Querying threads lets you replay full conversations, audit agent behavior across sessions, build analytics on conversation length and latency, and feed downstream workflows like fine-tuning and evaluation. The SDK exposes two methods for working with threads:

How threads work

Each run you create can carry a thread_id in its metadata. LangSmith uses this to group runs into threads. The backend looks for thread_id in metadata (falling back to session_id).
We recommend using UUID v7 thread IDs. UUIDv7 embeds a timestamp, which preserves correct time-ordering of threads. The LangSmith SDK exports a uuid7 helper (Python v0.4.43+, JS v0.3.80+):
  • Python: from langsmith import uuid7
  • JS/TS: import { uuid7 } from 'langsmith'
If you’re using a tracing integration, pass thread_id in the run metadata:

List all threads in a project

list_threads / listThreads fetches all threads in a project and groups their runs together. Results are sorted by most recent activity first.
Results are sorted by most recent activity:
Output

Parameters

Return value

A list of thread objects, each containing:
list_threads always returns root runs only. If you need child runs (e.g., tool calls, sub-chains), use read_thread instead, which accepts an is_root / isRoot parameter you can set to false.

Read runs for a single thread

When you already know the thread_id, use read_thread / readThread. It returns an iterator over the thread’s runs directly, without fetching all threads first.
Unlike list_threads, each item here is a Run object directly — there is no grouping wrapper. Runs are returned in ascending chronological order by default.
Output

Parameters

Return value

An iterator (Python) or async iterator (TypeScript) of Run objects.

Examples

Filter threads by run properties

Pass a filter expression to narrow results using LangSmith trace query syntax. For example, to surface only threads containing at least one failed run:

Look back further than 24 hours

By default, list_threads only surfaces threads with runs from the last day. Pass start_time to widen the window:

Reconstruct a conversation

Use read_thread with order="asc" to replay a conversation turn by turn: