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.

chore: optimize memory messages fetch count limit (#6021)

takatost23dc6edb99db
diff --git a/api/core/memory/token_buffer_memory.py b/api/core/memory/token_buffer_memory.py
index 4f4f5045f52..f38175020cc 100644
--- a/api/core/memory/token_buffer_memory.py
+++ b/api/core/memory/token_buffer_memory.py
@@ -36,9 +36,11 @@ class TokenBufferMemory:
).order_by(Message.created_at.desc())
if message_limit and message_limit > 0:
- messages = query.limit(message_limit).all()
+ message_limit = message_limit if message_limit <= 500 else 500
else:
- messages = query.all()
+ message_limit = 500
+
+ messages = query.limit(message_limit).all()
messages = list(reversed(messages))
message_file_parser = MessageFileParser(