Check the Status of your Threads¶
Setup¶
To start, we can setup our client with whatever URL you are hosting your graph from:
SDK initialization¶
First, we need to setup our client so that we can communicate with our hosted graph:
Find idle threads¶
We can use the following commands to find threads that are idle, which means that all runs executed on the thread have finished running:
Output:
[{'thread_id': 'cacf79bb-4248-4d01-aabc-938dbd60ed2c',
'created_at': '2024-08-14T17:36:38.921660+00:00',
'updated_at': '2024-08-14T17:36:38.921660+00:00',
'metadata': {'graph_id': 'agent'},
'status': 'idle',
'config': {'configurable': {}}}]
Find interrupted threads¶
We can use the following commands to find threads that have been interrupted in the middle of a run, which could either mean an error occurred before the run finished or a human-in-the-loop breakpoint was reached and the run is waiting to continue:
Output:
[{'thread_id': '0d282b22-bbd5-4d95-9c61-04dcc2e302a5',
'created_at': '2024-08-14T17:41:50.235455+00:00',
'updated_at': '2024-08-14T17:41:50.235455+00:00',
'metadata': {'graph_id': 'agent'},
'status': 'interrupted',
'config': {'configurable': {}}}]
Find busy threads¶
We can use the following commands to find threads that are busy, meaning they are currently handling the execution of a run:
Output:
[{'thread_id': '0d282b22-bbd5-4d95-9c61-04dcc2e302a5',
'created_at': '2024-08-14T17:41:50.235455+00:00',
'updated_at': '2024-08-14T17:41:50.235455+00:00',
'metadata': {'graph_id': 'agent'},
'status': 'busy',
'config': {'configurable': {}}}]
Find specific threads¶
You may also want to check the status of specific threads, which you can do in a few ways:
Find by ID¶
You can use the get
function to find the status of a specific thread, as long as you have the ID saved
Output:
'idle'
Find by metadata¶
The search endpoint for threads also allows you to filter on metadata, which can be helpful if you use metadata to tag threads in order to keep them organized:
Output:
'idle'