Skip to content

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

Feat: Add the history field to the agent's system variables. #7322 (#12823)

balibabue04cd99ae224
diff --git a/web/src/constants/agent.tsx b/web/src/constants/agent.tsx
index 631f52ec22..9521bafa24 100644
--- a/web/src/constants/agent.tsx
+++ b/web/src/constants/agent.tsx
@@ -27,6 +27,7 @@ export enum AgentGlobals {
SysUserId = 'sys.user_id',
SysConversationTurns = 'sys.conversation_turns',
SysFiles = 'sys.files',
+ SysHistory = 'sys.history',
}
export const AgentGlobalsSysQueryWithBrace = `{${AgentGlobals.SysQuery}}`;
diff --git a/web/src/hooks/use-agent-request.ts b/web/src/hooks/use-agent-request.ts
index 482677acd3..cea6fb25af 100644
--- a/web/src/hooks/use-agent-request.ts
+++ b/web/src/hooks/use-agent-request.ts
@@ -29,7 +29,7 @@ import api from '@/utils/api';
import { buildMessageListWithUuid } from '@/utils/chat';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useDebounce } from 'ahooks';
-import { get, set } from 'lodash';
+import { get, isEmpty, set } from 'lodash';
import { useCallback, useState } from 'react';
import { useParams, useSearchParams } from 'react-router';
import {
@@ -103,6 +103,7 @@ export const EmptyDsl = {
[AgentGlobals.SysUserId]: '',
[AgentGlobals.SysConversationTurns]: 0,
[AgentGlobals.SysFiles]: [],
+ [AgentGlobals.SysHistory]: [],
},
};
@@ -268,6 +269,17 @@ export const useFetchAgent = (): {
);
set(data, 'data.dsl.messages', messageList);
+ const sysHistoryPath = [
+ 'data',
+ 'dsl',
+ 'globals',
+ AgentGlobals.SysHistory,
+ ];
+
+ if (isEmpty(get(data, sysHistoryPath))) {
+ set(data, sysHistoryPath, []);
+ }
+
return data?.data ?? {};
},
});