Hey folks, quick one: I’m diving into the OpenAI Assistant API and wondering if threads (and messages in threads) have an expiration mechanism. Couldn’t find info in the docs. Particularly, regarding message persistence via GET https://api.openai.com/v1/threads/{thread_id}/messages
: is it a forever thing, or are there potential limitations? I noticed the “limit” field for the number of objects to be returned with a max of 100 so I am wondering if messages older than 100 can no longer be fetched via API ? How long does the threads/messages live ?
Appreciate any insights!
I have exact same question. Would be great if we can create a persistent thread with automatic expiry as we need a lot of threads for temporary persistence only
I’ve posted similar question (maybe a bit extended):
" [Questions regarding Threads in the Assistant API]"
There is “after” and “before” in the “/threads/{thread_id}/messages” params, so limit is just to limit the amount of data.
With a combination of the available parameters limit
, order
, after
and before
described at List messages you will be able to fetch all messages.
https://api.openai.com/v1/threads/thread_abc123/messages?order=asc
will list the oldest messages first
I dont believe there is a limit, but they do have a 30 day retention policy for Threads/Messages
https://platform.openai.com/docs/models/default-usage-policies-by-endpoint
This seems the closest thing to an answer as anyone has come to yet. My guess is that based on this link, threads persist for 30 days after the last time they were accessed, or at least 30 days since the last message was appended to them. This link says that messages persist for 30 days as well, so I’m guessing that when the last message “falls off the thread” and no more have been added, then the system deletes the thread?
This would be very useful for me to know, since my application is maintaining a list of threads, and when a user appends a message it gets the thread from the server using the locally stored thread id. If I could know that the thread was going to expire 30 days since its last use I could have a scheduled job that would clean up the locally stored threads, so it would not try to grab and use an expired thread id then have to error handle that situation.
As it stands, and without further official elaboration, I’m going to have to assume that this is the way it works and code this way. My application will clean up thread records (that store the IDs) after 30 days of not having a message appended, and if the same user attempts to access the same assistant 31+ days after their last interaction, the code will automatically create a new thread and a new thread record, vs trying to access one that I assume, at this point, will not be available.
From this line you can confidently make your assumption of threads being removed on day 31+ I include the + as there may be technical challenges to ensuring that every thread of millions is maintained down to the day.
From this line you can confidently make your assumption of threads being removed on day 31+ I include the + as there may be technical challenges to ensuring that every thread of millions is maintained down to the day.
Certainly, robust data management is required. This needs to be done with a job that runs outside of the flow of execution of the application vs something that is checked and handled when the thread is accessed. On the other hand, if your application is supporting threads to the tune of millions, one has to assume that your data access is highly optimized to begin with and your DBAs are at the top of their game.
@logankilpatrick Can you shed more light on this if possible? [Assistants API] Do assistant thread messages expire? - #7 by Camenwolf
Thanks
The usage polices section is the right place to look. I just made a PR to update this and make it more clear. Right now, the retention for messages and threads is actually 60 days after which they will automatically be deleted.
I also made a note that it is still a Beta for these endpoints so we are working on figuring out what the right long term path is / documenting how the different edge cases will manifest themselves. Expect to hear / see more from us on this in the weeks to come!
I am seeking clarification about whether the retention policy refers to the thread created date or a last update date. I am hoping the policy only applies to inactive threads and aged messages.