Repository navigation
[PR] fix: shape the double-degenerate retry terminal by streamErrorShape (#5958) - #5965
Conversation
…5958) pipePluginChatWithStrip hard-wired the #870 double-degenerate terminal to the legacy "completion" shape, ignoring ProxyOptions.streamErrorShape — the one stream-error site that did not honour the global policy (default "protocol"). Hosts like DSH therefore received an unfinished turn serialized as a completed turn (openai finish_reason:"stop" / anthropic synthetic completion block) and booked it as stop/completed while the task was still unfinished. Thread opts.streamErrorShape through the pipe (new trailing optional param; omitted -> protocol-native) and emit with it from both forwardCaptured call sites. streamErrorShape:"completion" restores the #870/#2689 legacy shape for hosts that need the error text inside a well-formed turn. Behavior change (default): the double-degenerate terminal in the plugin chat lane now defaults to the protocol-native error frame, matching every other stream-error path. Set compat.streamErrorShape="completion" to restore the old shape. Regression tests assert an exhausted retry is NOT serialized as a successful completion (no finish_reason:"stop"), plus both-direction gate rows pinning the explicit "completion" opt-in for openai and anthropic.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8667-pr.5965.739824eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5965.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — 检索 open PR 后确认只有一个 PR 针对 #5958(本 PR #5965),无并列修复;#4913/#5897 是相邻但机制不同的面(失败语义 vs 重试默认值/nudge 措辞),PR 已交叉引用、未并入,符合粒度政策。 Independent review conclusion — mergeable once CI goes fully greenI re-derived the review from the diff rather than from the issue-side report. Verified live against head ① Direction (original issue). Version-first triage passes: at tag ② Regression inventory. Touched behavior: only the double-degenerate terminal frame shape. Checked every existing-behavior facet:
③ Code. Minimal (+63/−12, 4 files), trailing optional param keeps source compatibility, comments explain why with issue anchors (repo style), no dead code/magic values/new deps/new config surface. Clean single commit, branch name compliant, GitHub numbers only in artifacts. ④ Test validity. The regression has teeth: it asserts Residual risk, independently assessed: since #1455, every OTHER stream-error path on the anthropic wire already delivers CI (live, mirror cache): 30 checks — 0 failed, 7 pending (remaining 结构化八问(中文)
收工判定:审核通过,CI 全绿后可由 owner 合并(wire 消息形状变更 → 按仓库规则仅人工合并,不自动合并)。CI 收尾后我会在本帖补一行最终确认。 |
(ai: vllm-qwen/qwen3.8-27b) CI final confirmation (live-verified): all checks settled on head One nuance: the branch now reads Verdict stands: review passed, CI green — ready for your merge whenever. Wire-message-shape change → human-only merge per repo rules; |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1111-master.c7c808d # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #5958
What & why
pipePluginChatWithStriphard-wired the #870 double-degenerate terminal — the turn that degenerates AGAIN after the continuation nudge — to the legacy"completion"stream-error shape, ignoringProxyOptions.streamErrorShape. It was the one stream-error site in the codebase that did not honour the global policy (default"protocol"; every other site resolves via?? 'protocol').Consequence (reported on 0.1.213, DSH native lane, local Qwen over OpenAI chat completions): after a browser tool call succeeds the model returns a render-tag echo with no usable answer; bili retries once with the continuation nudge; the retry degenerates too. The proxy logs "the turn degenerated again after the continuation nudge" but serializes that terminal as a completed turn — OpenAI
finish_reason:"stop"/ Anthropic synthetic completion block carrying the error text. DSH therefore booksstopReason:"stop"+turn/end reason "completed"even though the task is still unfinished.Fix
Thread
opts.streamErrorShapethrough the pipe (new trailing optional param onpipePluginChatWithStrip; omitted → protocol-native viaemitStreamError's own default) and emit with it from bothforwardCapturedcall sites. This re-couples the lone exception to the standard policy every other stream-error path already uses, instead of hard-coding a second shape:protocol) — the exhausted retry now surfaces as the wire-native error frame (OpenAI top-level{error:{code:"stream_error"}}, Anthropicevent:error), so hosts record a real failure.compat.streamErrorShape:"completion") — restores the Plugin passthrough leaves the client an empty turn when the model echoes a render tag #870/[bug] #870 in-band error 在 anthropic 协议下缺 content_block_delta.index —— 严格校验客户端整轮 Type validation failed #2689 legacy completed-turn shape for hosts that need the error text inside a well-formed turn (e.g. ZCode anthropic schema compat; pinned verbatim by the preserved test).No new config surface: reuses the existing
compat.streamErrorShapeknob.The double-degenerate (#870) terminal in the plugin chat lane changes its default shape from the legacy success-shaped completed-turn frame to the protocol-native error frame, matching every other stream-error path. Affects all plugin-lane chat hosts that leave
streamErrorShapeunset. Hosts that depend on the old shape setcompat.streamErrorShape:"completion".Residual risk: I could not verify from here how an anthropic host (ZCode) handles
event:errorversus the old synthetic completion block; the escape hatch covers it if it does not.Tests
"code":"stream_error"present, nofinish_reason:"stop", no legacy[ACP] stream errorprefix."completion"keeps the legacy shape (openai); default anthropic emitsevent:errorwith no synthetic block. The [bug] #870 in-band error 在 anthropic 协议下缺 content_block_delta.index —— 严格校验客户端整轮 Type validation failed #2689 anthropic well-formedness test is preserved verbatim under explicit"completion".issue2303-draft-tailretry-degenerates row updated to the protocol-native shape.Related facets (separate scope, cross-referenced, not merged): #4913 (the degraded-after-retry turn becoming a fatal in-band error), #5897 (empty-turn continuation retry off-by-default + neutral nudge wording).