Hello,

I experiment with using Assistant API in python and noticed, that there is a minimum time required between calling

run = client.beta.threads.runs.create()

and

run = client.beta.threads.runs.retrieve()

I tested the time limit and it seems like if the time bewteen calling both functions is <5s, the run status of the retrieve function will stick to ‘in progress’.

I now wanted to now if someone has experienced a simillar issue or if anyone has an idea if there is a possibility to set a condition to execute the retrieve function.

In the following there is a sample of my code:

for i in range(len(list)):

    message = client.beta.threads.messages.create(
    thread_id=thread.id,
    role="user",
    content="Test Request" 
    )

    run = client.beta.threads.runs.create(
        thread_id=thread.id,
        assistant_id=assistant_id,
    )
    j = 0
    while run.status != 'queued':
        if j > 5:
            print("Message Status: ", run.status, "\nRequest timed out move on to next news article")
            break
        print("Message Status: ", run.status)
        time.sleep(1)
        j += 1
    
    #critical! Otherwise retrive would stick to 'in_progress'!
    time.sleep(5)

    run = client.beta.threads.runs.retrieve(
        thread_id=thread.id,
        run_id=run.id,
    )
    j = 0
    while run.status != 'completed':
        if j > 10:
            print("Message Status: ", run.status, "\nRequest timed out move on to next news article")
            break
        print("Message Status: ", run.status)
        time.sleep(1)
        j += 1

I apreciate any useful information and help.