Fix OpenAI streaming returning no output for reasoning models

The SSE stream terminated prematurely when a network chunk contained
only unhandled event types (e.g. response.in_progress, reasoning
output_item.added). dispatch_sse_messages returned an empty vec, which
the unfold interpreted as stream-end. Now continues reading when
dispatch produces no StreamEvents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-02-23 09:12:40 -05:00
parent 433a7c6247
commit 55b6000374

View file

@ -527,7 +527,12 @@ async fn process_next_sse_events(
loop {
let messages = extract_sse_messages(&mut state.buffer);
if !messages.is_empty() {
return Ok(dispatch_sse_messages(state, messages));
let events = dispatch_sse_messages(state, messages);
if !events.is_empty() {
return Ok(events);
}
// All SSE messages were unhandled event types; continue reading.
continue;
}
match tokio::time::timeout(state.stream_read_timeout, state.byte_stream.next()).await {