Repository navigation
[PR] fix: openai adapter treats empty tool_calls array as absent (round-1 text loss) | 空 tool_calls 数组不再误判为工具帧,修复第一轮文本静默丢失 - #3954
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
Gateways that stamp every chunk with `tool_calls: []` (WorkBuddy / DeepSeek-family private deployments) routed all frames into the tool-frame branch: text events lost their raw passthrough, round-1 forwarding in core.ts found nothing to emit, and the settle-time prose rescue early-returned with pending empty — ALL round-1 text was silently dropped while finish_reason/usage looked healthy. Normalize an empty (or non-array) tool_calls field to absent at the single classification point so such frames take the normal text path. Non-empty arrays keep the tool-frame path unchanged. Regression pins (tests/issue3926-empty-tool-calls.test.ts): adapter-level exact-once round-1 text + no fabricated tool calls; gate negative row for non-empty arrays; loop-level client-boundary end-to-end pin. Verified the new tests fail on the unfixed code and pass on this one. Fixes #3926
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4706-pr.3954.8f98468This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3954.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 这是 #3926 的交付 PR 本身(带 ework-agent-pr 标记,已完成的工作);open/closed issue+PR 全量检索(按失败签名「empty tool_calls / round-1 text loss」与文件路径)无其他同机制在途条目——当前 open PR 列表里没有任何其他 PR 触碰 状态(初步核查):
正在本地做定向复核(diff 精读 + 相邻 openai 套件定向跑),结论随后按八问体例补上。 |
This was referenced Oct 20, 2026
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What & why
WorkBuddy-family gateways stamp EVERY streaming chunk with an empty
tool_calls: []array (plus empty sibling fields). In the openai adapter[]is truthy, so every frame was classified as a tool frame: text events lost their raw passthrough, round-1 forwarding in core.ts had nothing to emit, and the settle-time prose rescue (#1881/#1882) early-returned because an empty array absorbs no pending entries. Net effect: ALL first-round text was silently dropped at the client while finish_reason/usage looked healthy (#3926).Fix
Single-point normalization at the classification site (
src/loop/adapter-openai.ts): an empty or non-arraytool_callsfield is treated as absent, so such frames take the normal text path (raw passthrough). Non-empty arrays keep the tool-frame path byte-for-byte unchanged. No core.ts change needed — post-fix, "raw tool chunks buffered but pending empty" cannot occur (a non-empty array always creates pending entries).Behavior change (disclosure)
tool_calls: []: round-1 streamed text now reaches the client (previously silently discarded). This restores the intended pass-through; standard upstreams (field absent/null) are unaffected.tool_callsvalues now fall back to the text path instead of throwing inside the stream parser (strictly more robust).Verification
tests/issue3926-empty-tool-calls.test.ts:Closes #3926