Repository navigation
[PR] fix: client mid-history system messages ride verbatim on every wire (carrier re-voice narrowed to bili's own) (#4166, fixes #4159) - #4171
Conversation
) openaiToCore keeps the raw wire message on mid-history system/developer cores (rawOpenaiMessage); coreToOpenai re-emits it byte-exact, re-laying plain text when kernel ops rewrote it. hasUnrecoverableMediaPayload: structured (non-plain-text) mid system never folds — DSH tool_addition style declarations survive instead of being stringContent-flattened.
…car cores (#4166) responsesToCore hoists only the LEADING system/developer prefix into systemParts (strict single-system upstreams keep their merged head, #377); mid-history items become positioned cores carrying the raw item (rawResponsesItem) — replacing the host #1638 re-typing trick for plugin/codex clients with codec-native position preservation for every mode. coreToResponses re-emits sidecar items byte-exact (kernel text rewrites re-lay plain content). hasUnrecoverableMediaPayload: structured (role-guarded) mid system items never fold.
…only bili's carriers re-voice (#4166, #4159, #4165) kernel (mirrors #3992 on the remaining two wires): - openai: mid-history system parses with a rawOpenaiMessage verbatim sidecar; coreToOpenai re-emits it byte-exact (re-blocked only when the kernel itself edited the text); non-plain-text system is unfoldable - responses: mid-history system/developer become positioned sidecar cores (refs + fold coverage + layout slots); head prefix still hoists (#377); coreToResponses re-emits raw verbatim; kernel 0.0.149 host: - systemToUser/revoiceMidSystemDevelopers take a predicate; both codecs re-voice ONLY isRenderedSummaryMessage carriers — client-origin mid system/developer is data, never re-voiced (#4159) - prepare-responses: #1638 re-typing hack retired (codec-native now, mode-invariant projection — the plugin->proxy degrade no longer re-projects or re-bills, #2867); #3713 masking retired (real cores) - compress-loop-responses: visibility markers + retrieval injections are born user; no blanket re-voice on the re-request - loop/adapter-openai: same carrier-only narrowing (loop/prepare parity)
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4984-pr.4171.5115dbdThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4171.tgz
npm install -g packageInstall instructions are refreshed on each push. |
1895de8 to
8b2da08
Compare
8b2da08 to
0ce4a1c
Compare
The non-stream JSON loop no longer re-voices mid-history sys/dev items (#4166: client-origin items ride verbatim; bili's own visibility/retrieval injections are born user), so the function's last production caller is gone. Remove it plus its dedicated pin; the surviving systemToUser predicate tests are untouched.
…m since #4166) (#4171 review) The openai wire-drop detector counted every non-user role's non-text parts as dropped. #4166 makes mid-conversation system/developer messages ride the codec verbatim (rawOpenaiMessage sidecar), so the exact #4159 tool_addition shape would now trigger a false 'will drop' warn on every healed session. Narrow the scan to the surviving drop class — assistant/tool roles plus the leading system/developer run (still stringContent-flattened into systemText) — and pin both directions.
|
(ai: vllm-qwen/qwen3.8-27b) 独立深审(重读 diff + 本地跑码验证)另一个 agent 会话对同一区域做了独立并行分析(#4166 的平行实现),设计收敛到与本 PR 相同的选择(sidecar 逐字往返 + 载体用形状谓词判别而非新增字段)。以下结论由我独立重读 diff、本地运行代码后产出,未照抄 issue / PR 正文。 ① 方向判定:正确根因(摘要载体伪装成普通 system 消息上 wire、无一等信息身份 → 每条线 × 每种后端按角色形状一刀切补丁)与家族谱一致;把 #3992 的 anthropic 先例推广到另两条线是正确的收口点。responses 线只把开头连续 prefix 提升进 instructions、中途项保位置,修掉了未报告的附带伤害。 ② 回归审查(既有行为清单逐项)
③ 测试有效性新 e2e(tests/issue4159-client-mid-system-verbatim.test.ts)断言有牙:tool_addition exactly-once + role 保持 system + 位置在中间 + 跨 full-resend 轮次字节稳定。pin 文件双向(锚 + 绿契约 + fold-gate 行)。rebaseline 测试断言的是新契约本身,不是恒真改写。 ④ 行为变更清单(PR body 均已披露;补一条)
⑤ 状态本地定向验证(final head):D-trio 11/11、rebaselines 7/7、verif+pins+byte-stability 44/44、golden pair 17/17、host suites 26/26、drop-warn 20/20、typecheck 干净。远程 CI:2745e8739(死代码清理提交)的完整 CI + 全部 12 条 E2E 车道已全绿;最终 head ae93600(drop-warn 修复)的 push 事件未被送达(PR head 未推进、无自动 run),已按 ci.yml 注释里记载的补偿路径对该分支触发 workflow_dispatch(run 39624996201,排队中)——check-runs 落在同一 head sha(#772/#1744 模式),绿了即补齐。 判定:方向正确、实现收敛、全部确定性红已在分支内解决;最终 head CI 全绿后可合(前提仍是 #4167 打桩 PR 先合,stacking 顺序按 owner 指令)。 |
…ate-branch; GitHub UI unavailable)
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.730-master.fe5ba59 # this exact build
npm install -g billion-context@master # always the newest merged build
|
(ai: zhipuai-lb/glm-5.3)
kernel-change: mid-history system/developer verbatim sidecars on the openai + responses wires (the #4166 plan filed in #3939's sibling issue; stacked on the pins PR #4167 — merge that first, the diff here collapses to the real change after).
Part of #4165 (总账). Fixes #4159.
What
Two wires still treated client mid-history system messages as bili artifacts to rewrite (the anthropic wire fixed it yesterday in #3992):
rawOpenaiMessageverbatim sidecar (mirror of [PR] kernel: keep mid-conversation anthropic system messages verbatim (#3991) #3992);coreToOpenaire-emits byte-exact; structured (non-plain-text) system messages are unfoldable — tool_addition increments can no longer be silently flattened ([Bug] DeepSeek/OpenAI wire: compression re-serializes mid-conversation system messages,tool_additionblocks rejected (INVALID_REQUEST) #4159's silent-loss variant) or re-voiced into user messages ([Bug] DeepSeek/OpenAI wire: compression re-serializes mid-conversation system messages,tool_additionblocks rejected (INVALID_REQUEST) #4159's hard-400 variant).systemToUser/revoiceMidSystemDeveloperstake a predicate; both codecs + the loop adapter re-voice ONLYisRenderedSummaryMessagecarriers — the [Bug] ACP: ≥2 compressed blocks render as multiple system messages → SGLang (vLLM-compatible) upstreams return 400 #377/fix(#377): re-voice mid-stream acp_summary as user messages (user-carrier) #428/# [Bug] DSH 插件模式 + OpenAI Responses 上游:compress 后摘要载体以developer角色插入历史中段,严格单-system 后端 400「System message must be at the beginning」 #1999 carrier contracts are unchanged (pinned bytests/e2e-mid-system.test.ts), while client system/developer data now rides verbatim everywhere.user(bili's own artifacts take the [Bug] ACP: ≥2 compressed blocks render as multiple system messages → SGLang (vLLM-compatible) upstreams return 400 #377-sanctioned user voice from birth); the blanket re-voice on the re-request is gone.Visible behavior
compat.roles) instead of bili silently rewriting it.Tests
tests/issue4159-client-mid-system-verbatim.test.ts: DSH-shaped tool_addition mid system rides verbatim, byte-stable across 3 requests.tests/responses-mode-switch-fingerprint.test.ts: degrade-to-proxy no longer re-projects — resent prefix byte-identical, no projection-switch event.tests/e2e-mid-system.test.ts(carrier re-voice [Bug] ACP: ≥2 compressed blocks render as multiple system messages → SGLang (vLLM-compatible) upstreams return 400 #377) unchanged and green — the narrowing does not touch carriers.Rollback
Each commit is isolated (kernel openai / kernel responses / host narrowing); revert any single one and its pins go red, nothing else.
Stacked on #4167 — merge order: #4167 → this PR.