fix(maker-core): Codex exec yield 后产品 turn 不再假完成 - #3315
Conversation
Codex functions.exec 约 11 秒会先 yield cell,再由模型 wait。Grok 等模型 常在 yield 后立刻空 task_complete,Cindy 把产品 turn 标完成,长命令没跑完。 adapter 用 rollout 锁死的启发式铸造 continuation claim,宿主开续段让模型 wait 同一 cell。wait 结算后正常收口;空续段或重试耗尽报 lost-handle,不 replay 原请求。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc827d35ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
| Filename | Overview |
|---|---|
| packages/maker-core/src/agents/codex/index.ts | 新增 yield continuation 的 claim、turn 归属、重试、取消、终态收口及内部续段串行逻辑。 |
| packages/maker-core/src/agents/codex/yielded-exec-cell.ts | 新增 Codex exec/wait 输出中的 cell yield、存活和结算标记解析。 |
| packages/maker-core/src/agents/codex/index.test.ts | 大范围覆盖 continuation 生命周期、竞态、权限继承、Plan Mode、ask_user 和失败路径。 |
| packages/maker-core/src/agents/codex/yielded-exec-cell.test.ts | 覆盖 exec 与 wait item 的 marker 提取、去重和 prompt 格式化。 |
| docs/dev-rules/maker-core-and-agent-behavior.md | 补充产品 turn 结算、continuation ownership、失败闩锁和上下文继承规则。 |
Sequence Diagram
sequenceDiagram
participant M as 模型
participant C as Codex adapter
participant S as 产品 Session
M-->>C: exec 输出 running cell marker
M-->>C: provider turn/completed
C-->>S: done/status + continuation claim
C->>M: 新续段:wait 同一 cell
alt cell 已完成或终止
M-->>C: Script completed/terminated
C-->>S: 无 claim 的最终 done
else cell 仍运行
M-->>C: running marker
C->>M: 在预算内再次 wait
else cell handle 丢失或续段失败
C-->>S: terminal error + idle status
end
Reviews (17): Last reviewed commit: "fix(maker-core): keep nameless yield cel..." | Re-trigger Greptile
Responses/proxy 的 function_call 经常没有 item.id。原先无 id 的 completed 会删掉同一个空键,后面一个 wait 就能把仍在跑的 exec yield 清掉。 有稳定 id/call_id 时按键登记;没有时累加到匿名桶,且 completed 不再按空 键删除。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a53f519dcb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ask_user 作答与计划实施/修订都会走内部 handle.send,原先没有 CODEX_YIELD_CONTINUATION 标记,会被当成用户新 turn 取消正在等 cell 的 claim。内部续段改带 CODEX_INTERNAL_CONTINUATION,不再冲掉 yield 账本。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9094f989c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
transport error 会取消正在等 cell 的 claim,其它 willRetry:false 终态只推 Done。UI 已失败时 isTurnRunning() 仍为 true,后续 send 被 SESSION_RUNNING 拒绝。所有真正收口的终态错误路径都同步结算 claim。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c01db21ef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
续段 turn/start 已被 server 接受后,AbortSignal 会让取消检查直接抛, 墓碑和 interrupt 走不到。先凭响应里的 turn id 隔离,再抛/返回取消。 wait 仍输出 running marker 视为 cell 仍存活;重试预算内继续等, 不再把这类续段当成空完成报 lost-handle。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c8d3d8bea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ow-ups 迟到的外族 failed/interrupted 会在归属检查前取消当前 yield claim。 claim 现在记下 origin/continuation turn,只撤销属于自己的终态。 同一产品 turn 上的 ask_user/plan 内部续段改为等 yield 空闲后再 turn/start,避免两个内部 send 并发覆盖 currentTurnId。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfe6305587
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…iters 迟到的外族成功 completed 仍会结算当前 yield claim,甚至误报 lost-handle。 成功路径也先查 origin/continuation 归属。 Stop/close 取消 yield 时,排队中的 ask_user/plan waiter 改为取消退出, 不再被当成正常空闲继续 turn/start。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 846c3b0ac5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…letions 迟到的外族 completed/failed 虽不再结算 claim,仍会发出没有 turnContinuationId 的产品 done,Session 会把仍在跑的 cell 提前收口。 识别为外族后直接返回,成功与失败路径都不发未认领终态。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60d57fd1b7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ations 无人值守 turn 铸造 claim 后,续段 send 会把 activeTurnPermissionPolicy 重置为 null,wait 完成后继续原请求时可能按普通 Auto 权限执行。 把铸造时的策略快照进 claim,每个续段 turn/start 原样带上。 Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a8f99bf8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Product failure (lost-handle, retry exhaustion, continuation start failure) now wakes queued ask_user/plan waiters as cancelled, and handle.send no longer emits a second generic terminal for yield continuation start failures. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 042e6ab2c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A live continuation's generation and usage now have one owner: foreign completed/failed turns tombstone themselves before endTurn, instead of clearing the continuation bucket and then trying to suppress Done later. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55129681a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Nameless itemUpdated markers no longer enter the ledger. A completed snapshot without a yield marker clears the anonymous bucket, so a later Exit 0 cannot mint a lost-handle claim. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e10e8597eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
第 12 轮硬止损:范围声明本 PR 只修一件事:Codex 已覆盖的结算不变量:
本轮三条 Codex P1 划出范围、不再补丁:
不迁 Claude wake continuation,不迁 #3290 ask_user continuation,不抽公共模块。 |
MagicLizi
left a comment
There was a problem hiding this comment.
按维护者指示批准;合并仍需通过 review-pr 的代码审查与其余安全门。
MagicLizi
left a comment
There was a problem hiding this comment.
必须修改
P1×2。yield 续跑的 Stop / 失败收口还不完整,不能合。
|
@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(packages/maker-core/src/agents/codex/index.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
…-ups Stop after turnStarted now emits an unclaimed cancelled done so Session releases the attempt token even if interrupted turn/completed is tombstoned. Product failure latches waitForYieldContinuationIdle and dismisses leftover ask_user/plan cards. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4ddb9bbcb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
MagicLizi
left a comment
There was a problem hiding this comment.
审查结论:匿名多 cell 与 plan+yield 两条路径仍会假完成 / 丢计划。
packages/maker-core/src/agents/codex/index.ts:3216—rememberYieldedExecCells在phase === 'completed'且无id/call_id、当前 item 抽不出 yield/alive cell 时执行existing.delete(''),整桶清掉匿名账本。同 turn 两个无 id 的exec_command分别 yield 后,无 id 的wait对其中一个输出Script completed会先把仍在跑的另一个 cell 抹掉,产品 turn 再次假完成。wait 结算只应走forgetSettledYieldCells按cell_id剔除。请补「nameless exec 229 + 230 + nameless wait 229 Script completed → turn/completed 仍 claim 230」。packages/maker-core/src/agents/codex/index.ts:9120— origin plan turn 先 yield 再turn/completed时,startYieldContinuation()同步进入handle.send,此时planCycleActive仍为 true,续段以 plan mode 启动;随后同源 handler 因没有proposed_plan把planCycleActive = false。存在 awaiting yield claim 时不要结束 plan cycle。请补 plan mode 下 origin yield、续段产出<proposed_plan>仍发plan_review的单测。
|
@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(packages/maker-core/src/agents/codex/index.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
A nameless wait that settles one cell_id no longer wipes the anonymous bucket, so sibling yielded execs still mint a claim. Plan Mode review waits for the product terminal: empty origin turns keep the cycle, and plans produced before yield are restored after continuation settle. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 148e21721f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Yield continuations already snapshot turnPermissionPolicy. They now also keep the origin capability selection and auto-review intent, so wait prompts cannot drop MCP routing or replace the user's request as the reviewer intent. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efea905f7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ws it Abort after a returned continuation TurnStart must not synthesize a second unclaimed cancelled done. Provider interrupted already settles the product turn. Keep the synthetic done only while TurnStart is still pending and isolateCancelledTurnStart will swallow the later terminal. Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a109227c8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
MagicLizi
left a comment
There was a problem hiding this comment.
P1 × 1,当前 head 不能合。此前 MagicLizi 指出的 nameless wait 误清 sibling、origin plan yield 提前结束计划周期、Stop after turnStarted、lost-handle 后续 wait 这几条在本 head 已修好。还剩一个同类假完成洞。
packages/maker-core/src/agents/codex/index.ts:3215 — rememberYieldedExecCells 在 nameless completed 且不是带可解析 settled cell_id 的 wait 时仍 existing.delete('')。匿名桶里可以同时挂多条 yielded function_call(exec_command)(Responses/proxy 经常没有 id/call_id)。之后任意一条没有 yield 标记的 nameless completed sibling(短 exec_command Exit 0,或其它 nameless function_call)会清掉整个桶;turn/completed 于是发出未认领的 done,还在跑的 cell 再也认领不到。
请:除了 forgetSettledYieldCells 按 cell_id 结算,不要再清 '';未打标的 nameless completion 不得碰其它匿名 cell。补测试:nameless exec 229 yield + nameless exec Exit 0 → 仍应认领 229。
Nameless completed items share one anonymous ledger bucket. An unmarked
sibling exec (Exit 0) must not delete('') that bucket, or a still-running
yielded cell is forgotten and the product turn false-completes. Only
forgetSettledYieldCells may drop a cell by cell_id.
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
|
Fixed in ae450b8. Nameless completed items no longer Added |
这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。
|
合了。Codex exec yield 之后产品 turn 不再提前收口,这个假完成一直很难在日志里钉死——现在 claim / cell 结算对齐了,续段也不会把计划周期冲掉。谢谢。 |
这次改了什么
摘要
Codex
functions.exec大约 11 秒会先 yield 一个 cell,再由模型wait。Grok 等模型常在 yield 后立刻空task_complete,Cindy 把产品 turn 标完成,长命令其实还没跑完。这次在 Codex adapter 里用真实 rollout 锁死的启发式铸造 continuation claim:成功
status(isRunning:false)与done共用同一turnContinuationId,宿主再开续段让模型 wait 同一 cell。同 turn 或续段里 wait 输出Script completed/Script terminated后正常收口;空续段或重试耗尽报 lost-handle,不 replay 原请求、不重跑已执行命令。变更类型
fix缺陷修复feat新功能refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
task_complete)UI 变化
怎么验证的
自动验证
手工验证
不涉及。两名 Orca reviewer(Codex / Claude Code)按当前 worktree 独立复审,结论均为通过。
未执行的验证
全量
pnpm test:unit/run-unit-gate.sh因apps/desktop的ghostInstallReceipt.test.ts两条失败未绿。同一失败在主仓cindycheckout 上复现,与本 PR 的 Codex 文件无关;CI 仍会跑完整单测。未做真实 Codex daemon 上的 cell 跨 turn 存活实验。cell 丢失时走诚实 lost-handle,不自动重跑命令。
风险
风险分类
影响与回滚
#3179rollout 的Script running with cell ID <n>,只认commandExecution与function_call(exec_command)。turn/completed立刻结束产品 turn」的旧行为。提交前检查
git commit -s,见 DCO)