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

### What problem does this PR solve?

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

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2026-01-26 17:54:30 +08:00
committed by GitHub
parent 41905e2569
commit e04cd99ae2
2 changed files with 14 additions and 1 deletions

View File

@ -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}}`;

View File

@ -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 ?? {};
},
});