Skip to content

fix(codex-app): 区分异步文字提醒与提问卡 - #3886

Merged
deepcoldy merged 3 commits into
deepcoldy:masterfrom
uestcwangci:codex/codex-app-async-notices
Nov 26, 2026
Merged

deepcoldy merged 3 commits into
deepcoldy:masterfrom
uestcwangci:codex/codex-app-async-notices

Conversation

@uestcwangci

Copy link
Copy Markdown
Contributor

问题

Codex App Server 用 agentMessage.delivery=async 同时表示普通文字提醒和异步提问。Botmux 原先把两者都交给提问卡解析器,纯文字事件缺少 questions 时,飞书会误报提问格式不支持。

改动

  • 缺省或 null 的 questions 走当前轮的进度输出,Web 终端也会显示该文字。重复的完成事件只显示一次。
  • 带问题载荷的事件继续走已有提问卡校验和作答流程。提问正文只由提问卡处理,避免在轮次进度里重复显示。
  • 影响范围为 Codex App runner 的 app-server 通知和现有签名进度通道。适用于该 runner 的会话和后端,飞书机器人收到的是既有进度事件。

验证

  • bun run build 通过。相关 runner、进度和提问测试共 219 项通过。
  • 在 v3.59.33 上应用同一补丁,18 项异步消息集成用例通过,覆盖无 questions、questions: null、重复事件、真实提问作答和格式错误。
  • bun run build:bun 和 Linux 二进制启动检查通过。本地部署确认飞书重新连接,原会话用新版 runner 恢复到等待输入。飞书界面中的新提醒待自然触发验证。

- collector 直接单测覆盖 async question(含 commentary phase 的 delta 路径)
  与 questions 缺失/null 两种纯文字提醒,变异验证两处分流守卫均能咬红
- 集成断言补上 delta 首行泄漏检查(原断言只覆盖 completed 整段文本),
  顺带修正一处缩进

Co-Authored-By: Claude Fable 5 <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

自动评审初步意见(最终以维护者审阅为准)。

分流逻辑本身没有发现阻断问题:questions != null 走既有提问卡 broker、缺失/null 走 output.display + thinking marker、knownAgentItemIds 兜住重复通知,与 turn 结算(finalizeAcceptedGroup)和 delta 缓冲的交互都自洽。

评审中做变异复验时发现一处测试覆盖缺口,已在 3026bab 直接补上(仅测试,未改实现):

  1. CodexAppCotCollector 对 item/started 的 async 排除守卫,原有集成断言抓不住——fixture 里只有 duplicate 用例带 phase: 'commentary',而断言找的是 completed 才会泄漏的整段文本,delta 路径泄漏的首行 Which environment? 没有被钉住。摘掉该守卫后原测试全绿。补了 collector 直接单测(async question 全序列 + questions 缺失/null 两种纯文字提醒),并把集成断言扩成首行与整段都检查;两处分流守卫现在变异均咬红。
  2. 顺手修了一处多出来的缩进。

本地验证:bun run build 通过;codex-app-cot / codex-app-runner-protocol 单测与 codex-app-runner.integration 共 164 项通过;5 处 runner/collector 变异 + master 旧实现反向验证均按预期咬红。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论(3026bab5)

主流程没有发现阻断问题:questions != null 的提问仍进入既有 ask broker,缺失/null 的纯文字提醒只发布一次进度和终端输出,collector 对 async 提问的 delta/completed 两条泄漏路径均有测试守住。

P3(nit):纯文字提醒可能与后续终端输出连行

  • 位置:src/codex-app-runner.ts:1641
  • 新分支将 item.text 原样传给 RunnerControlWriter.display;该方法只写原始文本,不补行边界(src/adapters/cli/runner-control-channel.ts:25-27)。
  • 现有 async-user-input-plain 场景已经能复现:提醒 Complete sign-in in your private terminal. 没有尾随换行,随后输出 Independent work completed,实际 stdout 为:
    Complete sign-in in your private terminal.Independent work completed
    
  • 探针证据:在现有 plain 集成用例中临时增加 expect(harness.stdout).not.toContain(${text}Independent work completed),单用例如预期失败并显示上述连行;恢复探针后工作区干净。建议在文本未以 \n 结尾时补一个换行,并在该场景增加行边界断言。
  • 影响仅限 Web 终端的可读性;thinking marker、最终回复内容和提问卡流程不受影响,不列为合并阻断。

本地验证

  • bun run build:通过。
  • bunx vitest run test/codex-app-cot.test.ts test/codex-app-runner-protocol.test.ts test/codex-app-runner.integration.test.ts:3 个文件、164 项通过。
  • 相邻 turn 生命周期测试:8 个文件、134 项通过。
  • worker 侧 Codex App 回归测试:9 个文件、187 项通过。
  • git diff --check 1d4dd5bbb7..3026bab5ca:通过;探针运行后无残留测试进程。

当前 head 的 GitHub 记录只有 network-boundary 检查,仍为 queued,因此本结论不包含 CI 全绿声明。

无 questions 的 async agentMessage 原样 display,缺少尾随换行时会与
后续终端输出连成同一行。仅在 PTY 输出侧按 endsWith('\n') 条件补换行,
thinking marker 仍使用原始文本;plain/plain-null 集成用例增加行边界
断言,变异验证能咬红。

Co-Authored-By: Claude Fable 5 <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner

复审指出的 P3(纯文字提醒与后续终端输出连行)已在 7e65d44 修复。

修法:output.display 前对未以 \n 结尾的提醒文本补一个换行(已带换行的不重复添加);thinking marker 继续使用原始文本,进度通道行为不变。plain/plain-null 两个集成用例增加行边界断言(不得出现 提醒文本Independent work completed 连写,且必须存在 提醒文本\nIndependent work completed)。

验证:摘掉换行补全的变异下两个用例按预期咬红、恢复后通过;bun run build 通过;codex-app-cot / runner-protocol / runner.integration 共 164 项通过。

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论(7e65d445)

此前报告的终端连行 P3 已修复;本次增量复审没有发现新问题,无阻断,可合。

  • src/codex-app-runner.ts:1645 只在 PTY display 前条件补 \n,已有换行不会重复添加;params.item.text 未被改写,后续 publishTurnThinking 仍消费原始通知文本。
  • test/codex-app-runner.integration.test.ts:876-877 同时钉住“禁止连写”和“必须存在行边界”,覆盖 plain 与 plain-null 两条路径。

本地验证

  • bun run build:通过。
  • bunx vitest run test/codex-app-cot.test.ts test/codex-app-runner-protocol.test.ts test/codex-app-runner.integration.test.ts:3 个文件、164 项通过。
  • 变异复验:临时将条件补换行恢复为 output.display(item.text),plain / plain-null 两个用例如预期咬红,实际输出仍为 Complete sign-in in your private terminal.Independent work completed;恢复实现后两个用例通过。
  • 已有换行分支探针:临时让 plain fixture 的提醒自带 \n,两个用例通过,确认不会重复补行;恢复 fixture 后再次通过。
  • git diff --check 3026bab5ca..7e65d445c4:通过;所有探针均已恢复,工作区干净,无残留测试进程。

当前 head 已登记的 network-boundary 检查通过(2m5s):https://github.com/deepcoldy/botmux/actions/runs/45812193735

@deepcoldy
deepcoldy merged commit 6029b8d into deepcoldy:master Nov 26, 2026
41 of 43 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

感谢贡献,已合并进 master(6029b8d)。

这个修复把 delivery=async 的纯文字提醒与异步提问正确分流:带 questions 的继续走提问卡,缺失/null 的作为本轮进度与终端输出,且重复通知只显示一次,补上了原先误报「提问格式不支持」的缺口。评审过程中补齐了 collector 分流守卫的直接单测,并处理了纯文字提醒缺尾换行导致的终端连行,均已随本 PR 合入。

目前没有遗留的 follow-up 事项。欢迎继续贡献。

@github-actions

Copy link
Copy Markdown

@uestcwangci @deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。

这次运行覆盖 689970b…36f11a21e(11 个提交),同批合入的还有 #3846 #3881 #3870 #3869 #3868 #3877 #3875 #3876 #3885 #3883,失败不一定由本 PR 引起。

用例 跑道 状态 失败信息
Sandbox hides home and harness secrets feishu-core-sandbox failed Replanned 20 times, exceeding the limit. Please configure a larger value for replanningCycleLimit (or use MIDSCENE_REPLANNING_CYCLE_LIMIT) to handle more complex tasks.

@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants