Bug
OciClient.chat_stream() and OciClientV2.chat_stream() hang indefinitely after receiving all content from the OCI Generative AI service. The stream never terminates.
Root Cause
The OCI Generative AI SSE endpoint does not send a data: [DONE] marker to signal end-of-stream. Instead, it sends a final event containing finishReason and then keeps the HTTP connection open. The SDK's stream wrapper (transform_oci_stream_wrapper) relies on data: [DONE] to emit closing events (message-end for V2, stream-end for V1) and terminate the generator. Since [DONE] never arrives, the generator blocks forever on the next chunk read.
Raw OCI stream behavior:
data: {"apiFormat":"COHEREV2","message":{"role":"ASSISTANT","content":[{"type":"TEXT","text":"Hi"}]}}
data: {"apiFormat":"COHEREV2","message":{"role":"ASSISTANT","content":[{"type":"TEXT","text":"!"}]}}
data: {"apiFormat":"COHEREV2","message":{"role":"ASSISTANT"},"finishReason":"COMPLETE"}
... connection stays open indefinitely, no [DONE] ...
Impact
- Both V1 (
OciClient) and V2 (OciClientV2) streaming are affected
chat_stream() calls never return
- All OCI regions affected (tested on us-chicago-1)
Fix
When finishReason is present in an OCI event, emit closing events and return from the generator immediately, instead of waiting for [DONE]. The [DONE] path is preserved as a fallback for forward compatibility.
PR: (will link)
Bug
OciClient.chat_stream()andOciClientV2.chat_stream()hang indefinitely after receiving all content from the OCI Generative AI service. The stream never terminates.Root Cause
The OCI Generative AI SSE endpoint does not send a
data: [DONE]marker to signal end-of-stream. Instead, it sends a final event containingfinishReasonand then keeps the HTTP connection open. The SDK's stream wrapper (transform_oci_stream_wrapper) relies ondata: [DONE]to emit closing events (message-endfor V2,stream-endfor V1) and terminate the generator. Since[DONE]never arrives, the generator blocks forever on the next chunk read.Raw OCI stream behavior:
Impact
OciClient) and V2 (OciClientV2) streaming are affectedchat_stream()calls never returnFix
When
finishReasonis present in an OCI event, emit closing events and return from the generator immediately, instead of waiting for[DONE]. The[DONE]path is preserved as a fallback for forward compatibility.PR: (will link)