Skip to content

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

Feat: Fixed an issue where modifying fields in the agent operator caused the loss of structured data. #10427 (#11388)

balibabucfdccebb178b
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index e49f97ed14..38bc6c2122 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -1855,7 +1855,7 @@ Important structured information may include: names, dates, locations, events, k
desc: 'Descending',
},
variableAssignerLogicalOperatorOptions: {
- overwrite: 'Overwrite',
+ overwrite: 'Overwritten By',
clear: 'Clear',
set: 'Set',
'+=': 'Add',
diff --git a/web/src/pages/agent/form/agent-form/index.tsx b/web/src/pages/agent/form/agent-form/index.tsx
index 83e68e23bc..2b23010cdb 100644
--- a/web/src/pages/agent/form/agent-form/index.tsx
+++ b/web/src/pages/agent/form/agent-form/index.tsx
@@ -22,12 +22,13 @@ import { Switch } from '@/components/ui/switch';
import { LlmModelType } from '@/constants/knowledge';
import { useFindLlmByUuid } from '@/hooks/use-llm-request';
import { zodResolver } from '@hookform/resolvers/zod';
-import { memo, useEffect, useMemo } from 'react';
+import { memo, useCallback, useEffect, useMemo } from 'react';
import { useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import {
AgentExceptionMethod,
+ AgentStructuredOutputField,
NodeHandleId,
VariableType,
} from '../../constant';
@@ -127,6 +128,17 @@ function AgentForm({ node }: INextOperatorForm) {
handleStructuredOutputDialogOk,
} = useShowStructuredOutputDialog(node?.id);
+ const updateNodeForm = useGraphStore((state) => state.updateNodeForm);
+
+ const handleShowStructuredOutput = useCallback(
+ (val: boolean) => {
+ if (node?.id && val) {
+ updateNodeForm(node?.id, {}, ['outputs', AgentStructuredOutputField]);
+ }
+ },
+ [node?.id, updateNodeForm],
+ );
+
useEffect(() => {
if (exceptionMethod !== AgentExceptionMethod.Goto) {
if (node?.id) {
@@ -293,7 +305,10 @@ function AgentForm({ node }: INextOperatorForm) {
<Switch
id="airplane-mode"
checked={field.value}
- onCheckedChange={field.onChange}
+ onCheckedChange={(val) => {
+ handleShowStructuredOutput(val);
+ field.onChange(val);
+ }}
/>
</div>
)}
diff --git a/web/src/pages/agent/form/agent-form/use-watch-change.ts b/web/src/pages/agent/form/agent-form/use-watch-change.ts
index 9cd7932891..7c53a8d40e 100644
--- a/web/src/pages/agent/form/agent-form/use-watch-change.ts
+++ b/web/src/pages/agent/form/agent-form/use-watch-change.ts
@@ -17,20 +17,13 @@ export function useWatchFormChange(id?: string, form?: UseFormReturn<any>) {
prompts: [{ role: PromptRole.User, content: values.prompts }],
};
- if (values.showStructuredOutput) {
- nextValues = {
- ...nextValues,
- outputs: {
- ...values.outputs,
- [AgentStructuredOutputField]:
- values[AgentStructuredOutputField] ?? {},
- },
- };
- } else {
+ if (!values.showStructuredOutput) {
nextValues = {
...nextValues,
outputs: omit(values.outputs, [AgentStructuredOutputField]),
};
+ } else {
+ nextValues = omit(nextValues, 'outputs');
}
updateNodeForm(id, nextValues);
}