fix: merged response receiving empty model responses after reload (#27673)

Clicking "Merged Response" in a multi-model chat often made the merging model answer with "It appears that the responses provided from the other models were empty".

The merge handler collected each model's answer via `history.messages[id].content`. Assistant messages are persisted by the backend with `output` only (`upsert_message_to_chat_by_id_and_message_id` writes `done`/`role`/`output`, never `content`), so `content` is only populated in the browser session that generated the responses, where the streaming handler mirrors it. Once the chat is reloaded from the database, every assistant message has `content: ''` and the merge request is sent with a list of empty strings, which is exactly what the merging model then reports. That is why the failure looks random: merging works right after generating, and fails after a refresh or when reopening the chat.

Read the responses through `getOutputText(message.output) || message.content`, the same fallback already used by every other read site (`ResponseMessage`, `Overview/Node`, `SearchModal`, `ChatItem`, `ChatMenu`, `Navbar/Menu`).

Fixes #26962
This commit is contained in:
Classic298
2026-08-10 23:31:21 -06:00
committed by GitHub
parent fcc130c9bb
commit 4eb0394511
@@ -9,6 +9,7 @@
import { createOpenAITextStream } from '$lib/apis/streaming';
import ResponseMessage from './ResponseMessage.svelte';
import { getOutputText } from './structuredOutput';
import Tooltip from '$lib/components/common/Tooltip.svelte';
import Merge from '$lib/components/icons/Merge.svelte';
@@ -227,7 +228,8 @@
const { messageIds } = groupedMessageIds[modelIdx];
const messageId = messageIds[groupedMessageIdsIdx[modelIdx]];
return history.messages[messageId].content;
const message = history.messages[messageId];
return getOutputText(message?.output) || message?.content || '';
});
mergeResponses(messageId, responses, chatId);
};