Assistants Streaming not conformant with SSE spec?

I maintain this 3rd party openai elixir wrapper , and I’m having problems with the Run streaming API.

According to the SSE spec, a field is terminated by 2 EOL chars.

In this case, based on what I’m seeing (as well as example from the API docs, part of which is shown below), it appears that the ‘event’ field only has one EOL before the ‘data’ field. So a correct SSE parser will not see the ‘data’ as an event. It will be included in the value of the ‘event’ event. This is particularly problematic for the final “data: [DONE]” value.

Working around it is do-able, but it breaks the SSE spec. I’m wondering if this deviation from the spec is deliberate, or something that might be fixed in the future.

event: thread.run.step.in_progress
data: {"id":"step_001","object":"thread.run.step","created_at":1710330641,"run_id":"run_123","assistant_id":"asst_123","thread_id":"thread_123","type":"message_creation","status":"in_progress","cancelled_at":null,"completed_at":null,"expires_at":1710331240,"failed_at":null,"last_error":null,"step_details":{"type":"message_creation","message_creation":{"message_id":"msg_001"}},"usage":null}

event: thread.message.created
data: {"id":"msg_001","object":"thread.message","created_at":1710330641,"assistant_id":"asst_123","thread_id":"thread_123","run_id":"run_123","status":"in_progress","incomplete_details":null,"incomplete_at":null,"completed_at":null,"role":"assistant","content":[],"metadata":{}}
1 Like

I have worked around this issue, and am assuming that it will stay as is.