From c69e5a73c0de43691e502bfaa03285e4e8cec05d Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 25 Oct 2026 01:07:21 +0200 Subject: [PATCH] fix: "More Concise" and "Add Details" now revise the reply instead of answering the instruction (#33084) Choosing Add Details, More Concise, or typing a suggestion under a reply sent the model your original question followed straight by the bare instruction, with the reply itself missing, so it answered the instruction on its own (for example "OK, I'll keep answers shorter") instead of rewriting that reply. The model now receives the reply it is being asked to change, so it returns a shorter, more detailed or altered version of it. Plain Try Again and temporary chats were not affected. Fixes #33083 --- backend/open_webui/main.py | 1 + backend/open_webui/utils/middleware.py | 7 +++++++ src/lib/components/chat/Chat.svelte | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index b18224fb7f..2c35a44503 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1325,6 +1325,7 @@ async def chat_completion( 'user_message': user_message, 'user_message_id': user_message.get('id') if user_message else None, 'assistant_message_id': form_data.pop('assistant_message_id', None), + 'regeneration_message_id': form_data.pop('regeneration_message_id', None), 'session_id': form_data.pop('session_id', None), 'automation_id': automation_id, 'folder_id': form_data.pop('folder_id', None), diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 9bf25e7f82..5a279162fe 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -2110,6 +2110,13 @@ async def process_chat_payload(request, form_data, user, metadata, model): if metadata.get('tool_approval_resume') == 'tools' or pending_tool_calls(output): pending_assistant_message = assistant_message + # Guided regeneration: show the model the reply it is asked to revise. + regeneration_message_id = metadata.get('regeneration_message_id') + if regeneration_message_id: + regenerated_message = await Chats.get_message_by_id_and_message_id(chat_id, regeneration_message_id) + if regenerated_message and (regenerated_message.get('content') or regenerated_message.get('output')): + db_messages.append({k: v for k, v in regenerated_message.items() if k in MESSAGE_REPLAY_KEYS}) + system_message = get_system_message(form_data.get('messages', [])) form_data['messages'] = [system_message, *db_messages] if system_message else db_messages diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 0b3df2aae5..9fbb57f580 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -4008,12 +4008,14 @@ messages = null, modelId = null, modelIdx = null, - regenerationPrompt = null + regenerationPrompt = null, + regenerationMessageId = null }: { messages?: any[] | null; modelId?: string | null; modelIdx?: number | null; regenerationPrompt?: string | null; + regenerationMessageId?: string | null; } = {} ) => { const parent = _history.messages[parentId]; @@ -4150,7 +4152,8 @@ // regenerations in a duplicate-model chat, which would otherwise lose their // column identity and collapse on reload. messageIdsList: messageIdsList.length > 0 ? messageIdsList : undefined, - regenerationPrompt + regenerationPrompt, + regenerationMessageId } ); submittedTaskIds = @@ -4218,10 +4221,12 @@ { messageIdsList, regenerationPrompt, + regenerationMessageId, continueResponse = false }: { messageIdsList?: Array<{ model_id: string; message_id: string }>; regenerationPrompt?: string | null; + regenerationMessageId?: string | null; continueResponse?: boolean; } = {} ) => { @@ -4434,6 +4439,7 @@ parent_id: userMessage?.parentId ?? null, user_message: userMessage, ...(regenerationPrompt ? { regeneration_prompt: regenerationPrompt } : {}), + ...(regenerationMessageId ? { regeneration_message_id: regenerationMessageId } : {}), ...(continueResponse ? { assistant_message_id: responseMessageId } : {}), background_tasks: { @@ -4674,7 +4680,8 @@ ...(suggestionPrompt ? { messages: createMessagesList(history, message.id), - regenerationPrompt: suggestionPrompt + regenerationPrompt: suggestionPrompt, + regenerationMessageId: message.id } : {}), ...((userMessage?.models ?? [...selectedModels]).length > 1