mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: question and answer vanish from the chat when a background sub-agent finishes before the answer (#31557)
When a background sub-agent finished while the model was still writing the answer that started it, the sub-agent's report was placed as a reply to the previous answer instead. Once the answer ended, the chat switched to that other branch of the conversation, which hid the latest question and answer, and the model replied to the report without seeing that question and answer. The report now follows the answer that started the sub-agent (or the newest completed reply after it), so the conversation stays on one branch. Fixes #31507
This commit is contained in:
parent
f98ca224c5
commit
d7a74450b5
1 changed files with 8 additions and 2 deletions
|
|
@ -615,10 +615,16 @@ async def delegate(
|
|||
updated_chat = copy.deepcopy(parent.chat or {})
|
||||
updated_history = updated_chat.setdefault('history', {})
|
||||
updated_messages = updated_history.setdefault('messages', {})
|
||||
parent_message = updated_messages.get(parent_message_id)
|
||||
done_assistants = [
|
||||
message
|
||||
for message in updated_messages.values()
|
||||
if message.get('role') == 'assistant' and message.get('done') is not False
|
||||
for message_id, message in updated_messages.items()
|
||||
if message.get('role') == 'assistant'
|
||||
and message.get('done') is not False
|
||||
and (
|
||||
parent_message is None
|
||||
or any(entry is parent_message for entry in get_message_list(updated_messages, message_id))
|
||||
)
|
||||
]
|
||||
result_parent_id = (
|
||||
max(done_assistants, key=lambda message: message.get('timestamp', 0)).get('id')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue