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)):
            print(self.client.beta.threads.runs.list(thread_id).data[i])

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:
POST

https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/cancel

the following syntax seems not to work:

client.beta.threads.runs.delete(run.id)

Solved. I found the python code at following:

The correct syntax is:

client.beta.threads.runs.cancel(run.id,thread_id=thread_id)

https://platform.openai.com/docs/api-reference/runs/cancelRun

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