baa-conductor


baa-conductor / bugs / archive
codex@macbookpro  ·  2026-03-27

FIX-BUG-008.md

 1# FIX-BUG-008
 2
 3```text
 4你在仓库 /Users/george/code/baa-conductor 工作。
 5
 6必须从当前 main 基线开始:main@02b3d6a。
 7不要从其他任务分支切出。
 8如果本地已有旧 worktree/分支,不要复用,重新从 main 建干净 worktree。
 9
10任务:修复 codexd 在第二个 session/thread 上发 turn 容易超时并反复 reconnect 的问题
11建议分支:fix/codexd-second-thread-timeout
12
13先读:
141. /Users/george/code/baa-conductor/bugs/BUG-008-codexd-second-thread-turn-timeout.md
152. /Users/george/code/baa-conductor/apps/codexd/src/daemon.ts
163. /Users/george/code/baa-conductor/apps/codexd/src/app-server-transport.ts
174. /Users/george/code/baa-conductor/packages/codex-app-server/src/*
185. /Users/george/code/baa-conductor/docs/runtime/codexd.md
19
20背景:
21- 现在第一个 session/thread 的 turn 能成功完成
22- 第二个新 session/thread 的 turn 容易卡住
23- 之后会进入 reconnect,最终 failed
24- 这直接破坏 codexd 作为 duplex 多会话代理的核心能力
25
26目标:
27- 让 codexd 在同一个独立 app-server child 上,顺序处理多个 session/thread 的 turn 时稳定工作
28- 至少修到:
29  - 第一轮 session 正常
30  - 第二轮新 session 也能正常完成 turn
31  - 不再出现“第二个 thread 稳定失败”的模式
32
33要求:
34- 只在这些范围内工作:
35  - apps/codexd/**
36  - packages/codex-app-server/**
37  - docs/runtime/**
38- 不要修改 apps/conductor-daemon/**
39- 不要恢复 codex exec 正式模式
40- 不要引入新的架构方向
41
42建议调查方向:
431. codexd 的 app-server client 生命周期
44- 第二个 thread 开始前,client / transport 是否仍然处于健康状态
45- 有没有错误把“thread 完成”当成“child/stream 结束”
46
472. transport 关闭逻辑
48- 检查 app-server-transport.ts
49- 确认 onClose / disconnect / reconnect 是否在第二个 thread 上被误触发
50
513. thread 模型
52- 检查 createSession / createTurn 对 threadId 的处理
53- 确认新 thread 的 turnStart / turnSteer 是否和当前状态机兼容
54
554. 最小修复优先
56- 优先修“第二个 session/thread turn 失败”
57- 不要顺手做大重构
58
59验收标准:
60- 增加一个稳定复现并覆盖修复的测试
61- 至少覆盖:
62  - 第一个 session turn 完成
63  - 第二个 session turn 也完成
64  - 不出现 reconnect/fail
65- 至少跑:
66  - npx --yes pnpm -F @baa-conductor/codexd typecheck
67  - npx --yes pnpm -F @baa-conductor/codexd build
68  - node --test apps/codexd/src/index.test.js
69  - 如有必要,加你新增的专项 test
70  - git diff --check
71
72结束时:
73- 提交并推送该分支
74- 最终回复里明确说明:
75  - 根因是什么
76  - 第二个 thread 为什么之前会失败
77  - 你改了哪些生命周期/transport/session 逻辑
78  - 现在如何验证多个 session/thread 已经能顺序工作
79```