Skip to content

[PR] fix: collapse orphaned tool blocks; system no longer re-voiced as user (#4400, #4292 residual sub-issue) | fix: 折叠孤儿的 tool 块 system 不再 re-voice 成 user(#4400,#4292 遗留子洞) - #4418

Closed
ranxianglei wants to merge 2 commits into
masterfrom
2026-10-23_kernel-4400-tool-orphans
Closed

ranxianglei wants to merge 2 commits into
masterfrom
2026-10-23_kernel-4400-tool-orphans

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

kernel-change: fix #4400 — #4396 的 re-voice 修复对带 tool 块的孤儿 system 换了一种 400,需要 kernel 内豁免

现象(人话)

折叠把宿主发的"工具更新"system 消息(带 tool_addition/tool_removal 块)变成孤儿后,#4396 的修复会把它改写成 user 消息再发给 Anthropic —— 但 Anthropic 规定 tool 块只能出现在 system 消息里(WC-022 台账),于是这个会话还是会吃 400、永久打死。和 #4292 原始 bug 同一种死法,只是换了个拒绝理由。

根因

修复

影响面

  • 只影响 Anthropic 线上折叠后的孤儿 system 发射;正常流量(未折叠、合法位置)字节不变,前缀缓存不受影响。
  • 受益宿主:omp 18.12.6+、Claude Code 2.1.300+/VS Code 扩展(mid-conversation-system beta 用户)。

测试

  • kernel 套件 1463/1463;tests/wire-contract.test.ts + tests/issue4159-client-mid-system-verbatim.test.ts + tests/issue4166-openai-midsystem-pins.test.ts 23/23;typecheck 干净。
  • 本地未跑完整 CI(账号 Actions 停摆中,全仓库 26 run 排队 0 运行——已单独上报);恢复后以 CI test lanes 为准。

备注

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-23_kernel-4400-tool-orphans (2bb5e1f)

Latest build — install this exact version

npm install -g billion-context@0.0.5327-pr.4418.df215c3

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
2bb5e1f billion-context@0.0.5327-pr.4418.df215c3 build
9ef42aa billion-context@0.0.5301-pr.4418.773b864 build
5de6694 billion-context@0.0.5285-pr.4418.cccfa28 build
6aa3565 billion-context@0.0.5281-pr.4418.e6bf9c5 build
f989d1b billion-context@0.0.5276-pr.4418.22e0c64 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr4418.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: 折叠孤儿的 tool 块 system 不再 re-voice 成 user(#4400,#4292 遗留子洞) [PR] fix: collapse orphaned tool blocks; system no longer re-voiced as user (#4400, #4292 residual sub-issue) | fix: 折叠孤儿的 tool 块 system 不再 re-voice 成 user(#4400,#4292 遗留子洞) Oct 23, 2026
@ranxianglei
ranxianglei force-pushed the 2026-10-23_kernel-4400-tool-orphans branch from 5de6694 to 9ef42aa Compare October 23, 2026 14:14
@ranxianglei
ranxianglei force-pushed the 2026-10-23_kernel-4400-tool-orphans branch from 9ef42aa to 2bb5e1f Compare October 23, 2026 16:57
@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

状态说明:#4400 是 #4396(#4292 回归修复)留下的子洞收尾,对已发布的 v0.1.204 而言该形状本就不可用,严格口径下不算新回归。按 owner 决定「非回归问题本版不合并」,本 PR 留待下个版本(kernel 人工评审仍欢迎),保持 open、不阻塞发版。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复——open+closed issue/PR 检索只有本 PR 命中;它是 #4400 唯一在途修复条目(#4292/#4396 同机制链,已闭环)。
标签:bug / omp / claude-code / scope/kernel / p1(会话永久不可用;p1;kernel wire 层;omp 与 Claude Code 车道同时命中)。

本轮仅验证、未动代码(尊重「留待下个版本」的 owner 决定)。验证动作:拉分支逐文件读完全部 diff(6 文件 +145/-26)、对照 master 基线;重审 #4292 A/B 证据链、WC-022 台账与仓库内全部 tool_addition 流量 fixture;查 CI 与 PR 状态。

CI/状态:head 2bb5e1f0b 全绿(37 success / 14 gated skip / 0 fail——开 PR 时的 Actions 停摆已恢复);PR open、mergeable=true,但落后 master 4 个 commit(全是 #4439 CI shard 权重,与本 PR 零文件重叠,预期无冲突 rebase),合并前需 rebase。

对方向 D(本 PR 方案)的独立审核:判定大概率无效,不建议按现状合并。 D 的前提——「Anthropic 接受 tool-update system 出现在会话中段任意位置」——与仓库内全部证据相反:

  1. 官方位置规则:content-bearing system 后必须跟 assistant 或位于数组尾,豁免的只有 directive-only(空 content + output_config)——错误文案本身写明了这一点,没有 tool system 豁免条款;
  2. [Bug][anthropic] fold summary rendered as user right after a mid-conversation system message → 400 "role 'system' must precede an 'assistant' message" (0.1.204, since #3992) #4292 对真实上游的 A/B:system→user = 400;
  3. 新证据 A:仓库内所有真实流量 fixture(piBody 往返、WC-022 live probe)里,tool system 都位于数组尾或其后跟 assistant——从不直接跟 user。健康流量根本不产生 [system(tool), user],这正是生产一直没事的原因;而 D 发射的形状([.., system(text+tool_addition), user(锚点)])恰是健康流量里从不出现的形状;
  4. 新证据 B:本 PR 把测试侧「位置非法」的定义改了(positionIllegalSystems 排除带 tool 块的 system)——若上游真拒收该形状,套件会绿而会话永久 400,属假测试风险(Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 双向断言纪律的反面)。

决定性验证格无人跑过:带 beta 头向 api.anthropic.com 发 [user, system([text, tool_addition]), user]。若如预测 400,需转方向 A(re-voice 时剥离 tool 块)——A 由两个独立已验证事实组成(#4292 回放表「该 system 以 user 发出 → 200」+ WC-022 块角色规则),但有语义细节(伴随文本怎么处理、被剥声明是否仍在 top-level tools 里),需先讨论再动手。#4400 5F 审核方当时在等你确认改 A;本轮新证据进一步支持那条路。

结构化八问

  1. 是什么问题:折叠覆盖掉中部 tool-update system 消息后面的 assistant 后,[PR] kernel: folding orphaned system messages causes permanent 400 on Anthropic sessions — outbound fold signature guard (#42 | kernel: fold 孤儿 system 致 Anthropic 会话永久 400 — 出站折叠签名守卫 (#4292) #4396 守卫把该 system 逐字 re-voice 成 user,其中 tool 块违反 WC-022(只允许在 role:system 内)→ 会话永久 400。本 PR 给带 tool 块的 system 免 re-voice(方向 D)。
  2. 什么原因导致:两层——根因 = 折叠锚点恒插最早被覆盖位,必落在孤儿 sidecar system 之后([Bug][anthropic] fold summary rendered as user right after a mid-conversation system message → 400 "role 'system' must precede an 'assistant' message" (0.1.204, since #3992) #4292 机制);子洞 = [PR] kernel: folding orphaned system messages causes permanent 400 on Anthropic sessions — outbound fold signature guard (#42 | kernel: fold 孤儿 system 致 Anthropic 会话永久 400 — 出站折叠签名守卫 (#4292) #4396 修「位置规则」时没考虑「块角色规则」,re-voice 把位置非法的字节搬进了角色非法的 user 消息。
  3. 影响范围与严重程度:p1。触发 = mid-conversation-system beta 客户端(omp 18.12.6、Claude Code 2.1.300+/VS Code 扩展)+ 会话中工具更新 + 一次折叠覆盖其后 assistant;命中即永久不可用(每次重建同形状)。v0.1.204 里该形状本就不可用(不同报错),与「严格口径非新回归」判定一致。
  4. 怎么修复的:方向 D 已实现且测试双向钉住;但审核判定其前提未经上游验证且大概率不成立——合并前须补决定性 A/B 格,或讨论后转方向 A(owner 决策点,见上)。
  5. 是否有回归问题:逐项过——守卫不触发时出站逐字节不变(健康流量零影响);[Bug][anthropic] fold summary rendered as user right after a mid-conversation system message → 400 "role 'system' must precede an 'assistant' message" (0.1.204, since #3992) #4292 主线修复保留;directive-only 豁免不变;Pi 尾部 tool run 往返不变;客户端自发的位置非法形状保持 verbatim(kernel 是传输层不是校验器)。PR 内部无回归;风险在「修复可能无效」(方向问题),不在破坏旧行为。kernel 纪律合规(0.0.160→0.0.161 + lockfile 同步)。
  6. 是否破坏缓存:否——守卫不触发时逐字节不变;只有本来就在 400 的会话形状改变。
  7. 是否改了设计方向:无架构转向;若后续转 A,属 payload 级语义变更(剥块),需 owner 拍板 + kernel 人审。
  8. 是否引入新配置:无新增 env/config/默认值。

收工判定:PR 保持 open 至下个版本(不阻塞本版发布,与 owner 决定一致);进入下版合并窗口的前置条件 = ①决定性 A/B 格结果,或 ②讨论后转方向 A;合并前 rebase 到 master。本轮零代码改动。

@ranxianglei

Copy link
Copy Markdown
Owner Author

关闭:已被 #4465 取代。

如果这里面还有 #4465 没覆盖的独立改进,欢迎单独开新 PR 捡起来。

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

Projects

None yet

1 participant