Codex 干完活我总是后知后觉,我给它加了一个“完工提醒”

最近我在高频用 Codex 写代码、改脚本、整理内容。 但这件事在执行过程中也存在一个问题: 我把任务交给它之后,人就去干别的了。结果它什么时候干完,我根本不知道。 很多时候不是我不想盯着它,而是没必要一直盯着。 Codex 在那边读文件、改代码、跑验证,我在这边回消息、看资料、写别的东西。等我再切回来,常常已经过去了几分钟,甚至更久。 问题不在于它有没有完成。 问题在于: 它完成了,但我没有被及时通知。 所以我给自己做了一个很小、但非常实用的增强: 在同一个会话里,只要 Codex 完成一轮任务并输出最终回复,就给我一个声音反馈。 这个改动不大,但实际体验提升非常明显。 解决思路 要解决这个问题,首先需要确定 Codex 在本机运行时,有没有留下可监听的“任务完成事件”? 排查下来,Codex 本机会把会话数据写到: text 体验AI代码助手 代码解读复制代码C:\Users\Administrator.codex\sessions...*.jsonl

这个路径下面的会话日志,不只是简单文本,而是结构化事件流。 继续往里看,很快就能发现几类不同事件:

中间进度更新 工具调用 工具输出 assistant 最终回复

其中最关键的是这一类:

role = assistant phase = final_answer

这意味着,提醒不需要依赖未公开的内部 Hook。 我只需要:

启动 Codex 后台监听新产生的会话日志 一旦发现新的 assistant final_answer 立刻播放提示音

实现方案 我最后实现的是一个很轻量的包装方案。 结构大概是这样: text 体验AI代码助手 代码解读复制代码AIStudio/ codex-v.ps1 codex-v.cmd 12_Automation/ Scripts/ codex_notify/ codex_notify.ps1 README.md

它的职责分成两层: 第一层:简化启动入口 我不想每次都敲一长串命令,所以在仓库根目录放了:

codex-v.ps1 codex-v.cmd

这样以后在项目根目录里,直接输入: powershell 体验AI代码助手 代码解读复制代码.\codex-v.ps1

就能启动带提醒能力的 Codex。 第二层:真正的提醒脚本 内部的 codex_notify.ps1 负责做三件事:

启动实际的 Codex CLI 后台监听 ~/.codex/sessions/*.jsonl 检测到新的 assistant final_answer 时播放提示音

同时它还保留了异常处理:

正常单轮完成:播放完成提示音 异常退出:播放错误提示音 手动中断:播放中断提示音

这样你既有“业务完成提醒”,也不会丢掉“程序异常提醒”。 不只是一个提示音 表面上看,我只是给 Codex 加了一个声音提醒。 但本质上,我解决的是一个与AI高效协作的问题: 当 AI 开始承担连续执行工作时,人和 AI 之间需要一个清晰的“接力信号”。 以前你自己写代码,任务完成这件事是你感知到的,因为手一直在键盘上。 但现在 Agent 能连续跑十几分钟,甚至更久,你人不可能一直盯着。 这时候,“做完了请叫我一声”,就不再是一个可有可无的小功能,而是会直接影响工作流顺不顺。 所以这个小改动对我来说,价值不是“多了一个音效”。 而是: 可以放心把任务交出去,然后等它完成后叫我回来验收结果。 有了这个提醒后,整个使用体验会顺很多:

不用一直盯终端 不会错过单轮任务完成 可以真正把 Codex 当成后台执行搭档 https://infogram.com/docx-1h0r6rzokm17w4e https://infogram.com/docx-1hxj48m08dkvq2v https://infogram.com/docx-1h0r6rzokmn1w4e https://infogram.com/docx-1hnq41oy1e73k23 https://infogram.com/docx-1h0r6rzokmjnw4e https://infogram.com/docx-1hnp27e0pd3zn4g https://infogram.com/docx-1h0r6rzokylgl4e https://infogram.com/docx-1h7v4pdvklnlj4k https://infogram.com/docx-1hnp27e0pd37y4g https://infogram.com/docx-1h9j6q7ow9gy54g https://infogram.com/docx-1hnp27e0pdmly4g https://infogram.com/docx-1h0r6rzokyzlw4e https://infogram.com/docx-1h1749w08zwkl2z https://infogram.com/docx-1hnp27e0pde1n4g https://infogram.com/docx-1h984wvw85vld2p https://infogram.com/docx-1hmr6g8m9x83o2n https://infogram.com/docx-1h7v4pdvkld7j4k https://infogram.com/docx-1hxj48m08gmx52v https://infogram.com/docx-1h984wvw85j3z2p https://infogram.com/docx-1h1749w08zkxl2z https://infogram.com/docx-1h984wvw85j1d2p https://infogram.com/docx-1hmr6g8m9xeno2n https://infogram.com/docx-1h7v4pdvkl31j4k https://infogram.com/docx-1hxj48m08g7552v https://infogram.com/docx-1h984wvw850oz2p https://infogram.com/docx-1h1749w08zxol2z https://infogram.com/docx-1h9j6q7ow9yx54g https://infogram.com/docx-1h7v4pdvkl9m84k https://infogram.com/docx-1hnp27e0pd5vn4g https://infogram.com/docx-1h984wvw850wd2p https://infogram.com/docx-1h0r6rzok3jnl4e https://infogram.com/docx-1hxj48m08o5r52v https://infogram.com/docx-1h1749w08ol0l2z https://infogram.com/docx-1h9j6q7owpvr54g https://infogram.com/docx-1hnq41oy13kzk23 https://infogram.com/docx-1hxj48m08o59q2v https://infogram.com/docx-1h1749w08ovvq2z https://infogram.com/docx-1h9j6q7owpgyv4g https://infogram.com/docx-1h984wvw8qo8z2p https://infogram.com/docx-1h0r6rzokepgw4e https://infogram.com/docx-1h0n25o093ovz4p https://infogram.com/docx-1hnq41oy13odk23 https://infogram.com/docx-1h0n25o093kml4p https://infogram.com/docx-1hnp27e0pok1y4g https://infogram.com/docx-1hxj48m08o3w52v https://infogram.com/docx-1h0r6rzoke0ow4e https://infogram.com/docx-1hmr6g8m91e3z2n https://infogram.com/docx-1h0n25o093kqz4p https://infogram.com/docx-1h7v4pdvkp3784k https://infogram.com/docx-1hnq41oy135gk23 https://infogram.com/docx-1h0r6rzoke3zl4e https://infogram.com/docx-1hmr6g8m91weo2n https://infogram.com/docx-1h9j6q7owpyxv4g https://infogram.com/docx-1hxj48m08o7q52v https://infogram.com/docx-1h984wvw8q0wz2p https://infogram.com/docx-1h0n25o093mlz4p https://infogram.com/docx-1h984wvw8qqod2p https://infogram.com/docx-1h1749w08oooq2z https://infogram.com/docx-1h7v4pdvkppej4k https://infogram.com/docx-1hxj48m08oo052v https://infogram.com/docx-1hnp27e0pon3n4g https://infogram.com/docx-1h984wvw8qzvd2p https://infogram.com/docx-1h9j6q7owpj8v4g https://infogram.com/docx-1hnp27e0ponqy4g https://infogram.com/docx-1hxj48m08ovj52v https://infogram.com/docx-1hmr6g8m91oxz2n https://infogram.com/docx-1h0n25o093znz4p https://infogram.com/docx-1hnq41oy13qkk23 https://infogram.com/docx-1h984wvw8qpjd2p https://infogram.com/docx-1h0r6rzokexel4e

评论

暂无评论