claude-code-best/packages
IronRookieCoder 4cb047ff48 fix(costrict): recover task updates from missing tool calls
## Bug 详情
CSC 在相同模型和输入下,任务流程可能先成功执行 TaskCreate,随后模型返回 stop_reason=tool_use 但没有实际 tool_use block,导致 TaskUpdate/update_todo_list 没有执行,最终任务状态更新失败。

## 根因
CoStrict/OpenAI 兼容流在工具参数不完整或模型续轮缺少工具块时,缺少稳定的结构化恢复路径;query 层原先无法基于已发生的任务工具调用链路区分普通缺失工具调用和任务状态更新流程。

## 修复方案
基于结构化 tool_use 历史识别任务流程,优先引导 CoStrict 使用 update_todo_list 恢复任务清单状态;同时为 CoStrict 工具 JSON 流增加无效参数保留和错误结果回传,避免执行 malformed tool input。

## 变更要点
- 新增 update_todo_list 兼容工具,并注册到 TaskV2 工具列表
- query 缺失 tool_use 恢复改为基于 TaskCreate/TaskUpdate/TaskList/TaskGet/update_todo_list 结构化工具历史判断
- CoStrict provider 保留 malformed tool call 的 id/name 并阻止执行无效参数
- 工具执行和 streaming executor 对 invalid tool call 返回错误 tool_result
- 补充 query 恢复、CoStrict provider、工具执行、消息规范化和 update_todo_list 单测

## 自测
- bun test src/__tests__/queryMissingToolUseRecovery.test.ts
- bun test src/costrict/provider/index.test.ts
- bun test src/utils/__tests__/messages.test.ts
- bun test src/services/tools/__tests__/StreamingToolExecutor.test.ts packages/builtin-tools/src/tools/UpdateTodoListCompatTool/__tests__/UpdateTodoListCompatTool.test.ts
- bun run typecheck 仍有当前工作区既有无关错误,未由本次修改引入
2026-05-20 13:44:12 +08:00
..
@ant fix(costrict): handle image input for model compatibility 2026-05-19 11:38:16 +08:00
acp-link style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
agent-tools style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
audio-capture-napi style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
builtin-tools fix(costrict): recover task updates from missing tool calls 2026-05-20 13:44:12 +08:00
color-diff-napi style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
image-processor-napi style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
mcp-client fix: 优化内存峰值与 CPU 性能,降低 100-300MB 内存占用 2026-05-02 00:45:03 +08:00
modifiers-napi style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
remote-control-server chore: 合并社区 upstream/main 代码至 v2.4.2 2026-05-12 11:55:04 +08:00
url-handler-napi style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
weixin style: 完成所有文件的lint 2026-05-01 21:39:30 +08:00
tsconfig.json feat: 重构供应商层次 (#286) 2026-04-17 09:33:14 +08:00