refactor: 统一自建 Tool Search — 移除 tool_reference/defer_loading 依赖,全 provider 通用

- 重命名 ExecuteTool → ExecuteExtraTool,作为一等工具始终可用
- ToolSearchTool 输出改为纯文本(区分 core/deferred),移除 tool_reference blocks
- 移除 modelSupportsToolReference() 及相关 GrowthBook 配置
- 移除 API 侧 defer_loading 字段和 tool search beta header 注入
- 简化 system prompt(工具使用指南从 ~120 行压缩到 ~10 行)
- extractDiscoveredToolNames 支持文本格式解析(向后兼容旧 session 的 tool_reference)
- 更新 promptEngineeringAudit 测试以匹配简化后的 prompt 结构

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-05-09 14:19:31 +08:00
parent 4fc95bd5a7
commit 8c157f0767
17 changed files with 280 additions and 401 deletions

View File

@@ -270,7 +270,10 @@ export function getAllBaseTools(): Tools {
ReadMcpResourceTool,
// Include ToolSearchTool when tool search might be enabled (optimistic check)
// The actual decision to defer tools happens at request time in claude.ts
...(isToolSearchEnabledOptimistic() ? [ToolSearchTool, ExecuteTool] : []),
...(isToolSearchEnabledOptimistic() ? [ToolSearchTool] : []),
// ExecuteExtraTool (ExecuteTool) is a first-class tool — always available, not deferred.
// Models use it to invoke deferred tools discovered via ToolSearch.
ExecuteTool,
]
}