mirror of
https://github.com/7836246/cursor2api.git
synced 2026-09-03 07:20:02 +08:00
fix: 提供完整的工具参数 Schema 和描述信息给模型
- 之前生成的工具列表只包含粗略的参数名和 string 类型提示,丢失了 description 和 enum 等关键信息。 - 改为直接输出 tool.description 和 stringify 后的完整 input_schema,从而修复模型调用 Agent 等复杂工具时填错参数类型导致 `Agent type 'general' not found` 的问题。
This commit is contained in:
@@ -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<string, { type?: string; description?: string }>)
|
||||
.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:
|
||||
|
||||
Reference in New Issue
Block a user