You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wire/openai: kernel text-rewrite re-lay drops extra keys on text parts (e.g. gateway-stamped cache_control) #4201
Found during the v0.1.204 release review (PR #4190). Non-blocking edge case.
Where:kernel/src/wire/openai.ts — the re-lay path guarded by isPlainStringOrTextParts.
What: when the kernel rewrites a system/developer message's text (summary re-voice, append), the re-lay rebuilds text parts as {type:"text", text: <new>} — dropping any EXTRA keys the original parts carried (a gateway or host may stamp cache_control on OpenAI-wire content parts). The verbatim re-emit path (no rewrite) is byte-exact and unaffected; only the rewrite path loses the extras.
Impact: after a kernel rewrite of a system/developer message whose parts carried gateway-added keys, the re-emitted message no longer carries them → prefix-cache breakpoint loss on wires that use part-level cache stamps.
Suggested fix direction: in the re-lay, spread the original part object and override only text (preserve unknown keys), same discipline as the anthropic wire's rebuildSystemMessage.
Kernel-side change → owner approval per the kernel boundary; filing for triage.
影响范围与严重程度:仅 OpenAI-wire 车道,且需同时满足:gateway/host 在 system 族消息的 parts 上盖了 part 级键 + kernel 改写了该消息文本(或注入命中 parts-array 头)。后果是缓存命中率下降(成本问题),无数据丢失、无功能损坏——特定条件下的体验/成本瑕疵,p2。
怎么修复的:对齐 anthropic wire 既有纪律(rebuildSystemMessage 的 harvest-last 标记规则)——re-lay 改为展开原始 parts 的并集(同键后者赢)、只覆写 type/text;injectOpenaiSystem 对 parts-array 头保持形状不变,原 parts 逐字节保留,注入文本作为新的末尾 text part 追加。字符串路径一行未动。
Activity
ranxianglei commentedon Oct 21, 2026
(ai: vllm-qwen/qwen3.8-27b)
查重: 不重复。检索了 open+closed issues 与 PRs——所有
cache_control相关条目(#1639/#2191/#1103/#1616)都在 anthropic 车道或文档面,没有一条触碰 openai wire 的 re-lay/inject 路径。标签: bug / scope/kernel / p2(kernel 内 openai codec 丢 part 级元数据;触发条件窄、后果是缓存断点丢失而非功能损坏,与你「non-blocking edge case」的定性一致)。主题类别:A(前缀缓存接缝)。
修复完成 → PR #4232(kernel-change 已声明,kernel 0.0.151→0.0.152):#4232
结构化八问
cache_control之类)全丢了,前缀缓存断点随之失效。coreToOpenai的 re-lay 分支不复制原始 part 的未知键,而是从零拼一个裸{type:"text",text};verbatim 路径不动 raw、不受影响。修的时候发现同机制家族的第二处:injectOpenaiSystem每次向 parts-array 头部注入时把它塌缩成纯字符串——同样丢额外键,而且连结构化块(kernel: carrier self-identification + openai/responses mid-stream system verbatim sidecar (fixes #4159 family) | kernel: 载体自标识 + openai/responses 中途 system verbatim sidecar (治 #4159 家族) #4166 认定的客户端数据)一起丢。两处同属「openai codec 重建 system 族消息时丢 wire 元数据」一个失败域,一并修掉。rebuildSystemMessage的 harvest-last 标记规则)——re-lay 改为展开原始 parts 的并集(同键后者赢)、只覆写type/text;injectOpenaiSystem对 parts-array 头保持形状不变,原 parts 逐字节保留,注入文本作为新的末尾 text part 追加。字符串路径一行未动。base\n\n---\n\nextra)不变、string re-lay 输出不变、verbatim sidecar 逐字重发不变、user-run 规范形状(Unified Prefix Cache Fix: Transactional Folding Boundaries + Single Exit Arbiter (Global Tracking) | 前缀缓存统一修复:折叠边界事务化 + 出口单一判官(总跟踪) #3938/[Kernel Initiative] Transactional folding boundaries + wire byte fidelity (unified prefix cache fix #3938, kernel side) | [kernel 专项] 折叠边界事务化 + wire 字节保真(前缀缓存统一修复 #3938 内核侧) #3939⑥ pin)未触碰、prepend/no-op 不变。有意的行为变更(仅 parts-array 形状):re-lay 从裸单 part → 带原额外键的单 part(N 个 part 仍合为 1 个,与之前相同);inject 从「塌缩成字符串」→「保持数组 + 追加末尾 part」。退化角落:content 为null的被改写 mid-system 现在出纯字符串而非单 part 数组(实际不可达,两种形式跨请求都稳定)。验证(定向本地,全量交 CI):kernel wire 套件 issue4201+issue4166(openai)+openai-system-hoist 共 22 过;bili 侧接缝套件 proxy-basic/basic/openai-plugin-postfold-seam/system-to-user 共 58 过;typecheck + build 干净。新回归文件
kernel/tests/issue4201-openai-preserve-part-extras.test.ts(10 条,按 #3617 双向钉:该保留时保留 + 不该动时没动)。判定:可进人工审核(kernel 变更按边界规则始终 human-only review);PR Closes #4201。
fix(ci): sync lockfile versions with kernel 0.0.152 bump (#4201)
ranxianglei commentedon Oct 24, 2026
(ai: zhipuai-lb/glm-5.3)
孤儿 issue 清理:修复已由已合并 PR #4190 落地(含今日五列合并列车),但本 issue 未随之关闭。现补关;若该修复仍有残留问题请 reopen 并描述复现。