For the streaming case, we create an EventHandler class to handle events in the response stream and submit all tool outputs at once with the “submit tool outputs stream” helper in the Python and Node SDKs. { if (toolCall.function.name === "getCurrentTemperature") { return { tool_call_id: toolCall.id, output: "57", }; } else if (toolCall.function.name === "getRainProbability") { return { tool_call_id: toolCall.id, output: "0.06", }; } }); // Submit all the tool outputs at the same time await this.submitToolOutputs(toolOutputs, runId, threadId); } catch (error) { console.error("Error processing required action:", error); } }\n async submitToolOutputs(toolOutputs, runId, threadId) { try { // Use the submitToolOutputsStream helper const stream = this.client.beta.threads.runs.submitToolOutputsStream( threadId, runId, { tool_outputs: toolOutputs }, ); for await (const event of stream) { this.emit("event", event); } } catch (error) { console.error("Error submitting tool outputs:", error); } } }\n const eventHandler = new EventHandler(client); eventHandler.on("event", eventHandler.onEvent.bind(eventHandler));\n const stream = await client.beta.threads.runs.stream( threadId, { assistant_id: assistantId }, eventHandler, );\n for await (const event of stream) { eventHandler.emit("event", event); } `.trim(), }} />