mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: keep streamed Responses output when response.completed reports an empty output array (#27800)
The `response.completed` handler replaced the accumulated output with the terminal event's `output` whenever that key was present, guarded only by `is not None`. An empty array satisfies that guard, so a provider that finishes the stream with `"output": []` wiped everything collected from `response.output_item.added`, `response.output_text.delta` and `response.output_item.done`. The assistant message was then persisted with `output: []` and empty content, which shows up as a reply that renders correctly while streaming and disappears the moment the stream ends. Fall back to the accumulated output when the terminal array is empty. A spec-compliant `response.completed` still wins, since a populated array is truthy, and when nothing was streamed the accumulated output is empty too, so the fallback cannot invent content. Fixes #27789
This commit is contained in:
parent
ac8af4996c
commit
798f3935ae
1 changed files with 2 additions and 1 deletions
|
|
@ -775,7 +775,8 @@ def handle_responses_streaming_event(
|
|||
response_data = data.get('response', {})
|
||||
final_output = response_data.get('output')
|
||||
|
||||
new_output = final_output if final_output is not None else current_output
|
||||
# Some providers send an empty output on response.completed despite having streamed items
|
||||
new_output = final_output if final_output else current_output
|
||||
|
||||
# Ensure reasoning items are marked as completed in the final output
|
||||
if new_output:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue