Skip to content

fix(worker): adopt 模式下跳过畸形 CoT text 条目,不再中断活动流 - #3742

Merged
deepcoldy merged 1 commit into
deepcoldy:masterfrom
yintamaa:fix/3669-adopt-cot-malformed-entry
Nov 23, 2026
Merged

deepcoldy merged 1 commit into
deepcoldy:masterfrom
yintamaa:fix/3669-adopt-cot-malformed-entry

Conversation

@yintamaa

Copy link
Copy Markdown
Contributor

改了什么、为什么

adopt 模式下,observeCotEntries 会原样保留 CoT 条目。遇到 text 不是字符串的 text 条目时,cotEntryChars 执行 e.text.length 会抛 TypeError,本次 transcript drain 后面的活动条目全部丢失。

现在 adopt 路径和非 adopt 路径一样,丢弃这类畸形条目。其余条目(包括 sentinel 原文)照旧原样保留,adopt 模式「不剥 sentinel」的语义不变。

影响面

只改了 src/worker.ts 里 observeCotEntries 的 adopt 分支。非 adopt 路径、cotEntryWithoutSentinel 以及各 CLI 的观测函数都没动。

验证

  • 先补了 adopt 模式的回归用例,在未修改的 master(226fe48ac)上确认它失败:TypeError: Cannot read properties of undefined (reading 'length')
  • bun run test -- test/worker-cot-malformed-entry.test.ts test/background-wait-card.test.ts test/cli-progress-notice.test.ts test/dsh-cot.test.ts:4 个文件,149 个用例全部通过
  • bun run build(含 typecheck 和 dist 审计)通过
  • 没跑完整的 unit 套件和 e2e,也没在飞书 live 实测,因为手头没有能稳定产出畸形条目的真实 adopt 会话

Fixes #3669

🤖 Generated with Claude Code
)

adopt 会话原样保留 CoT 条目,遇到 text 不是字符串的条目时 cotEntryChars
抛 TypeError,本次 transcript drain 的后续活动条目全部丢失。adopt 路径改为
和非 adopt 路径一样丢弃这类条目,其余条目(含 sentinel 原文)照旧保留。

Fixes deepcoldy#3669

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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.

PR #3742 复审|head b1d3824d|结论:代码层面可合

  • 阻断发现:无。未发现 P1 / P2 / 合前必修 P3,也未发现首审结论需要翻转的依据。
  • 审查对象:远端 head 确认为 b1d3824d43ec07724c4fe0faa1d1d01fb9d436bf;本地 rebase 提交 9914e9b2c 基于最新 origin/master(8157a3717),两者默认 git patch-id 均为 6a5d6f3bc8778a826700cd3a05cace8fb08ed5a0,git diff --check 通过。
  • 修复正确性:src/worker.ts:10525 仅在 adopt 分支丢弃 kind === 'text' 且 text 非字符串的条目,并在 src/worker.ts:10549-10552 的字符统计前完成过滤;合法条目的顺序和内容不变,包括 adopt 模式必须原样保留的 sentinel。非 adopt 的 sentinel 剥除路径未改。
  • 回归用例有效:test/worker-cot-malformed-entry.test.ts:44-47 通过 worker function harness 执行真实函数,同时断言「不抛错」和 thinkingEntries 与完整 tail 相等,既覆盖后续条目不丢,也钉住 sentinel 不被误剥。
  • 影响面:变化只发生在 adopt 会话收到畸形 text 条目时;其它 CLI 的合法 CoT 条目、非 adopt 会话、工具调用/结果及持久状态语义均未改变。
  • 首审非阻断项:cotEntryChars 对其它 kind 的畸形字段仍是既有、两条路径对称的通用硬化缺口,不是本 PR 引入或扩大的回归;可另行整体加固,不拦本次合入。

本次实际验证

  • bun run build:通过(含 typecheck、dashboard bundle 与 dist 审计)。
  • bun run test -- test/worker-cot-malformed-entry.test.ts test/background-wait-card.test.ts test/cli-progress-notice.test.ts test/dsh-cot.test.ts test/antigravity-runtime.test.ts test/worker-kimi-activity-wiring.test.ts test/worker-codex-app-process-attestation.test.ts:7 个文件、215 个用例全部通过。
  • 未另跑完整 unit / e2e 或飞书 live;该修复无需改动持久状态或部署形态。

CI

截至本复审发布时,Sandbox network boundary 已通过,CI 的 build / test / bun-test / binary 各项仍在 queued 或运行中;最终合并仍以这些检查全绿为前提。

@deepcoldy
deepcoldy merged commit 897662a into deepcoldy:master Nov 23, 2026
16 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner

感谢修复,PR 已 squash 合入 master,#3669 随之关闭。

评审中确认:adopt 分支新增的过滤只丢弃 kind === 'text' 且 text 不是字符串的畸形条目,合法条目(含 adopt 模式需原样保留的 sentinel)不受影响,与非 adopt 路径的既有守卫语义一致;变异验证下新增回归用例能准确咬红。

一个非阻断的后续建议(不影响本 PR 合入):cotEntryChars 对 thinking/tool_call/tool_result 的非字符串字段目前没有防御,极端畸形数据下两条路径仍会抛 TypeError。当前仓内所有条目生产侧都有类型守卫、实际不可达,可另开 issue 做整体硬化。

以上为自动评审流程的记录,最终以维护者审阅为准。

deepcoldy pushed a commit that referenced this pull request Nov 23, 2026
…ld-composer

同步 #3739 合入后的最新 master(f16cdcb3ad,含 #3713/#3715/#3723/#3742/#3744)。
git 自动合并零冲突;名义交集 src/worker.ts 与 src/i18n/{zh,en}.ts 上双方改动位于
不同区域,已逐项核对本 PR 的改名回执/reattach 恢复逻辑与 master 侧改动
(#3742 畸形 CoT 跳过等)均在合并树中。
验证:tsc --noEmit、bun run build 通过;8 个定向测试文件 251 例全绿
(含两个新测试文件与 worker-cot-malformed-entry)。

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

Copy link
Copy Markdown

🚀 Released in v3.59.30

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.

fix(worker): adopt 模式下畸形 CoT text 条目抛 TypeError 并中断当次活动流

2 participants