diff --git a/src/pages/AgentEditor/components/CapabilitySettings.tsx b/src/pages/AgentEditor/components/CapabilitySettings.tsx
index cc24fc4..e6f9fe6 100644
--- a/src/pages/AgentEditor/components/CapabilitySettings.tsx
+++ b/src/pages/AgentEditor/components/CapabilitySettings.tsx
@@ -152,9 +152,6 @@ export default function CapabilitySettings({
label="模型"
className="mb-0"
getValueProps={(value) => ({ value: parseModelSelections(value) })}
- normalize={(value) =>
- Array.isArray(value) ? value.map((item) => String(item).trim()).filter(Boolean).join(',') : ''
- }
>
diff --git a/src/pages/AgentEditor/constants.ts b/src/pages/AgentEditor/constants.ts
index d749c87..81a57d7 100644
--- a/src/pages/AgentEditor/constants.ts
+++ b/src/pages/AgentEditor/constants.ts
@@ -32,10 +32,26 @@ export const TYPE_TAG: Record url?.startsWith('http') || url?.startsWith('/');
-export const parseModelSelections = (value?: string | string[]) =>
- Array.isArray(value)
- ? value
- : String(value || '')
- .split(',')
- .map((item) => item.trim())
- .filter(Boolean);
+export const parseModelSelections = (value?: string | string[]) => {
+ if (Array.isArray(value)) {
+ return value;
+ }
+ // 尝试解析 JSON 格式
+ try {
+ const parsed = JSON.parse(String(value || '[]'));
+ if (Array.isArray(parsed)) {
+ return parsed.map((item: any) => {
+ if (typeof item === 'object' && item.id) {
+ return item.id;
+ }
+ return String(item);
+ }).filter(Boolean);
+ }
+ } catch {
+ // 兼容旧格式:逗号分隔的字符串
+ }
+ return String(value || '')
+ .split(',')
+ .map((item) => item.trim())
+ .filter(Boolean);
+};
diff --git a/src/pages/AgentEditor/hooks/useAgentEditor.ts b/src/pages/AgentEditor/hooks/useAgentEditor.ts
index e1e7fab..e913c9c 100644
--- a/src/pages/AgentEditor/hooks/useAgentEditor.ts
+++ b/src/pages/AgentEditor/hooks/useAgentEditor.ts
@@ -163,9 +163,13 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE
Object.keys(values).forEach((key) => {
const formValue = (values as any)[key];
const originalValue = (agent as any)?.[key];
- // 特殊处理 model 字段:如果是数组,用逗号拼接成字符串
+ // 特殊处理 model 字段:将 id 和 name 组合成 JSON 数组字符串
if (key === 'model' && Array.isArray(formValue)) {
- changedFields[key] = formValue.join(',');
+ const modelObjects = formValue.map((modelId: string) => {
+ const model = models.find((m) => m.id === modelId);
+ return { id: modelId, name: model?.model_name || '' };
+ });
+ changedFields[key] = JSON.stringify(modelObjects);
} else if (formValue !== originalValue) {
changedFields[key] = formValue;
}