Multi-turn function calling with Assistants streaming mode?

I’ve been attempting to integrate the Assistants API streaming mode into a workflow with my own tools (function calling).

Following from the Assistants API documentation, I’ve been using the AssistantEventHandler, however the issue I run into is that in instances where multiple tool calls are required based on the user’s input, the event handler will end up closing the stream before the run is complete. Otherwise, I’ll get an error that the run is in progress (it doesn’t wait to submit). Any best practices for this?

You need to loop around processing the run and submit tool outputs until you no longer get tool response. Then you exit the loop and end the stream.