How to handle rate limit failure in assistant submit_tool_outputs_and_poll

Hi all,

When submitting tool outputs in assistant with self.client.beta.threads.runs.submit_tool_outputs_and_poll I sometimes run into my rate limit: “Rate limit reached …Please try again in …”

This is correctly returned by the API:
run.status == “failed”
run.last_error.code == “rate_limit_exceeded”

I then wait a bit and would like to redo the self.client.beta.threads.runs.submit_tool_outputs call. But then I get the answer: “Runs in status “failed” do not accept tool outputs.”

How do I properly handle the rate limit error in tool output submission?

1 Like

I’ve been facing the same error here and don’t know how to solve it.
I added a time.sleep(1) and retry but it only worked for runs.create_and_poll.
When using runs.submit_tool_outputs_and_poll, I get the same error message:

Failed to submit tool outputs: Error code: 400 - {‘error’: {‘message’: ‘Runs in status “failed” do not accept tool outputs.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: None}}

Plus one here, facing the same issue.

I’m trying to make it work like this: if the submit_tool_output call fails, we should simply retry the run, as that will run again the requires_action update. isn’t it?