Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: remove the latest message from the user that does not have any answer yet (#9297)

kurokobo857055b797b8
diff --git a/api/core/memory/token_buffer_memory.py b/api/core/memory/token_buffer_memory.py
index 72da3b0c6f2..bc94912c1eb 100644
--- a/api/core/memory/token_buffer_memory.py
+++ b/api/core/memory/token_buffer_memory.py
@@ -60,8 +60,8 @@ class TokenBufferMemory:
thread_messages = extract_thread_messages(messages)
# for newly created message, its answer is temporarily empty, we don't need to add it to memory
- if thread_messages and not thread_messages[-1].answer:
- thread_messages.pop()
+ if thread_messages and not thread_messages[0].answer:
+ thread_messages.pop(0)
messages = list(reversed(thread_messages))