Skip to content

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

fix(chat): relocate decision model to agentic settings and allow inheriting it (#21386)

chanx0da322950ce9
diff --git a/web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx b/web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
index e04fca4a6f..16160e3f62 100644
--- a/web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
+++ b/web/src/pages/next-chats/chat/app-settings/chat-prompt-engine.tsx
@@ -112,13 +112,6 @@ export function ChatPromptEngine({
label={t('chat.keyword')}
tooltip={t('chat.keywordTip')}
></SwitchFormField>
- <ModelTreeSelectFormField
- name={prefixName(prefix, 'decision_id')}
- label={t('chat.decisionModel')}
- tooltip={t('chat.decisionModelTip')}
- modelTypes={ModelTypeMap.decision_id}
- allowClear
- />
<FormField
control={form.control}
name={prefixName(prefix, 'prompt_config.system')}
@@ -171,10 +164,19 @@ export function ChatPromptEngine({
open={agenticSettingOpen}
onOpenChange={onAgenticSettingOpenChange}
>
- <AgenticTemplateFormField
- name={prefixName(prefix, 'prompt_config.agentic_rag.content')}
- config={agenticConfig}
- />
+ <div className="space-y-8">
+ <ModelTreeSelectFormField
+ name={prefixName(prefix, 'decision_id')}
+ label={t('chat.decisionModel')}
+ tooltip={t('chat.decisionModelTip')}
+ modelTypes={ModelTypeMap.decision_id}
+ allowClear
+ />
+ <AgenticTemplateFormField
+ name={prefixName(prefix, 'prompt_config.agentic_rag.content')}
+ config={agenticConfig}
+ />
+ </div>
</Collapse>
</div>
</Collapse>
diff --git a/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx b/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
index 7cc56040af..e0ab55cc0d 100644
--- a/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
+++ b/web/src/pages/next-chats/chat/app-settings/chat-settings.tsx
@@ -132,6 +132,14 @@ export function ChatSettings({ hasSingleChatBox }: ChatSettingsProps) {
agentic_rag: agenticRag,
};
+ // The decision TreeSelect clears to '', but the backend reads only a
+ // missing key / null as "inherit the tenant default" and would treat ''
+ // as a literal empty model id. Normalise at the point where form values
+ // become the wire payload, so clearing the override really persists.
+ if (nextValues.decision_id === '') {
+ nextValues.decision_id = null;
+ }
+
updateChat({
chatId: id!,
params: {
diff --git a/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx b/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx
index 5b00ecf401..aa4553f7ef 100644
--- a/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx
+++ b/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx
@@ -93,8 +93,11 @@ export function buildChatSettingFormSchema(t: (key: string) => string) {
...LlmSettingEnabledSchema,
llm_id: z.string().optional(),
// Empty means "inherit the tenant default": most chats never override
- // the decision model, and clearing the field must be expressible.
- decision_id: z.string().optional(),
+ // the decision model, so the backend returns null for them and clearing
+ // must be expressible. optional() alone only permits undefined, so a
+ // loaded null would fail validation and block every save — nullable()
+ // is required to represent the inherited state.
+ decision_id: z.string().nullable().optional(),
...keywordsSimilarityWeightSchema,
...similarityThresholdSchema,
...topnSchema,
diff --git a/web/src/pages/user-setting/setting-model/layout/system-setting.tsx b/web/src/pages/user-setting/setting-model/layout/system-setting.tsx
index cd7248ac30..d1f8a38ce2 100644
--- a/web/src/pages/user-setting/setting-model/layout/system-setting.tsx
+++ b/web/src/pages/user-setting/setting-model/layout/system-setting.tsx
@@ -108,15 +108,6 @@ function SystemSetting() {
value: defaultModelDictionary.llm_id ?? '',
tooltip: t('chatModelTip'),
},
- {
- // The decision model judges whether a retrieved passage is worth
- // putting in front of the chat model. It sits next to the chat model
- // because it is chosen the same way and independently of it.
- id: 'decision_id',
- label: t('decisionModel'),
- value: defaultModelDictionary.decision_id ?? '',
- tooltip: t('decisionModelTip'),
- },
{
id: 'embd_id',
label: t('embeddingModel'),
@@ -147,6 +138,15 @@ function SystemSetting() {
value: defaultModelDictionary.tts_id ?? '',
tooltip: t('ttsModelTip'),
},
+ {
+ // The decision model judges whether a retrieved passage is worth
+ // putting in front of the chat model. It sits next to the chat model
+ // because it is chosen the same way and independently of it.
+ id: 'decision_id',
+ label: t('decisionModel'),
+ value: defaultModelDictionary.decision_id ?? '',
+ tooltip: t('decisionModelTip'),
+ },
];
}, [defaultModelDictionary, t]);