From 743a46bdcd04f4026f5bcff594942b7ee093120c Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 3 Oct 2026 15:06:03 +0200 Subject: [PATCH] fix: chat stays broken after a reply is stopped or fails before any text (#31892) When a reply was stopped or failed before the model sent any text, the chat kept an empty reply, and every later message in that chat sent it back to the model as part of the conversation. Providers that reject empty assistant messages then refused every new request, so the chat stayed unusable unless the empty reply was deleted from the database by hand. Empty replies are now skipped when the conversation is sent to the model, as replies that ended in an error already were. Chats already stuck like this work again on their next message, since nothing stored has to change. Fixes #25083 --- backend/open_webui/utils/middleware.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 0b67c6deed..c6c0ed83c1 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2229,9 +2229,7 @@ async def load_messages_from_db(chat_id: str, message_id: str) -> Optional[list[ return [ {k: v for k, v in msg.items() if k in MESSAGE_REPLAY_KEYS} for msg in db_messages - if not ( - msg.get('role') == 'assistant' and msg.get('error') and not msg.get('content') and not msg.get('output') - ) + if not (msg.get('role') == 'assistant' and not msg.get('content') and not msg.get('output')) ]