From e39820d19ef4225195e75c85c0a160177e6354f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=AB=E5=BD=B1233?= Date: Wed, 24 Jun 2026 15:28:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20memory=20add=20=E4=B8=8D=E4=BC=A0=20type?= =?UTF-8?q?=20=E6=97=B6=E9=BB=98=E8=AE=A4=20fact=20=E2=80=94=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=85=9C=E5=BA=95=E6=9B=BF=E4=BB=A3=20schema=20?= =?UTF-8?q?=E7=BA=A6=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gemma 4 等模型的 function calling 对复杂 schema 不稳定,即使 type 在 required 数组中也会偶发遗漏。改为代码层面兜底:type 缺失时默认 'fact',确保 add 操作 始终成功。同时将 type 从 required 中移除,减少 schema 复杂度。 --- src/renderer/services/tool-registry.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/renderer/services/tool-registry.ts b/src/renderer/services/tool-registry.ts index ec3ef6b..6acc527 100644 --- a/src/renderer/services/tool-registry.ts +++ b/src/renderer/services/tool-registry.ts @@ -367,7 +367,7 @@ export const TOOL_DEFINITIONS: ToolDefinition[] = [ CRITICAL: For add action, you MUST include both "type" (fact/preference/rule) and "content" fields. If you omit them, the call will fail.`, parameters: { type: 'object', - required: ['action', 'type'], + required: ['action'], properties: { action: { type: 'string', enum: ['search', 'add', 'replace', 'remove', 'read_all'], description: 'Which operation to perform.' }, query: { type: 'string', description: '[search] Keywords to search for.' }, @@ -791,12 +791,11 @@ export async function executeTool(toolName: string, args: Record