fix(codex): 修复任务假闲并补齐 RPC 生命周期#571
Open
xiaoxueSunn wants to merge 11 commits into
Open
Conversation
…overy (PR 1-5) Fixes three user-visible failures in the Codex App path: - False idle: task still running but card/Dashboard show idle - False busy: task finished but UI stays busy - Wrong turn ownership: message routed to incorrect task turn Root cause: three state sources (TUI screen, worker memory, runner notifications) could override each other. Fix makes runner signed state the single owner of idle/ready; display layer only projects it. Also includes Riff shutdown (prepare/commit/abort fence) and PM2 recovery (exact start, descriptor guard, supervisor shutdown protocol) as separate concerns with independent test gates. Tests: 29/29 + 32/32 false-busy/false-idle cases pass; full unit regression shows 0 new failures. tsc --noEmit passes. Doc: https://bytedance.larkoffice.com/docx/TZUydIskCoJZT8xfMXzc2WI5ntc
经典 Codex 在 structured turn 已 started 未 final 时,屏幕启发式会把 prompt/PTY 静默投影为 idle。统一用 projectRuntimeScreenStatus: structuredTurnBlocking 优先于 promptReady;三入口(markPromptReady / 周期 screen update / 截图)共用;仅 codex allowlist 强门控; submit verification/confirm 使用 30s/20s 有界 lease,到期 fail-open 防止掉 Enter 永久假忙。
…+ coco/codex history-append tests RPC mode has no local transcript ingest, so a turn never reaches 'started' and relied solely on the 20s confirmation lease. A turn running longer than 20s (e.g. approval pending) was pruned by pruneExpiredPreStartHeads → false idle. Add rpcActive flag + markRpcActive/stopRpcActive so the lifecycle gate stays asserted for the full server-side run; hasBlockingTurn, pruneExpiredPreStartHeads, preStartLeaseRemainingMs, and refreshNextPreStartLease all respect it. stopCodexRpcEngine clears rpcActive turns + rejected-ready evidence. Add 5 RPC tests (codex-bridge-queue) and 3 coco/codex history-append return-value tests (write-input).
xiaoxueSunn
force-pushed
the
fix/codex-false-idle
branch
from
July 23, 2026 13:22
1041c99 to
d9f9958
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
普通 Codex CLI 的 turn 尚未结束时,终端输入提示或短暂静默可能让飞书卡片和 Dashboard 提前显示「等待输入」。RPC 模式下,response、terminal notification、pane 重连和 worker restart 还可能以不同顺序到达,导致终态丢失、错配或旧异步后续回调污染新 CLI。
根因
屏幕启发式判断、structured bridge、RPC response / terminal 和 CLI generation 缺少统一的优先级、所有权与精确结算边界。旧逻辑在 native turn ID 不明确时还可能按唯一 pending 项猜归属。
修复
rpcActive,直到精确 terminal、可精确归属的失败或 stop 才释放;变基与验证
本 PR 基于
#537@72783ba8,head 为910705dd,包含 5 个增量提交。tsc --noEmit通过;未执行 daemon 重启、真实 Codex app-server 的生产式 RPC 会话或飞书 live E2E;这些项目阻塞发布验证,不阻塞代码审核。
若 #537 以保留提交祖先关系的 merge commit 合入,本 PR 会只显示第二层增量;若仓库使用 squash 或 rebase merge,需要把本 PR 重新变基到最新
master。详细说明:https://bytedance.larkoffice.com/docx/GzoDdmVtSoQnj2xmChycyjRCnaf
本次未执行合并。