RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Refactor: Remove the brute-force deduplication method for agent logs. (#12864)
balibabufe99905a2b10
diff --git a/web/src/locales/en.ts b/web/src/locales/en.tsindex 4573659d28..732a5a5c6e 100644--- a/web/src/locales/en.ts+++ b/web/src/locales/en.ts@@ -2235,7 +2235,7 @@ Important structured information may include: names, dates, locations, events, k'Accepted Response: The system returns an acknowledgment immediately after the request is validated, while the workflow continues to execute asynchronously in the background. /Final Response: The system returns a response only after the workflow execution is completed.',authMethods: 'Authentication methods',authType: 'Authentication type',- limit: 'Request limit',+ limit: 'Request frequency limit',per: 'Time period',maxBodySize: 'Maximum body size',ipWhitelist: 'IP whitelist',diff --git a/web/src/pages/agent/canvas/index.tsx b/web/src/pages/agent/canvas/index.tsxindex ebf2619150..074bd828a7 100644--- a/web/src/pages/agent/canvas/index.tsx+++ b/web/src/pages/agent/canvas/index.tsx@@ -157,10 +157,10 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {currentEventListWithoutMessageById,clearEventList,currentMessageId,- currentTaskId,+ latestTaskId,} = useCacheChatLog();- const { stopMessage } = useStopMessageUnmount(chatVisible, currentTaskId);+ const { stopMessage } = useStopMessageUnmount(chatVisible, latestTaskId);const { showLogSheet, logSheetVisible, hideLogSheet } = useShowLogSheet({setCurrentMessageId,@@ -179,10 +179,10 @@ function AgentCanvas({ drawerVisible, hideDrawer }: IProps) {useEffect(() => {if (!chatVisible) {- stopMessage(currentTaskId);+ stopMessage(latestTaskId);clearEventList();}- }, [chatVisible, clearEventList, currentTaskId, stopMessage]);+ }, [chatVisible, clearEventList, latestTaskId, stopMessage]);const setLastSendLoadingFunc = (loading: boolean, messageId: string) => {setCurrentSendLoading(!!loading);diff --git a/web/src/pages/agent/hooks/use-cache-chat-log.ts b/web/src/pages/agent/hooks/use-cache-chat-log.tsindex 7e67cdd0b6..45fa6b7f46 100644--- a/web/src/pages/agent/hooks/use-cache-chat-log.ts+++ b/web/src/pages/agent/hooks/use-cache-chat-log.ts@@ -3,7 +3,8 @@ import {INodeEvent,MessageEventType,} from '@/hooks/use-send-message';-import { useCallback, useEffect, useMemo, useState } from 'react';+import { get, isEmpty } from 'lodash';+import { useCallback, useMemo, useState } from 'react';export const ExcludeTypes = [MessageEventType.Message,@@ -11,15 +12,13 @@ export const ExcludeTypes = [];export function useCacheChatLog() {- const [eventList, setEventList] = useState<IEventList>([]);const [messageIdPool, setMessageIdPool] = useState<Record<string, IEventList>>({});+ const [latestTaskId, setLatestTaskId] = useState('');+const [currentMessageId, setCurrentMessageId] = useState('');- useEffect(() => {- setMessageIdPool((prev) => ({ ...prev, [currentMessageId]: eventList }));- }, [currentMessageId, eventList]);const filterEventListByMessageId = useCallback((messageId: string) => {@@ -40,16 +39,26 @@ export function useCacheChatLog() {);const clearEventList = useCallback(() => {- setEventList([]);setMessageIdPool({});}, []);const addEventList = useCallback((events: IEventList, message_id: string) => {- setEventList((x) => {- const list = [...x, ...events];- setMessageIdPool((prev) => ({ ...prev, [message_id]: list }));- return list;- });+ if (!isEmpty(events)) {+ const taskId = get(events, '0.task_id');+ setLatestTaskId(taskId);++ setMessageIdPool((prev) => {+ const list = [...(prev[message_id] ?? [])];++ events.forEach((event) => {+ if (!list.some((y) => y === event)) {+ list.push(event);+ }+ });++ return { ...prev, [message_id]: list };+ });+ }}, []);const currentEventListWithoutMessage = useMemo(() => {@@ -73,21 +82,15 @@ export function useCacheChatLog() {[messageIdPool],);- const currentTaskId = useMemo(() => {- return eventList.at(-1)?.task_id;- }, [eventList]);-return {- eventList,currentEventListWithoutMessage,currentEventListWithoutMessageById,- setEventList,clearEventList,addEventList,filterEventListByEventType,filterEventListByMessageId,setCurrentMessageId,currentMessageId,- currentTaskId,+ latestTaskId,};}diff --git a/web/src/pages/agent/log-sheet/workflow-timeline.tsx b/web/src/pages/agent/log-sheet/workflow-timeline.tsxindex 5fdb8c3ccf..59776907cd 100644--- a/web/src/pages/agent/log-sheet/workflow-timeline.tsx+++ b/web/src/pages/agent/log-sheet/workflow-timeline.tsx@@ -22,7 +22,7 @@ import {import { ITraceData } from '@/interfaces/database/agent';import { cn } from '@/lib/utils';import { t } from 'i18next';-import { get, isEmpty, isEqual, uniqWith } from 'lodash';+import { get, isEmpty } from 'lodash';import { useCallback, useEffect, useMemo } from 'react';import { Operator } from '../constant';import { JsonViewer } from '../form/components/json-viewer';@@ -88,7 +88,7 @@ function getInputsOrOutputs(return inputsOrOutputs[0] || {};}- return uniqWith(inputsOrOutputs, isEqual); // TODO: Violence should not be used to+ return inputsOrOutputs;}export const WorkFlowTimeline = ({currentEventListWithoutMessage,