Streaming Assistants API v2 with Code Interpreter ThreadRunStepFailed

I’m trying to stream output from the Assistants API but I’m facing the issue of ThreadRunStepFailed very frequently.
I’ve noticed that it happens when I’m asking something from the code interpreter, for example, draw the graph of y=x^2. And this issue isn’t always reproducible, but it happens very frequently on the same prompt.

The thread.run.step.failed event looks like this

ThreadRunStepFailed(data=RunStep(id='step_jqhAcCOXYlxguYdcnifDUjHe', assistant_id='asst_JvlNMlLftIO80HfiBVsWsWvj', cancelled_at=None, completed_at=None, created_at=1713691694, expired_at=None, failed_at=1713691708, last_error=LastError(code='server_error', message='Sorry, something went wrong.'), metadata=None, object='thread.run.step', run_id='run_lQDkrjCRnsfDSBkvxe1lTxB0', status='failed', step_details=ToolCallsStepDetails(tool_calls=[CodeInterpreterToolCall(id='call_kMjTRqIFEMt97eaRD2fh5jMG', code_interpreter=CodeInterpreter(input="import matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.linspace(-10, 10, 400)\ny = x ** 2\n\nplt.figure(figsize=(8, 6))\nplt.plot(x, y, label='y = x^2')\nplt.title('Graph of y = x^2')\nplt.xlabel('x')\nplt.ylabel('y')\nplt.grid(True)\nplt.legend()\nplt.show()", outputs=[CodeInterpreterOutputImage(image=CodeInterpreterOutputImageImage(file_id='file-oxlAsdcgHNJfTqiMeQB2XRLK'), type='image')]), type='code_interpreter')], type='tool_calls'), thread_id='thread_a1VJ4KeTpBrfMsK0zPnmgBZa', type='tool_calls', usage=Usage(completion_tokens=91, prompt_tokens=4250, total_tokens=4341), expires_at=1713692293), event='thread.run.step.failed')

Is this an internal server error, or can I do something to solve it from my end?

i have same promble,did you find the solution?

i have same promble,did you find the solution?

not yet

I have the same problem from time to time.
After sending second request after message output in same thread.

Why not destroy the assistant after each step and respawn it. This has worked for us, and is efficient.

Does not work.
The api worked well until last week.
It is a bug.

For me, it appears when an API Key is created under the “Default” project, it works Ok.

However, if an API Key is created under a custom project, the run fails.

The problem occurs in the playground as well (under a custom project).

Now that I am playing around with it some more, I see that this didn’t fully fix the issue. It seems it went from failing every time to failing intermittently (both when the API is used from my custom programs and in the OpenAI Playground).

This seems to be a major issue with the API, making this feature unusable. Any ideas, updates, or suggestions? Should we switch our customers back to V1 of the API or is there a way to make V2 work?