Skip to content

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

Fix: UI chat should pass pass_all_history_messages=false in 1.0 go (#19602)

balibabufcaad5716f0a
diff --git a/web/src/pages/next-chats/hooks/use-send-single-message.ts b/web/src/pages/next-chats/hooks/use-send-single-message.ts
index 5bb575249d..76737df99f 100644
--- a/web/src/pages/next-chats/hooks/use-send-single-message.ts
+++ b/web/src/pages/next-chats/hooks/use-send-single-message.ts
@@ -8,6 +8,7 @@ import {
import { useGetChatSearchParams } from '@/hooks/use-chat-request';
import { IMessage } from '@/interfaces/database/chat';
import api from '@/utils/api';
+import { useIsGoBackend } from '@/utils/backend-variant';
import { trim } from 'lodash';
import { useCallback, useEffect } from 'react';
import { useParams } from 'react-router';
@@ -32,6 +33,7 @@ export function useSendSingleMessage({
Pick<ReturnType<typeof useUploadFile>, 'files' | 'clearFiles'>) {
const { conversationId } = useGetChatSearchParams();
const { id: chatId } = useParams();
+ const isGoBackend = useIsGoBackend();
const { send, answer, done } = useSendMessageWithSse();
@@ -86,7 +88,10 @@ export function useSendSingleMessage({
...(storeHistoryMessages === undefined
? {}
: { store_history_messages: storeHistoryMessages }),
- pass_all_history_messages: true,
+ // The Go backend owns session history server-side and appends the
+ // new question; the Python backend is overwritten with the
+ // client-sent list.
+ pass_all_history_messages: !isGoBackend,
},
controller,
);
@@ -106,6 +111,7 @@ export function useSendSingleMessage({
setValue,
send,
controller,
+ isGoBackend,
],
);
diff --git a/web/src/services/chat-completion-stream.ts b/web/src/services/chat-completion-stream.ts
index 58b242daee..5b9c817aa8 100644
--- a/web/src/services/chat-completion-stream.ts
+++ b/web/src/services/chat-completion-stream.ts
@@ -14,6 +14,7 @@ import { ResponseType } from '@/interfaces/database/base';
import { IMessage, Variable } from '@/interfaces/database/chat';
import api from '@/utils/api';
import { getAuthorization } from '@/utils/authorization-util';
+import { pickByBackend } from '@/utils/backend-variant';
import { EventSourceParserStream } from 'eventsource-parser/stream';
export type ChatCompletionStreamParams = {
@@ -69,7 +70,9 @@ export function requestChatCompletionStream(
chat_id: chatId,
session_id: sessionId,
messages,
- pass_all_history_messages: true,
+ // The Go backend owns session history server-side and appends the new
+ // question; the Python backend is overwritten with the client-sent list.
+ pass_all_history_messages: pickByBackend({ go: false, python: true }),
reasoning: Number(enableThinking),
internet: enableInternet,
...(temperature === undefined ? {} : { temperature }),