Repository navigation
fix(codex): 提交确认兼容 Codex 去掉首尾空白后写入的历史记录 - #3089
Merged
Merged
Conversation
Codex 把提交的输入框文本去掉首尾空白后才写进 history.jsonl(真实 Codex 0.150.0 / 0.164.0 / 0.166.0 / 0.167.0 均如此)。botmux 按原文逐字比对,开头 或结尾带空白(例如结尾换行、开头缩进)的消息明明已执行,确认也永远对不上, 延迟复查后报 submit_unconfirmed。 historyTextMatches 在逐字和 CRLF 归一比对之外,再接受去掉首尾空白后相等的 记录;全空白的输入不参与放宽比对。归属过滤(acceptSid / proveSid)不变。
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 17:09
Owner
Author
|
head 按合码标准 G4 不靠同 SHA 重跑:等 #3116 合入后本 PR 同步 master,转绿再合。 |
|
🚀 Released in v3.59.0 |
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 会话「频繁」出现:
但任务实际已经执行。
根因
Codex 把提交的输入框文本去掉首尾空白后才写进
~/.codex/history.jsonl。writeInput的提交确认按原文逐字比对(只做了 CRLF 归一),所以开头或结尾带空白的消息无论等多久都对不上,延迟复查后发 submit_unconfirmed 卡片。默认注入模式下消息被
<session_id>…</user_message>等标签包住,首尾不会是空白;用户原文直接下发的路径(零注入、转写 + 单聊的精简信封、adopt 桥接)只要飞书消息结尾带空行或开头带空格就会命中。实测(私有 tmux + 本地 mock Responses 服务,真实 Codex 二进制,空闲发 6 条、忙时发 2 条):
col1\tcol2\ntrailing newline\n\n被去掉indented start7 个任务全部执行完成,只有确认对不上。
改动
src/adapters/cli/codex.ts的historyTextMatches:逐字、CRLF 归一之外,再接受「去掉首尾空白后相等」的记录;全空白输入不参与放宽比对。归属过滤(acceptSid/proveSid)、在线等待、延迟复查都不变。影响面
测试
test/codex-history-trimmed-match.test.ts(按 Codex 的写法去掉首尾空白、CRLF → LF 后写 history):inband=NO / recheck@20s=MISSING,修后 8 条全部在线确认。bun run build、tsc --noEmit通过;Codex 相关 28 个测试文件全绿(cli-adapters.test.ts里 3 条 dsh 用例在本机默认 TMPDIR 下因路径形状不同而红,TMPDIR=/var/tmp下 501 条全绿,与本改动无关)。🤖 Generated with Claude Code