I just found that there is an upper bound of number of messages per thread of assistant API. Total number of user messages and assistant messages is limited to 20 per thread. Does anyone encounter same problems?
Everyone would encounter it, as it is documented.
You can attach a maximum of 20 files per Assistant, and they can be at most 512 MB each. The size of all the files uploaded by your organization should not exceed 100 GB. You can request an increase in this storage limit using our help center. In addition to the 512 MB file size limit, each file can only contain 2,000,000 tokens. Assistant or Message creation will fail if any attached files exceed the token limit.
(I’d like to find the data file where 2 million tokens = 512 million bytes…)
https://platform.openai.com/docs/assistants/how-it-works/creating-assistants
(sorry, I mistook the “20” as the well-known file limit. As answered below, listing the objects of assistants through the API has a default length and a maximum length)
I found that the volume of message list is 20, so if your len(messages) exceeds 20, the list will be cut. If your order is set to “asc” when retrieve response messages, you will not access the latest message. So set the order to “desc” and get the latest response from the first element of the list.
The default limit is 20 for pagination
limit
integer
Optional
Defaults to 20
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
https://platform.openai.com/docs/api-reference/messages/listMessages