How to delete a pending run in Assistants?

Should a run be waiting for tool_output, it takes 10 minutes before to expire. In that time it is not possible to fire another run in that thread.
It would be very usefull to delete pending run in a thread expecially when debugging threads with assistants using functions tool.
Is there a way to kill the pending run (without delete a thread)?

The API Reference for Assistants offers you this method:

Cancel a Run

If it is waiting for a tool return, I’d wonder if the thread is left in a state of internal messages that are invisible, still expecting a tool if you attach to another assistant and run. The permanence and storage of internal iterations is not made clear.

Thank you very much. I was’nt aware of it.
Do you know a reference for function template writing? I do’nt know how to declare parameters such as mode=‘text’ (this is a constant parameter needed by the function to format output as text when called by openai Assistant) in order to call a python function?

I still have a small (!) problem. I can see the last pending runs in the current Thread:

        for i in range(len(self.client.beta.threads.runs.list(thread_id).data)):

but I did’nt understood the python syntax to delete the self.client.beta.threads.runs.list(thread_id).data[i] run

May be I’m dumb (or better, take it for granted :smile: -) ) but I canno t derive the python call from REST syntax:

the following syntax seems not to work:


Solved. I found the python code at following:

The correct syntax is:


Guys OPEN AI is having an API to cancel the existing run.The above link is the openai documentation for cancelling the run.