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: Both methods take a project ID. If you only have the project name, look it up with aread_project() / readProject() first, as the examples below do. In Python, both methods are async.
To query the threads of an agent, an experiment, or the evaluators, find its project ID and pass it as the project ID.
These methods replace list_threads / listThreads and read_thread / readThread, which are deprecated. LangSmith Cloud removes them on January 31, 2027, and self-hosted LangSmith removes them in v0.19. The new methods require langsmith>=0.10.15 (Python) or langsmith>=0.8.9 (TypeScript) and, on self-hosted LangSmith, v0.16 or later. For the full list of changes, see the migration guide.

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 threads in a project

threads.query returns the threads in a project, one row per thread with its aggregates. Results are paginated with a cursor; the SDK iterates through every page for you.
Output

Parameters

Return value

An async iterator of Thread objects. The most useful fields: A Thread does not embed its runs. To get them, call threads.list_traces with the thread_id.

Read the traces of a single thread

When you already know the thread_id, use threads.list_traces / threads.listTraces. It returns the thread’s traces (root runs) in ascending start_time order.
Each item is a lightweight ThreadTrace, not a full run. Only the fields listed in selects are populated; without selects, you get trace_id only. Use traces.list_runs to get a trace’s child runs (tool calls, sub-chains).

Parameters

Return value

An async iterator of ThreadTrace objects, sorted by start_time ascending.

Examples

The snippets below continue the samples above: in Python, run them inside the same async def main(), with client and project already set.

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, threads.query only surfaces threads with traces from the last day. Pass min_start_time to widen the window:

Reconstruct a conversation

threads.list_traces returns traces oldest first, so you can replay a conversation turn by turn. Select INPUTS and OUTPUTS to get the full payloads: