Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: truncate message issue. (#5765)

Kevin Hu64c6cc4cf3d0
diff --git a/rag/prompts.py b/rag/prompts.py
index 7c0f23be94..6bc6a4659c 100644
--- a/rag/prompts.py
+++ b/rag/prompts.py
@@ -70,7 +70,7 @@ def message_fit_in(msg, max_length=4000):
if c < max_length:
return c, msg
- msg_ = [m for m in msg[:-1] if m["role"] == "system"]
+ msg_ = [m for m in msg if m["role"] == "system"]
if len(msg) > 1:
msg_.append(msg[-1])
msg = msg_