Skip to content

Commit bbbacce

Browse files
author
linyuan.yang
committed
配置保存问题
1 parent 943c964 commit bbbacce

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎packages/admin/src/views/agents/modals/AgentModal.vue‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,21 @@ async function save() {
138138
if (form.value.sessionMode !== ACPSessionMode.Persistent) config.sessionMode = form.value.sessionMode
139139
if (form.value.initTimeout != null && form.value.initTimeout > 0) config.initTimeout = form.value.initTimeout
140140
}
141-
// 保留在专属页面配置的字段(generative/acp 模式无工具/技能,不保留)
142-
const existing = editingId.value ? agents.value[editingId.value] : null
143-
if (type !== AgentMode.Generative && type !== AgentMode.ACP) {
144-
if (existing?.mcp) config.mcp = existing.mcp
145-
if (existing?.skills) config.skills = existing.skills
146-
if ((existing as any)?.autoApproveTools) (config as any).autoApproveTools = (existing as any).autoApproveTools
141+
// 后端会整体替换 agent.json,自动带回本表单未管理的字段,避免新增字段时遗漏。
142+
// 当前表单管理的字段不能带回旧值,否则用户清空字段后无法保存;模式不支持的字段同样不保留。
143+
const existing = (editingId.value ? agents.value[editingId.value] : null) as any
144+
const managedFields = new Set([...Object.keys(form.value), 'agents'])
145+
const unsupportedFields = new Set<string>()
146+
if (type === AgentMode.Generative || type === AgentMode.ACP) {
147+
for (const key of ['mcp', 'mcpExclude', 'mcpParams', 'skills', 'skillsExclude', 'autoApproveTools']) {
148+
unsupportedFields.add(key)
149+
}
150+
}
151+
if (type !== AgentMode.Generative) unsupportedFields.add('maxHistoryRounds')
152+
for (const [key, value] of Object.entries(existing || {})) {
153+
if (!managedFields.has(key) && !unsupportedFields.has(key)) {
154+
(config as any)[key] = value
155+
}
147156
}
148157
149158
if (form.value.name.trim()) (config as any).name = form.value.name.trim()

0 commit comments

Comments
 (0)