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
This commit is contained in:
Classic298 2026-10-25 01:07:21 +02:00 • committed by GitHub
parent ece6bc1a55
commit c69e5a73c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View file

@ -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),

View file

@ -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

View file

@ -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