Repository navigation
fix(responses): re-voice surviving system/developer core messages before the codec (#1999) - #2002
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1999
是什么问题
DSH 插件模式(以及任何 Responses wire 客户端)+ 严格单-system 上游(Qwen3 系 chat_template 要求 system 必在 messages[0]):任意一次 compress 折叠之后,内核把每个 active block 的摘要渲染为锚定在历史中段的 role:"system" 核心消息;
coreToResponses把它投影成留在原位的developerinput item → 上游把 developer 映射为 system 喂给 Jinja 模板 → 「System message must be at the beginning」400。折叠状态持久,之后每个请求都 400,会话报废。与 #377/#428(chat wire)同族,但 Responses wire 此前没有任何等价兜底。根因
四条出站投影不对称:
coreToOpenai之后应用systemToUser([Bug] ACP: ≥2 compressed blocks render as multiple system messages → SGLang (vLLM-compatible) upstreams return 400 #377 的既有修法);coreToResponses把 system 映射成原位 developer item,而 bili 的 responses 路径上不存在任何 systemToUser 等价物——这就是缺陷本身。stripKernelSummaries在插件模式下本应摘掉内核摘要锚点,但它只在 object-form compress pair 随 inbound 历史上行时才成立;客户端裁剪工具交换或回显 line-form content 时锚点保留。代理模式下 pair 从不进入客户端历史,锚点则总是存活。因此「一压缩就炸」与具体触发路径无关,是 wire 层缺陷。修复方式
在
src/responses-tool-output.ts的两个投影包装器里、codec 之前应用与 chat wire 完全相同的systemToUser(无 sys/dev 时 no-op 返回原数组),使全部出站构造点(prepare / compact forge / loop rebuild)共享同一 chokepoint。位置保持的 re-voice:中段 system/developer → user;头部 developer 注入(instructions)不动;prefix-cache 锚点字节不变。两种压缩模式同时覆盖(见根因)。行为变更披露(old → new)
developerinput item 形式发出。userinput item 发出。Config surface
不涉及——未新增/改名/重语义任何 config 字段、env var 或 CLI flag。
验证
新增
tests/e2e-responses-mid-developer.test.ts(真实startServer+ 模拟严格后端的 mock upstream,中段 sys/dev 即回 400):HTTP 400 {"code":"invalid_prompt","message":"artifact:chat_template.jinja: System message must be at the beginning (developer at input index 2)"},与报告人引擎报错同类;修复后 GREEN;定向回归全绿:
tests/system-to-user.test.ts、tests/e2e-mid-system.test.ts(chat wire #377 不变量)、tests/codex-compact-e2e.test.ts、tests/e2e-plugin-grow-compress.test.ts;typecheck clean。全量套件交 CI。残留 checklist(属本 issue 机制族,未在此修,待 owner 决定)
inboundCompressPairPresent只匹配 object-form ranges:客户端回显 line-form content strings 时,block refs 永不匹配 → tool result 已携带摘要的同时锚点也上行(双载体)。本修复后双载体无害(user voice、位置合法),但浪费 token;是否把 strip 加固到识别 line-form,留 owner 决策。