Both methods take a
project_id. The examples below resolve the agent environment to get it. In Python, both methods are async.
To query the threads of an agent environment, an experiment, or the evaluators, resolve it and pass the returned
session_id as project_id. Resolving needs recent SDK and LangSmith versions, and is not available on BYOC data planes. For the requirements and a BYOC alternative, see Resolve an agent environment.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 athread_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'
thread_id in the run metadata:
List threads in an agent environment
threads.query returns the threads in an agent environment, 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 ofThread 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 thethread_id, use threads.list_traces / threads.listTraces. It returns the thread’s traces (root runs) in ascending start_time order.
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 ofThreadTrace objects, sorted by start_time ascending.
Examples
The snippets below continue the samples above: in Python, run them inside the sameasync 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:
Connect these docs to your agent of choice via MCP for real-time answers.

