缺陷 / 高 / Agent 引擎
electron/harness/prompts/context-builder.ts
ContextBuilder.estimateTokens 在估算 system prompt token 时,仅累加 tool.name + tool.description,忽略 tool.parameters:
tools.forEach(tool => { total += tool.name.length + tool.description.length; });
但 tool.parameters(JSON Schema)通常占工具 token 的 70%+:
tools.forEach(tool => { total += tool.name.length + tool.description.length; // 估算 parameters schema 的 token if (tool.parameters) { const schemaStr = JSON.stringify(tool.parameters); total += estimateTokens(schemaStr); // 使用同一估算器 } });
或调用统一的 estimateMessagesTokens,将 tools 作为 messages 的一部分。
No dependencies set.
The note is not visible to the blocked user.
问题类型
缺陷 / 高 / Agent 引擎
文件位置
electron/harness/prompts/context-builder.ts问题描述
ContextBuilder.estimateTokens 在估算 system prompt token 时,仅累加 tool.name + tool.description,忽略 tool.parameters:
但 tool.parameters(JSON Schema)通常占工具 token 的 70%+:
影响
建议修复
或调用统一的 estimateMessagesTokens,将 tools 作为 messages 的一部分。