mirror of
https://github.com/open-webui/open-webui.git
synced 2026-12-01 01:12:43 -05:00
fix: model answers the previous question after compaction between tool calls (#35375)
When context compaction ran between tool calls and the messages it kept still included an earlier question, the current prompt was moved in front of that earlier question. The model then saw the previous question as the latest one and answered it again. The current prompt now stays in its place when it is still among the kept messages, and is only put back in front of them when compaction removed it. Fixes #35366
This commit is contained in:
1 parent
52cda2507a
commit
588d58b9ff
1 file changed
+1
-2
@@ -6490,8 +6490,7 @@ async def streaming_chat_response_handler(response, ctx):
|
||||
for message, content in user_messages:
|
||||
message['content'] = content
|
||||
if compacted:
|
||||
if user_prompt is not None:
|
||||
messages = [message for message in messages if message != user_prompt]
|
||||
if user_prompt is not None and user_prompt not in messages:
|
||||
messages.insert(
|
||||
1 if messages and messages[0].get('role') == 'system' else 0,
|
||||
dict(user_prompt),
|
||||
|
||||
Reference in new issue
Block a user