Files
makelore/.project-docs/30-worklog/tasks/20260924-consultation-run-busy-9ac245f1.md
T

45 lines
4.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Task: Diagnose consultation thread busy after tool use
## Identity
- Task ID: 20260924-consultation-run-busy-9ac245f1
- Mode: Feature
- Branch: codex/20260924-consultation-run-busy-9ac245f1-consultation-run-busy
- Worktree: D:\Datas\OthersProjects\.codex-worktrees\makelore\20260924-consultation-run-busy-9ac245f1
- Base commit: 0e22e0545d6f58a17a8c85805570a550d1c14c43
- Owner: codex
- Status: Ready for Integration
## Scope
- 修复云端智能体使用三个本地只读工具后,客户端显示“该智能体线程正在运行,请等待、查询或取消当前运行后再继续”的续接失败。仅调整 Main 云端传输、相应回归测试和 README。
## Intent And Constraints
- 用户要求检查截图报错;并发与 Planning Gate 已通过,在独立工作树修复。没有创建子智能体,没有修改其他任务的工作树。
- 保持同一问题、同一工具结果批次和学生计费归属;保留云端线程互斥、原问题时限与取消机制。其他运行占用、结果冲突和新问题失败不自动重发。没有 API/schema、界面或模型配置变更。
## Outcome
- 已确认触发路径:Yuxi 先提交 interrupted,再释放运行资源;GET 状态已可见 interrupted,而原 Run 的 runtime_cleanup_pending 仍为 true。客户端读完本地文件后提交 tool-results,云端原生互斥检查以同一个 interrupted Run 返回 409 run_busy。旧客户端把它当作不可恢复错误并取消问题。
- 传输层只对 tool-results 返回的同一父 Run、interrupted 状态和明确 run_busy 等待 500ms 后重交原批次;等待不消耗普通网络重试次数,仍受调用方传入的原问题取消/超时信号控制,不重读文件、不重建问题。
- 真实云端控制复现见 Yuxi 任务 20260924-teacher-run-busy-f327b9d4:暂停资源释放时 HTTP 409,释放后原请求 HTTP 200,并继续到 completed、真实输出及学生付费断言通过。直接控制 cleanup 变量已提供因果证据,因此未继续扩大到无关假设或 bisect。
- README 已同步该续接行为;源码与测试自查完成。当前仅完成本地修复,未合并主分支、打包安装、推送或部署。
## Verification
- 修复前:`pnpm exec vitest run tests/unit/coding-teacher-cloud.test.ts -t 'waits for the interrupted parent cleanup' --maxWorkers=1`,1 failed,失败文本为截图中的 run_busy;工具结果 POST 路径命中真实传输层。
- 修复后:`pnpm exec vitest run teacher-cloud-activity coding-teacher --maxWorkers=1`,6 files / 183 passed。
- 最终补齐“新问题不重试”负向例并调整类型收窄后:`pnpm exec vitest run tests/unit/coding-teacher-cloud.test.ts --maxWorkers=1`,29 passed。覆盖三工具完整续接、连续四次清理冲突后成功、本地文件变化不改变重交内容、不取消成功问题、其他运行/状态/冲突不重试、新问题不重试和等待取消。
- `pnpm run typecheck` passed(Renderer);最终 `pnpm exec eslint electron/coding-teacher/cloud-runner.ts tests/unit/coding-teacher-cloud.test.ts` 和 `pnpm run build:vite` passed。没有声称全仓 Main 类型基线零错误。
- 本次无界面布局/Host API 变化;已有 Electron E2E 用 Host API fixture 绕过真实云端传输,不能验证这个缺陷,未新增重复 UI 测试。未执行安装版或生产云端实机验收。
- 仅依赖安装复用本地缓存,未变更清单或锁文件;文档门禁和 diff 空白检查在提交前执行。
## Follow-ups
- 合并后构建/更新客户端,并在真实下发智能体中提问需要读取项目和会话的问题,确认三工具后继续输出。生产环境中的截图 Run 未直接读取;本地已复现相同错误及完整因果链。
## Promotion Candidates
- Target: `.project-docs/30-worklog/current-state.md`。Proposal: 云端智能体工具续接能够等待原 interrupted Run 资源释放,复用结果批次并保留原时限/取消。Evidence: 真实 HTTP/PG/worker 控制实验与客户端回归。Future impact: 排查此类 409 时须区分原 Run 清理与另一运行占用。Semantic conflicts: 无;不改变云端互斥或付费规则。Human confirmation: 技术事实无额外确认要求,由后续 Integration Gate 决定是否推广。