Create a thread
To run your graph and the state persisted, you must first create a thread.Empty thread
To create a new thread, use the LangGraph SDKcreate
method. See the Python and JS SDK reference docs for more information.
Copy thread
Alternatively, if you already have a thread in your application whose state you wish to copy, you can use thecopy
method. This will create an independent thread whose history is identical to the original thread at the time of the operation. See the Python and JS SDK reference docs for more information.
Prepopulated State
Finally, you can create a thread with an arbitrary pre-defined state by providing a list ofsupersteps
into the create
method. The supersteps
describe a list of a sequence of state updates. For example:
List threads
LangGraph SDK
To list threads, use the LangGraph SDKsearch
method. This will list the threads in the application that match the provided filters. See the Python and JS SDK reference docs for more information.
Filter by thread status
Use thestatus
field to filter threads based on their status. Supported values are idle
, busy
, interrupted
, and error
. See here for information on each status. For example, to view idle
threads:
Filter by metadata
Thesearch
method allows you to filter on metadata:
Sorting
The SDK also supports sorting threads bythread_id
, status
, created_at
, and updated_at
using the sort_by
and sort_order
params.
LangGraph Platform UI
You can also view threads in a deployment via the LangGraph Platform UI. Inside your deployment, select the “Threads” tab. This will load a table of all of the threads in your deployment. To filter by thread status, select a status in the top bar. To sort by a supported property, click on the arrow icon for the desired column.Inspect threads
LangGraph SDK
Get Thread
To view a specific thread given itsthread_id
, use the get
method:
Inspect Thread State
To view the current state of a given thread, use theget_state
method:
Inspect Full Thread History
To view a thread’s history, use theget_history
method. This returns a list of every state the thread experienced. For more information see the Python and JS reference docs.