From b208f80c0b22c45c49bc2e2ea9152cb82295a954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= <7836246@qq.com> Date: Wed, 4 Mar 2026 16:04:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E4=BE=9B=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E5=85=B7=E5=8F=82=E6=95=B0=20Schema=20?= =?UTF-8?q?=E5=92=8C=E6=8F=8F=E8=BF=B0=E4=BF=A1=E6=81=AF=E7=BB=99=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 之前生成的工具列表只包含粗略的参数名和 string 类型提示,丢失了 description 和 enum 等关键信息。 - 改为直接输出 tool.description 和 stringify 后的完整 input_schema,从而修复模型调用 Agent 等复杂工具时填错参数类型导致 `Agent type 'general' not found` 的问题。 --- src/converter.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/converter.ts b/src/converter.ts index cef8fa0..ca2f8b2 100644 --- a/src/converter.ts +++ b/src/converter.ts @@ -56,13 +56,9 @@ function buildToolInstructions(tools: AnthropicTool[], hasCommunicationTool: boo if (!tools || tools.length === 0) return ''; const toolList = tools.map((tool) => { - const params = tool.input_schema?.properties - ? Object.entries(tool.input_schema.properties as Record) - .map(([k, v]) => `${k}: ${v.type || 'string'}`) - .join(', ') - : ''; - return `- ${tool.name}(${params})`; - }).join('\n'); + const schema = tool.input_schema ? JSON.stringify(tool.input_schema) : '{}'; + return `### ${tool.name}\nDescription: ${tool.description || 'No description'}\nInput Schema: ${schema}`; + }).join('\n\n'); const rules = hasCommunicationTool ? `CRITICAL RULES: