Streaming Assistant API returns [DONE] after "status":"requires_action"

… while the run is still “in_progress”

I’m using new streaming Assistant API on Node.js like this:

    const stream = await openai.beta.threads.runs.create(
      threadId,
      {
        assistant_id: process.env["OPENAI_ASSISTANT_ID"],
        stream: true,
      },
    );
    for await (const event of stream) {
       ...
    }

After I get event.event === "thread.run.requires_action" and call submitToolOutputs the client receives [END] and stream no longer emits new events, even though the run is still in_progress (if I immediately call openai.beta.threads.runs.retrieve I can see it). I’m not sure how to continue streaming the output.

I was wondering the same and looked here first. Then I went to the source code.

There is a submitToolOutputsStream method!

I’m using it like this when I get to a required actions state, after handling tool outputs:

const toolRun = openai.beta.threads.runs.submitToolOutputsStream(
  thread_id,
  run_id, {
    tool_outputs,
    stream: true,
  },
  streamOptions);

for await (const event of toolRun) {
  await handleEvent(event);
}
1 Like