Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(frontend): expose history and retrieval retention to smart-reasoning agents

ochan.kwonfc9d6f8c347c
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index e436437fe..1a625a578 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -983,6 +983,7 @@ export default {
allowedTools: 'Allowed Tools',
multiTurn: 'Multi-turn Conversation',
historyTurns: 'History Turns',
+ retainRetrievalHistory: 'Keep retrieval results',
memoryEnabled: 'Long-term Memory',
retrievalStrategy: 'Retrieval Strategy',
embeddingTopK: 'Embedding Top K',
@@ -5266,8 +5267,10 @@ export default {
maxTokens: 'Maximum number of tokens for model-generated responses',
thinking: 'Enable extended thinking capability (requires model support)',
conversationSection: 'Configure multi-turn conversation and query rewriting parameters',
+ conversationSectionAgent: 'How much earlier conversation each turn carries. Smart reasoning is always multi-turn',
multiTurn: 'When enabled, historical conversation context will be preserved',
historyRounds: 'Number of recent conversation rounds to keep as context',
+ retainRetrievalHistory: 'Keep knowledge base results from earlier turns. When off, each turn searches again',
rewrite: 'Automatically rewrite user questions in multi-turn conversations to resolve references and omissions',
memoryEnabled: 'Let this agent read and add to your long-term memory. When off, conversations with it neither read your memories nor add new ones. Turning it on here has no effect while the workspace or personal switch is off',
queryUnderstandModel: 'Model used for query understanding (rewriting and intent detection). Leave empty to reuse the main chat model.',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index e3781e30d..b53422b95 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -1103,8 +1103,10 @@ export default {
maxTokens: '모델이 생성하는 응답의 최대 토큰 수',
thinking: '모델의 확장 사고 기능 활성화 (모델 지원 필요)',
conversationSection: '다중 턴 대화 및 질문 재작성 관련 매개변수 설정',
+ conversationSectionAgent: '매 턴에 실어 보낼 이전 대화 분량 설정 (스마트 추론은 항상 다중 턴)',
multiTurn: '활성화하면 대화 기록 컨텍스트가 유지됩니다',
historyRounds: '컨텍스트로 유지할 최근 대화 라운드 수',
+ retainRetrievalHistory: '이전 턴의 지식베이스 검색 결과를 유지합니다. 끄면 매 턴 새로 검색합니다',
rewrite: '다중 턴 대화에서 사용자 질문을 자동으로 재작성하여 지시대명사 해소 및 생략 보완',
memoryEnabled: '이 에이전트가 장기 기억을 읽고 추가하도록 허용합니다. 끄면 이 에이전트와의 대화에서 기억을 읽지도, 새로 추가하지도 않습니다. 공간 또는 개인 설정이 꺼져 있으면 여기서 켜도 적용되지 않습니다',
queryUnderstandModel: '질문 이해(재작성과 의도 분류)에 사용할 모델입니다. 비워 두면 기본 대화 모델을 사용합니다.',
@@ -5457,6 +5459,7 @@ export default {
allowedTools: '허용된 도구',
multiTurn: '여러 라운드의 대화',
historyTurns: '라운드 수를 유지하세요',
+ retainRetrievalHistory: '검색 결과 유지',
memoryEnabled: '장기 기억',
retrievalStrategy: '검색 전략',
embeddingTopK: '벡터 회수 횟수',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index c54f08922..bcfed2c39 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -1103,8 +1103,10 @@ export default {
maxTokens: 'Максимальное количество токенов в ответе модели',
thinking: 'Включить расширенное мышление модели (требуется поддержка модели)',
conversationSection: 'Настройка параметров многооборотного диалога и перефразирования вопросов',
+ conversationSectionAgent: 'Объём предыдущего диалога в каждом ходе. Умные рассуждения всегда многооборотные',
multiTurn: 'При включении сохраняется контекст истории диалога',
historyRounds: 'Количество последних раундов диалога для сохранения в контексте',
+ retainRetrievalHistory: 'Сохранять результаты поиска из прошлых ходов. При отключении каждый ход ищет заново',
rewrite: 'Автоматическое перефразирование вопросов в многооборотном диалоге для разрешения ссылок и дополнения',
memoryEnabled: 'Разрешить этому агенту читать и пополнять вашу долговременную память. При выключении разговоры с ним не читают ваши записи и не добавляют новые. Если память выключена в настройках пространства или в личных настройках, включение здесь не подействует',
queryUnderstandModel: 'Модель для понимания запроса (перефразирование и распознавание намерения). Пустое значение — использовать основную модель чата.',
@@ -5457,6 +5459,7 @@ export default {
allowedTools: 'Allowed Tools',
multiTurn: 'Multi-turn Conversation',
historyTurns: 'History Turns',
+ retainRetrievalHistory: 'Сохранять результаты поиска',
memoryEnabled: 'Долговременная память',
retrievalStrategy: 'Retrieval Strategy',
embeddingTopK: 'Embedding Top K',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index dc7b26e69..da723462f 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -1105,8 +1105,10 @@ export default {
maxTokens: '模型生成回复的最大Token数量',
thinking: '启用模型的扩展思考能力(需要模型支持)',
conversationSection: '配置多轮对话开关与问题改写开关(改写提示词见「提示词」)',
+ conversationSectionAgent: '配置每轮携带多少历史对话。智能推理始终为多轮模式。',
multiTurn: '开启后将保留历史对话上下文',
historyRounds: '保留最近几轮对话作为上下文',
+ retainRetrievalHistory: '保留此前轮次的知识库检索结果。关闭时每轮重新检索',
rewrite: '多轮对话时自动改写用户问题,消解指代和补全省略',
memoryEnabled: '允许该智能体读取并补充你的长期记忆。关闭后,与它的对话既不会读取记忆,也不会新增记忆。空间或个人设置关闭时,这里开启也不会生效',
queryUnderstandModel: '用于问题理解(改写与意图识别)的模型,留空则复用主对话模型',
@@ -5459,6 +5461,7 @@ export default {
allowedTools: '允许的工具',
multiTurn: '多轮对话',
historyTurns: '保留轮数',
+ retainRetrievalHistory: '保留检索结果',
memoryEnabled: '长期记忆',
retrievalStrategy: '检索策略',
embeddingTopK: '向量召回数量',
diff --git a/frontend/src/views/agent/AgentEditorModal.test.mjs b/frontend/src/views/agent/AgentEditorModal.test.mjs
index 834c402dd..437fa6297 100644
--- a/frontend/src/views/agent/AgentEditorModal.test.mjs
+++ b/frontend/src/views/agent/AgentEditorModal.test.mjs
@@ -34,3 +34,77 @@ test('shows a post-create hint after the first successful save', () => {
assert.match(source, /settings-footer-note/)
assert.match(source, /agent\.editor\.postCreateHint\.title/)
})
+
+// Locate a settings row by the i18n key of its label and return the attributes
+// that sit before class="setting-row" — i.e. whatever v-if guards that row.
+// Anchoring on the label keeps these assertions stable across reformatting.
+function settingRowGuard(labelKey) {
+ const key = labelKey.replace(/\./g, '\\.')
+ const row = source.match(
+ new RegExp(
+ `<div([^>]*)class="setting-row">\\s*<div class="setting-info">\\s*<label>\\{\\{ \\$t\\('${key}'\\) \\}\\}`
+ )
+ )
+ assert.ok(row, `expected to find the ${labelKey} row`)
+ return row[1]
+}
+
+test('conversation settings stay reachable in smart-reasoning mode', () => {
+ // The agent path reads history_turns (session_agent_qa.go -> LoadAgentHistory),
+ // so the section must not be gated on the running mode.
+ assert.match(source, /v-show="currentSection === 'conversation'"/)
+ assert.doesNotMatch(source, /currentSection === 'conversation' && !isAgentMode/)
+
+ // The nav entry is pushed unconditionally; a re-introduced guard would indent it.
+ const navItems = source.match(/const navItems = computed\(\(\) => \{([\s\S]*?)^\}\);/m)?.[1]
+ assert.ok(navItems, 'expected to find the nav items computed')
+ assert.match(navItems, /^ items\.push\(\{ key: 'conversation'/m)
+
+ // Switching to agent mode must not evict the user from the section.
+ // Tolerates the watch being dropped entirely by a later cleanup.
+ const modeWatch = source.match(/watch\(isAgentMode, \(isAgent\) => \{([\s\S]*?)^\}\);/m)?.[1] ?? ''
+ assert.doesNotMatch(modeWatch, /conversation/)
+})
+
+test('history turns is editable in smart-reasoning mode', () => {
+ // A new agent defaults to smart-reasoning with multi_turn_enabled=false in the
+ // form, while the server forces multi-turn on. Gating the input on the local
+ // switch alone would hide it exactly where it is needed.
+ const guard = settingRowGuard('agent.editor.historyTurns')
+ assert.match(guard, /formData\.config\.multi_turn_enabled \|\| isAgentMode/)
+})
+
+test('multi-turn switch stays hidden in smart-reasoning mode', () => {
+ // CustomAgent.EnsureDefaults pins MultiTurnEnabled to true for smart-reasoning,
+ // so an editable switch would silently revert after save.
+ const guard = settingRowGuard('agent.editor.multiTurn')
+ assert.match(guard, /v-if="!isAgentMode"/)
+})
+
+test('query rewrite stays hidden in smart-reasoning mode', () => {
+ // enable_rewrite is consumed by the KnowledgeQA pipeline only.
+ const guard = settingRowGuard('agent.editor.enableRewrite')
+ assert.match(guard, /!isAgentMode/)
+})
+
+test('the section description matches what the mode actually shows', () => {
+ // The default copy mentions query rewriting, which agent mode does not show.
+ assert.match(source, /isAgentMode\.value\s*\?\s*t\('agentEditor\.desc\.conversationSectionAgent'\)/)
+ assert.match(source, /<p class="section-description">\{\{ conversationSectionDesc \}\}<\/p>/)
+})
+
+test('history turns can be raised beyond the old 20 cap', () => {
+ // A 5-to-20 range sits two orders of magnitude below the 200k token budget
+ // the agent engine already manages, so the turn cap always bites first.
+ const input = source.match(/<t-input-number v-model="formData\.config\.history_turns"[^>]*>/)
+ assert.ok(input, 'expected to find the history turns input')
+ assert.match(input[0], /:max="100"/)
+})
+
+test('retrieval retention is offered to agents that actually have a knowledge base', () => {
+ // retain_retrieval_history is read only by the agent path
+ // (internal/agent/observe.go) and only rewrites KB/Wiki tool results, so it
+ // is meaningless without a knowledge base.
+ const guard = settingRowGuard('agent.editor.retainRetrievalHistory')
+ assert.match(guard, /isAgentMode && hasKnowledgeBase/)
+})
diff --git a/frontend/src/views/agent/AgentEditorModal.vue b/frontend/src/views/agent/AgentEditorModal.vue
index 1066d4e9a..7b936e8ff 100644
--- a/frontend/src/views/agent/AgentEditorModal.vue
+++ b/frontend/src/views/agent/AgentEditorModal.vue
@@ -168,8 +168,8 @@
</div>
</div>
- <!-- 长期记忆。放在这里而不是「多轮对话」那一组,是因为那一组
- 整个带了 !isAgentMode,而智能推理恰恰是最需要这个开关的模式。
+ <!-- 长期记忆。留在基础信息这一组而不是「多轮对话」,是因为它与
+ 多轮历史窗口无关,且智能推理恰恰是最需要这个开关的模式。
这个开关只能"关":空间或个人设置关闭时,这里打开也不生效。 -->
<div class="setting-row">
<div class="setting-info">
@@ -861,16 +861,19 @@
</div>
</div>
- <!-- 多轮对话(仅普通模式显示,Agent模式内部自动控制) -->
- <div v-show="currentSection === 'conversation' && !isAgentMode" class="section">
+ <!-- 多轮对话。Agent 模式下 history_turns 同样生效(session_agent_qa.go
+ 经 LoadAgentHistory 读取),所以本组不再整体按模式隐藏;开关本身仍由
+ EnsureDefaults 强制开启,故只在普通模式展示。 -->
+ <div v-show="currentSection === 'conversation'" class="section">
<div class="section-header">
<h2>{{ $t('agent.editor.conversationSettings') }}</h2>
- <p class="section-description">{{ $t('agentEditor.desc.conversationSection') }}</p>
+ <p class="section-description">{{ conversationSectionDesc }}</p>
</div>
<div class="settings-group">
- <!-- 多轮对话 -->
- <div class="setting-row">
+ <!-- 多轮对话开关(仅普通模式:Agent 模式由 EnsureDefaults 强制开启,
+ 展示可关闭的开关只会被服务端改回去) -->
+ <div v-if="!isAgentMode" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.multiTurn') }}</label>
<p class="desc">{{ $t('agentEditor.desc.multiTurn') }}</p>
@@ -880,14 +883,26 @@
</div>
</div>
- <!-- 保留轮数 -->
- <div v-if="formData.config.multi_turn_enabled" class="setting-row">
+ <!-- 保留轮数(Agent 模式恒为多轮,故不受开关状态影响) -->
+ <div v-if="formData.config.multi_turn_enabled || isAgentMode" class="setting-row">
<div class="setting-info">
<label>{{ $t('agent.editor.historyTurns') }}</label>
<p class="desc">{{ $t('agentEditor.desc.historyRounds') }}</p>
</div>
<div class="setting-control">
- <t-input-number v-model="formData.config.history_turns" :min="1" :max="20" theme="column" />
+ <t-input-number v-model="formData.config.history_turns" :min="1" :max="100" theme="column" />
+ </div>
+ </div>
+
+ <!-- 跨轮保留检索结果。只有 agent 链路读取该值(internal/agent/observe.go),
+ 且改写的只是 KB/Wiki 这八个工具的历史结果,所以没有知识库时不展示。 -->
+ <div v-if="isAgentMode && hasKnowledgeBase" class="setting-row">
+ <div class="setting-info">
+ <label>{{ $t('agent.editor.retainRetrievalHistory') }}</label>
+ <p class="desc">{{ $t('agentEditor.desc.retainRetrievalHistory') }}</p>
+ </div>
+ <div class="setting-control">
+ <t-switch v-model="formData.config.retain_retrieval_history" />
</div>
</div>
@@ -2287,10 +2302,8 @@ const navItems = computed(() => {
{ key: 'model', icon: 'control-platform', label: t('agent.editor.modelConfig') },
{ key: 'suggestions', icon: 'help-circle', label: t('agentEditor.questionSuggestions.navLabel') },
];
- // 多轮对话(仅普通模式显示,Agent模式内部自动控制)
- if (!isAgentMode.value) {
- items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') });
- }
+ // 多轮对话(两种模式都需要:Agent 模式同样按 history_turns 截断历史)
+ items.push({ key: 'conversation', icon: 'chat', label: t('agent.editor.conversationSettings') });
// 知识库与检索
items.push({ key: 'knowledge', icon: 'folder', label: t('agent.editor.knowledgeConfig') });
if (hasKnowledgeBase.value) {
@@ -2412,6 +2425,7 @@ const defaultFormData = {
// 多轮对话设置
multi_turn_enabled: false,
history_turns: 5,
+ retain_retrieval_history: false,
// 长期记忆:默认跟随空间设置。写 true 与不写等价,只有 false 才会
// 让这个智能体单独不读记忆。
memory_enabled: true,
@@ -2524,6 +2538,14 @@ const hasAnyIntentCustomized = computed(() =>
intentPromptTemplates.value.some((item) => isIntentCustomized(item.id)),
);
+// Agent 模式下本组只剩「保留轮数」(以及有知识库时的检索保留),
+// 默认文案里的「问题改写」并不展示,故按模式分开。
+const conversationSectionDesc = computed(() =>
+ isAgentMode.value
+ ? t('agentEditor.desc.conversationSectionAgent')
+ : t('agentEditor.desc.conversationSection'),
+);
+
const showRewritePrompts = computed(() =>
!isAgentMode.value
&& formData.value.config.multi_turn_enabled
@@ -3334,10 +3356,6 @@ watch(isAgentMode, (isAgent) => {
if (isAgent && currentSection.value === 'advanced') {
currentSection.value = 'basic';
}
- // 如果当前在多轮对话页面但切换到了Agent模式,切换到基础设置(Agent模式下多轮对话由内部控制)
- if (isAgent && currentSection.value === 'conversation') {
- currentSection.value = 'basic';
- }
});
// 监听设置弹窗关闭,刷新模型列表