Repository navigation
[PR] Responses/chat plugin pipes: stop emitting a truncation error after the terminal frame already reached the client - #4062
ranxianglei wants to merge 3 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4916-pr.4062.c6feabeThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4062.tgz
npm install -g packageInstall instructions are refreshed on each push. |
af6a999 to
03e87be
Compare
03e87be to
d3ee4e0
Compare
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 对应 #4059,是修复该机制的唯一在途项。同错误码条目逐条比对:#3576(DSH/Windows 传输频繁中断——真断流,检测本身正确,问题在传输侧)、#2993/#2996(accept-encoding 解码)、#2323/#2329(CRLF 跨 chunk 拆坏)——与本例症状和机制都不同(它们都是「真断流」,本例是「完成后误报失败」),不并入。 标签:bug / dsh / scope/wiring / p2(+既有 pr)。理由:缺陷类;证据车道 dsh Desktop;领域为协议接线(plugin-lane SSE 管道);能用但有明显问题,不到 p1(无数据丢失、无缓存泄露、会话可恢复)。 审核方式(独立于 issue 侧结论重做):全量读 diff,两条 pipe 完整路径逐行走查(write helper / 终局分支 / catch / finally),对照 src/stream-error.ts 确认各 wire 在终局之后原本会发什么字节;本地跑新套件 + 9 个相邻套件(10 文件 97 测试全绿);拉旧 head 的 CI job 日志核实红因。 方向:bug 属实。根因 = catch 路径只知道「解析时见过终局」(sawTerminal),不知道「终局字节是否真的到了客户端」(投递状态),把「生成被截断」与「连接结束」混为一谈。修法是加一个只在 awaited write 成功后置位的投递跟踪标志,在 catch 决策点分叉——修的是产生错误帧的决策本身,不是遮症状。 回归清点(触碰路径的既有行为逐项判定):
代码:标志在 4 处统一于 awaited write 成功后置位;写前 alive 检查与 write() helper 自身门一致(write 对死流是 no-op,故「wrote」==「写前活着」);若 drain 期间 res 死亡导致标志 stale-true,循环会在 destroyed 检查处 break 或 abort 检查先行命中,guard 分支不会误触发。无 as any/@ts-ignore,命名达意,注释带 #NNNN 来源符合仓库惯例。 测试:13 例驱动真实 pipe 入口(合成 SSE + 带 end 计数的 mock ServerResponse),每条 wire 双向断言门控;断言有牙(终局出现次数 == 1、error 帧缺席、openai error 帧精确形状 + [DONE] 先后序、classification 字符串、guard 分支日志行)。发现一处缺口:google wire 一例都没有(行为表声称 google 有变化但 Tests 未覆盖)→ 已直接补上:新增 2 例(finish-reason chunk 后的读错 clean end + finish 前的 cut 保留 UNAVAILABLE 帧),本地 15/15 绿,作为独立提交 8bfebe0 推入 PR 分支。 审核中采取的行动:
行为变更(old → new,有意):
理由:终局一到客户端,turn 从客户端视角已完成;其后追加帧要么是重复终局(生命周期违规),要么是虚假失败报告(客户端徒劳重试或停摆)——即 #4059 的两个症状。无新配置面、无 kernel/ 改动、不新增任何帧。 结构化八问:
CI 状态:最终 head 8bfebe0(rebase + google 补充)上目前 32 项绿、7 项进行中(test 分片)、0 红;旧 head 的红均为存量 #3769 存储 flake(master 已随 #4077 修复)。 判定:方向正确、修复打到根因、回归面封闭、测试有牙(含我补的 google 两例)。可合入——待进行中的 CI 项转绿即可。合并留给你:#4062 |
(ai: vllm-qwen/qwen3.8-27b) CI 已跑完 — 最终 head 8bfebe0 的状态:33 项绿、5 个 test lane 红。 逐条拉了 5 个红 lane 的 job 日志核实,全部是存量/环境问题,没有一项由本 PR 引起:
为何断定不是本 PR:diff 只碰 本 PR 相关套件全绿:新增 15 例 + truncation/zero-byte/empty-turn/draft-tail/CRLF/usage/backpressure 各套件在各自分片里都过。 判定不变:可合入。 这 5 个红是环境性 CI 噪音,对任何 PR 一视同仁——现在合入没问题,或等 |
…y-forwarded terminal (#4059)
… (CI triage #4062) Found while triaging the #4062 CI red: the async test body kept executing after t.skip() because the gate line had no return. On every solverless CI shard it then threw deeper (no-solver error on Linux, doubled-drive-letter ENOENT on Windows), producing a 'not ok ... # SKIP' TAP line that is NOT counted in the failure total but reads like a failure and misled this triage. The return makes the skip honest per the KDD #14 auto-skip contract; behavior with a solver present is unchanged (branch never taken).
8bfebe0 to
720f338
Compare
(ai: vllm-qwen/qwen3.8-27b) CI 已修到可合状态:原 5 条红 lane 的根因全部是 PR base(56a0f5a)过期——verif 门控/绝对路径缺陷已在 #4084、#3769 Windows EBUSY 已在 #4087 修入 master。我把分支 rebase 到最新 master(5f3b1e6)并推了新 head 720f338,这 5 条 lane 现已全绿;另附一个标注过的顺手小修(verif 测试 skip 门控缺 剩余唯一红:
两轮(run + rerun)其余 5 个 test 分片(ubuntu×4 + win22-s1)及全部 gate/e2e 辅助 lane 全绿。本 lane 按「最多 2 次」到此为止——剩余红的根治需要动无关测试文件的等待预算/重试语义,属测试基建范畴,超出本 PR 范围。 结构化八问
收工判定:PR 本体 CI-clean、可合;建议人工对该 PR 再 rerun 一次 |
Problem
In the plugin lane, when an upstream read failure happens after the turn's terminal frame was already forwarded to the client, the catch path unconditionally emits its truncation signal:
pipePluginResponsesWithStrip): afterresponse.completed, the client still receivesevent: error {code: "upstream_stream_truncated"}— a failure following a completion. The diagnostic blob self-contradicts too (responseStatus: "completed"next toclassification: "no-terminal-seen"). Clients treat the turn as failed → retry or stop.pipePluginChatWithStrip): after[DONE]/message_stop, the same path re-sends a duplicate terminal byte (strict lifecycle validators reject it).Root cause: the catch path conflates "generation cut" with "connection ended". It knows
sawTerminal(set at parse time, also feeding the empty-turn retry) but not whether the terminal byte actually reached the client.Fix
Track
terminalForwardedper pipe — set only after the awaited write of the terminal frame succeeds:response.completed/response.failed/response.incompleteframe, or[DONE];[DONE]; anthropic:message_stop; google: the finish-reason chunk (its terminator).In both catch paths, when the flag is set: run the existing usage/witness cleanup, log one warn line, and end clean without appending any frame. All pre-terminal behavior is unchanged: genuine cuts still emit the in-band error (or their
finished=truesynthesis for openai/anthropic). A terminal consumed by the empty-turn retry (never forwarded) does NOT set the flag, so a cut retry stream still signals as before.response.failed/response.incompletekeep their own terminal state — nothing is re-voiced into a success.Behavior change (old → new)
upstream_stream_truncatederror frameterminal already forwarded[DONE]/message_stop(chat wire)terminal byte already forwarded— truncation signal pathline + built a diagNo new config surface (no env var / file key / CLI flag). No
kernel/changes. Wire shape: no new frames are added — only spurious post-terminal frames are suppressed; every genuine failure path keeps its exact previous frames.Tests
New
tests/issue4059-post-terminal-read-error.test.ts(13 cases driving the real pipes with synthetic SSE), both directions of the gate per wire:[DONE]/message_stopon the chat wires; stream closed exactly once;errorobject + trailing[DONE]) and theno-terminal-seenclassification;Local targeted run: 13 new + 167 tests across 14 adjacent suites (truncation diagnostics, zero-byte retry, empty-turn retry, draft-tail, CRLF cross-chunk, usage settlement, backpressure) all green. Full-suite verdict = CI on this head.
Closes #4059