Repository navigation
[fix]: OpenAI provider - report a Responses stream that ends without a terminal event #10288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
88a3597
dee02c4
c008f35
96bc6bf
598c372
fda67ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2629,12 +2629,11 @@ func HandleOpenAIResponsesStreaming( | |
|
|
||
| // The loop returns as soon as a terminal event (completed / incomplete / | ||
| // failed / error) arrives, so falling out of it means the body ended without | ||
| // one. A plain io.EOF cannot distinguish that from a healthy close, so | ||
| // surface it rather than closing the channel silently — a silent close is | ||
| // indistinguishable to the client from a stream that just stopped emitting. | ||
| if !providerUtils.SSEStreamEndedOnMarker(sseReader) { | ||
| providerUtils.SendStreamTruncatedError(ctx, postHookRunner, responseChan, logger, postHookSpanFinalizer, jsonBody) | ||
| } | ||
| // one. A Responses stream must end with a terminal event, so this is a | ||
| // truncation even when [DONE] arrived. Surface it rather than closing the | ||
| // channel silently: with no error and no final chunk, the client and the | ||
| // post-hooks never see the request end. | ||
| providerUtils.SendStreamTruncatedError(ctx, postHookRunner, responseChan, logger, postHookSpanFinalizer, jsonBody) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this handler is shared by 14 providers' Responses streams (Azure, xAI, Fireworks, OpenRouter, Perplexity, vLLM, Databricks, Bedrock runtime and Mantle, Bedrock Mantle, BytePlus, OpenCode, GitHub Copilot, Baseten), so from this change any of those upstreams that ends a Responses stream with |
||
| }() | ||
|
|
||
| return responseChan, nil | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (follow-up, not caused by this PR):
SendStreamTruncatedErrorbills what it finds inBifrostContextKeyStreamAccumulatedUsage(core/providers/utils/utils.go:4491), but this Responses loop never sets that key (only the chat paths do,openai.go:741and:1488), and Responses usage only arrives onresponse.completed. So a stream truncated after many deltas is logged and billed with zero tokens. Not needed here, but worth an issue: either record usage fromresponse.in_progress/ output deltas into that key, or state that truncated Responses streams are unbilled.