Repository navigation
[PR] Fix: text stream swallowed when gateway sends empty array tool_calls:[], client receives empty stream (#4466) | 修复:网关发空数组 tool_calls:[] 时文本流被吞、客户端收到空流(#4466) - #4470
Conversation
Some OpenAI-compatible gateways (Tencent CodeBuddy, copilot.tencent.com)
stamp "tool_calls": [] on every chunk of a normal text response. The
bare truthiness check classified each text frame as a tool-call frame,
withholding its client-visible bytes for a tool settle that never comes
— the client received an empty stream ("Model returned no valid
response"). An empty array is now treated as absent (same predicate as
filterRealToolFragments); non-empty tool_calls behavior is unchanged.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5374-pr.4470.2362e7eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4470.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:重复——三重撞车。 这个修复已经有三个 open PR 在跑同一个机制:
三者症状相同(网关每块带 标签: bug / scope/wiring / p1 / duplicate —— wire 帧误分类导致受影响网关经代理完全拿不到正文(可用性停摆,p1);与 #3954/#3926、#4469 同症状同机制,打 duplicate 待 owner 收拢。客户端标签不打:CodeBuddy 是上游网关不是 agent 客户端,且修复覆盖所有 OpenAI 兼容车道。 本地独立验证进行中(根因代码路径复核 + 定向测试 + 负控制),完整八问 review 结论随后补一条。 |
(ai: vllm-qwen/qwen3.8-27b) PR #4470 独立复审完成(重读 diff、重走代码路径、本地定向验证 + 负控制复做,未照抄 issue/上游分析)。 先说方向关(① 审原 issue):#4466 的诊断在 master 代码上独立复核成立—— 八问:
行为变更披露(旧→新): 测试有效性(④):真入口 diff 整洁度(⑤/⑤b):2 文件 +135/-1——一行谓词 + 讲「为什么」的注释(带 issue 引用)+ 自包含测试文件。无无关改动、无死代码、命名与注释风格合仓库惯例。过。 验证证据:
处置建议(重复链,细节见首条回复):#3954(10-20,最早)/ #4469(今晨 01:43)/ #4470(本 PR)是同一机制的三个 PR,修法语义等价。按先来后到建议保留最早的 #3954(rebase 到当前 master 刷一轮 CI 即可,其 head CI 曾全绿但 base 已陈旧);#4469/#4470 打 duplicate 关闭。备选:本 PR base 最新、测试最完整,可把它这个测试文件 cherry-pick 进 #3954 分支后一并收掉。关不关由你定,我不自行关闭。 判定:修复内容本身可合(单行谓词收敛 + 双向回归钉 + CI 全绿);但作为三重重复之一,建议按上面方案收敛为一个 PR 后再合,不要在三个里任选一个单独合入。 |
|
Backported to |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.783-master.b11dd2a # this exact build
npm install -g billion-context@master # always the newest merged build
|
… the train (ranxianglei#4474) A conflicted backport leaves only a PR comment; CI green on the train head says nothing about fixes that are ABSENT. Before opening the ship PR, reconcile every backport-labeled merge since the train's base tag (merge-commit ranges + squash-shape subjects) against the cherry-pick -x trailers on the train; any no-show renders as a prominent warning section at the top of the ship PR body. Never fails the run — the owner may ship without the straggler, but must see it first. Verified end-to-end against the live repo: stale train (missing the ranxianglei#4470 pick) -> flags {ranxianglei#4473, ranxianglei#4470}; real train (pick present) -> flags {ranxianglei#4473} only, both directions.
Fixes #4466
现象(人话)
腾讯 CodeBuddy 网关(
copilot.tencent.com)在每个普通文本块里都带一个空数组"tool_calls": []。代理把它当真值 → 文本块全被归类成「工具调用帧」→ 客户端可见字节被扣住等工具结算(永远不会来)→ 客户端收到空流(「Model returned no valid response」)。不走代理一切正常。根因
src/loop/adapter-openai.ts:528裸真值判断:[]在 JS 里是真值。同文件filterRealToolFragments早已用!tcs || tcs.length === 0 → keep—— 两处判定不一致。修复
空数组当缺失(与
filterRealToolFragments同一谓词):非空
tool_calls行为完全不变(真工具流照旧吸收/重放)。测试(both-direction #3617)
tests/issue4466-empty-tool-calls.test.ts:tool_calls:[]的文本块 → 文本事件 + 客户端可见字节都带 HELLO(修复前此测试红,已做负控制验证);相邻面 758/758(toolargs-adversarial / absorb-emission / issue1881 / issue1502 / host-usage-postfold / issue1455)+ typecheck 干净。完整 CI 以 push 后的 test lanes 为准。
config surface
无。
影响面
所有 OpenAI 兼容车道(/bili/ 重写 + cert-MITM);报告者实测 0.1.203/0.1.204/0.1.205/master 全带此代码路径,非 203/204 回归,是一直存在的接线 bug。