Repository navigation
[PR] fix(#1706): recognize unterminated final [DONE] at EOF; add truncation forensics logs - #1709
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1665-pr.1709.67e2678This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1709.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR review — verified against branch ① Issue direction — correct. Two separate problems, both handled at their decision point:
② Regression inventory (existing behaviors on touched paths):
③ Code — clean. Normalization ( ④ Tests — real, with teeth. 8 behavioral tests drive the actual ⑤ Diff — clean. 2 files, every line on-purpose. Behavior changes (explicit, per policy):
Local verification at CI red explained — not caused by this PR: all four core test-matrix jobs fail on Verdict: code is merge-ready (wire-shape change ⇒ human merge per §7.4); only a fresh green CI run on the current head is outstanding. No changes made to the branch — review only. 中文摘要:审核了 PR #1709(识别 EOF 处未终止的最后一个 |
922abc3 to
0fc0aa8
Compare
…he truncation path
[bot] 🏷 Follow-up (continuing the review above): While verifying, the branch was rebased onto latest master ( I also picked up one of the two minor gaps flagged in my review and fixed it directly on the branch (small-problem rule):
Verified locally at Status: waiting on the fresh CI run triggered by this push; once green, the PR is ready for human merge (wire-shape change ⇒ §7.4 human-only). No other changes made. 中文摘要:PR 已被 rebase 到最新 master(含 #1710 的 rmsync 测试修复),我在分支上补了一个小测试提交 de91d23(钉住「哨兵被截断在 token 中间」仍走截断路径的边界),rebase 后本地全量验证通过(typecheck/3290 项测试/build 全绿);等这次推送触发的新 CI 变绿即可由人工合并。 |
|
(ai: zhipuai-lb/glm-5.3) 孤儿票清理:标题指向的 issue 已关闭,修复已由其他路径落地。关单;误判请 reopen。 |
Ref: #1706 (no auto-close — the reported incident is likely a genuine mid-thought disconnect; this PR fixes one verified bili-side false-positive window and makes every future occurrence self-diagnosable. Closing once the cutting hop is confirmed from the owner's log line.)
What changed
Two changes, both in
src/plugin.ts, both on the #721 truncation path:1. Recognize an unterminated final
data: [DONE]at EOF (false-positive fix). The SSE parser only recognizes[DONE]inside complete blank-line-delimited events. A gateway that closes right after the finaldata: [DONE]line — no terminating blank line — left the sentinel dangling in the buffer at EOF; if the stream had also omittedfinish_reason, bili reported a semantically completed turn as truncated. At EOF the single-data-line[DONE]payload is now recognized with the same normalization as the in-stream form (data:[DONE], extra spaces), the sentinel is forwarded with its terminator restored, and no error is emitted. Recognition is deliberately strict: exactly one data line whose normalized payload is[DONE]. Multi-line dangling blocks, other protocols, and the read-failure (catch) path are untouched and stay conservative.2. Truncation forensics logging. Both emission sites in both lanes (chat + responses) now include
<bytes>B in <elapsed>ms, last byte <silence>ms ago. The silence duration names the cutting hop's idle budget: ~300s/600s ⇒ a middlebox/proxy, ~720s ⇒ bili's own 12-minute upstream watchdog (BILI_UPSTREAM_TIMEOUT_MS), 0B ⇒ the connection produced nothing. Log-only; wire output unchanged by this part.Behavior changes (old → new)
data: [DONE]+ nofinish_reasonanywhere — old: in-band truncation error frame ("this turn may be incomplete"); new: treated as complete, sentinel forwarded terminated, no error. Rationale:[DONE]is an unambiguous completion marker; a missing terminator is framing detail, not semantics. Everything else (genuine cuts, multi-line dangling blocks, catch path) behaves exactly as before — pinned by control tests.Why (issue context)
#1706 reports the error during opencode's thinking phase, frequently but not deterministically. Thinking = long wire silence ⇒ classic idle-timeout disconnect signature; the intermittent pattern matches "only when silence exceeds some hop's idle budget". While investigating, two bili-side gaps were verified locally:
Evidence
Probe matrix against
pipePluginChatWithStrip(openai lane), before → after:[DONE][DONE]data: [DONE]\ndata: [DONE]data:[DONE](no space)New regression suite
tests/issue1706-dangling-done.test.ts: 8 tests pinning the whole matrix plus both forensics log shapes (EOF path and read-failure path).Preflight
npm run typecheck— cleannpm test— 3240 pass / 0 fail / 12 skip (full suite, rebased head = current master 8d3d1bf)npm run build— success