Repository navigation
[PR] Fix: control-plane system messages collapsed as regular messages + position validity fallback (#4457, #4292 family root | 修复:控制面 system 消息按普通消息折叠 + 位置合法性兜底(#4457,#4292 家族根修) - #4465
Conversation
…backstop (#4457) Root fix for the #4292 family: the never-fold carve for sidecar system cores (anthropic tool_addition deltas / openai structured mid systems / responses items) leaked them unbounded while folding their neighbours, orphaning them into wire positions Anthropic rejects (permanent 400) and forcing an ever-growing chain of special cases (#4292 re-voice, #4400 tool-block exemption, #4457 S1/S2 signatures). - protected.ts: drop the sidecar never-fold branches (all three wires); sidecar systems fold like ordinary messages — folding is reversible and tools[] re-states current toolsets. Remove now-dead isPlainTextResponsesSystemItem. - wire/anthropic.ts: replace the fold-signature re-voice with a position-based backstop (healIllegalSystemPositions): any non-directive system whose first non-system follower is neither an assistant nor the array end is healed — re-voiced to user with tool_addition/tool_removal stripped (WC-022), dropped when nothing remains. Legal layouts stay byte-exact. - kernel 0.0.160 -> 0.0.161.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5369-pr.4465.003f5b4This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4465.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The kernel bump landed kernel/package.json + kernel/package-lock.json at 0.0.161 but the root package-lock.json still recorded the file-linked kernel at 0.0.160, so the root lock-sync step kept failing. Regenerated via npm install --package-lock-only; single-line delta.
(ai: vllm-qwen/qwen3.8-27b) 查重:不涉及 —— 本条是 #4465 的 CI 自动修复通道,只在该 PR 分支上修 做了什么:找到 结构化八问:
收工判定: |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——open+closed 检索中 #4457/#4400 家族(#4292→#4396→#4418)的唯一在途修复条目即本 PR;它取代 #4418(方向 D,我在 #4418 floor 4 的独立审核已判定其前提「Anthropic 接受中段 tool system」与仓库全部证据相反、大概率无效,并给出转方向 A 的建议)。本 PR = 折叠层根修 + 泛化 A(位置规则兜底),正是那条推荐路径的完整形态。 标签:bug / claude-code / pi / dsh / scope/kernel / p1(正文点名三车道均受影响;p1=会话永久 400 + 上下文只增不减泄漏类)。 独立审核动作(未复述 issue 结论,分支
八问:
收工判定:代码质量达标,方向正确,两层测试有牙且本地定向全绿——CI test shards 全绿后即可合(kernel 改动,人审合并,不合 auto-merge)。合并后请 owner 关闭被取代的 #4418(PR 正文已注明由其关闭,#4400/#4457 随 merge 自动闭环)。CI 结果出来我再跟一条确认。 |
…review fix) Review correction against the official Anthropic mid-conversation tool-changes contract: tool_addition/tool_removal deltas are FUNCTIONAL - tools[] stays static by design and the deltas control the offered tool set (defer_loading surfacing, by-value definitions, removals, MCP toolsets). Folding them would silently alter the effective tool set, so the protected.ts never-fold carve is restored verbatim. The position-based emission backstop (healIllegalSystemPositions) is kept: it heals fold-orphaned sidecar systems into legal user entries (tool blocks stripped per WC-022, empty result dropped), fixing both field layouts - pre-anchor orphan (#4400 S1) and post-anchor orphan (#4457 S2) - while legal layouts stay byte-exact. Also drops empty-string healed entries instead of minting empty user messages, and realigns the touched tests to pin protection + healing through the real apply->prune->emit chain.
(ai: vllm-qwen/qwen3.8-27b) 分支新增 commit 自我纠正:我上一条判定「根因定位正确」所依据的前提 (b)——「sidecar system 声明的工具在每请求顶层 tools[] 有现行声明,折叠只丢时间线注记、模型能力零损失」——被仓库内证据推翻:
对新 head(8fc3618)的独立重审:
八问(修订版):
收工判定: |
(ai: vllm-qwen/qwen3.8-27b) CI 确认: 合并判定:具备条件,可合。 kernel 改动按边界规则人审合并。合并后请 owner 关闭被取代的 #4418(#4400/#4457 随 merge 自动闭环)。本 PR 审核到此收工。 |
|
(ai: zhipuai-lb/glm-5.3) 接受审查修正 8fc3618(身份 ci-check),已在本地复核:kernel 1465/1465、bili 相邻 29/29、typecheck、CI full 全绿。 我认可修正的技术判断:初版「tools[] 每次请求重述现行工具集」是宿主行为(Pi 如此),不是 Anthropic tool-changes 契约——该 beta 的设计就是 top-level tools[] 静态 + 增量控制系统性工具集(defer_loading/按值定义/MCP 工具集)。在无法验证宿主是否重述的前提下折叠增量 = 潜在静默工具丢失(wire fidelity 红线),「永不折叠」是正确的保守契约立场;增长泄漏保留为有界已知代价。 保留并强化的是本 PR 的核心:位置兜底 healIllegalSystemPositions 治愈全部非法形态(#4400 S1 + #4457 S2 + 存量会话 + 非法输入),空内容丢弃,合法布局字节不变。#4292 家族的「会话永久 400」从此在发射层关门。 PR body 已更新为最终设计。 |
(ai: vllm-qwen/qwen3.8-27b) 从 CI 门禁(lock-sync)这条线独立复核了当前 head
CI 门禁侧无回归、无遗留待办;PR 已就绪,等人工合并即可。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.781-master.76254c9 # this exact build
npm install -g billion-context@master # always the newest merged build
|
|
(ai: zai/glm-5.3) 已手动完成本 PR 的 backport(不等 #4472):从 发车路径(等 #4472 合并后):Actions → Release (one-click) → 勾 |
…touch the actions-variables API Maiden backport run (ranxianglei#4465, run 40053876329) died at resolve: gh api actions/variables/BACKPORT_TRAIN returned 403 'Resource not accessible by integration' — no workflow permissions-block category grants the variables API, so the variable-based pointer could never work under GITHUB_TOKEN. Replace the stored state with a derived one: the open train IS the newest bugfix-release/* branch whose BASE version (suffix stripped) is strictly above the latest v* tag. Cutting = pushing such a branch; publishing = the tag catching up (auto-closed). The suffix-strip matters: raw string sort ranks v0.1.206-train above tag v0.1.206 and would wrongly reopen a shipped train (6-case table verified locally). Reconciled with c5df0eb (landed meanwhile on the same files): - KEPT its pick hardening verbatim (rev-list --reverse --no-merges housekeeping-merge expansion, squash/rebase shape refusal with the partial-fix rationale, identity-before-pick, explicit train fetch, ci.yml dispatch by filename, rerun-conflict breadcrumb); - RESTORED auto-cut on 'no train open' — the owner asked for the full-lifecycle automation in-session ('能自动化吗', 2026-10-24); c5df0eb reverted it for lack of in-thread sign-off, its own message notes it can come back with owner approval, which this is; - gate reads the PR via gh api (merged/labels/merge_commit/head sha), enabling a NEW workflow_dispatch pr=<number> repair path — which is also how the ranxianglei#4465 backport gets retried once this merges. release-manual.yml train mode derives the same way; release-bugfix.yml tail variable-clear becomes a notice (the tag closes the cycle); reference/release.md documents the derivation model, the 403 lesson, and git-ref manual overrides.
kernel-change: 根修 #4292 家族的发射层;#4457 泄漏面部分保留(见「审查修正」);kernel 0.0.160 → 0.0.161
Fixes #4292
Closes #4400
Relates #4457
现象(人话)
客户端(Claude Code / Pi / DSH)在对话中段发 system 消息声明工具增量(tool_addition)。折叠掉它们周围的 assistant 后,这些消息落在 Anthropic 拒绝的位置 → 整个会话永久 400(messages.N: role system must precede an assistant message or end the array)。此前 #4396 的折叠签名 re-voice 撞上「tool_addition 只能在 system 里」(#4400),又提议豁免工具块——特判链越来越长。
最终设计(含审查修正 8fc3618)
初版(8b8f935/b0180459)把这类消息改为可折叠;审查修正推翻了折叠,保留兜底:**
hasUnrecoverableMediaPayload的 sidecar 永不折叠 carve 原样保留。审查理由(Anthropic tool-changes 契约):tool_addition/tool_removal 增量是功能性的——top-level tools[] 按设计保持静态,增量控制有效工具集(defer_loading 呈现、按值定义、移除、MCP 工具集)。折叠增量会静默改变有效工具集(模型丢失工具,能力损失)。「tools[] 每次请求都会重述」是宿主行为而非契约,代理不能假设。[Bug][anthropic] 0.1.205: 400 "role 'system' must precede an 'assistant' message" still occurs with #4396 present (mid-conversation system + tool_addition, cf. #4400) #4457 的增长泄漏因此保留为已知代价(通常每会话只有少量工具集变更,有界)。healIllegalSystemPositions按位置规则治愈一切非法形状——任何非 directive-only 的 system,其后的第一个非 system 消息既非 assistant 也非数组结尾 → 重配音为 user(tool_addition/tool_removal 块按 WC-022 剥离,剥空整条丢弃,空字符串内容同样丢弃而非铸出空 user 消息);按连续 run 判定(Pi 末尾工具 run 合法,字节原样)。同时治愈 Collapsed orphan system message with tool_addition blocks: re-voicing fix switched to a different 400 (#4396 residual su | 带 tool_addition 块的折叠孤儿 system 消息:重配音修复换了一种 400(#4396 遗留子洞) #4400 S1(anchor 前)与 [Bug][anthropic] 0.1.205: 400 "role 'system' must precede an 'assistant' message" still occurs with #4396 present (mid-conversation system + tool_addition, cf. #4400) #4457 S2(anchor 后)两种形态;老版本折叠过的存量会话和位置非法的客户端输入也一并治愈;合法布局字节完全不变(缓存稳定)。测试(两层,both-direction #3617)
issue4457-sidecar-system-folds.test.ts重定向为钉「保护 + 真实 apply→prune→emit 链路治愈」;issue4292-orphan-system-guard7 处更新为位置规则;anthropic-system-message-passthrough/issue4166-*(openai/responses 钉子回到永不折叠)/ bili 侧issue4292-anthropic-fold-orphan-system对齐。config surface
无。
关系