You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
收到,先说结论方向:截图里这句 upstream stream ended before a completion event; this turn may be incomplete 是 billion-context 自己发出的信号(#721 的带内截断提示),意思是:代理看到上游模型的流在没有收到结束事件(stop_reason / message_stop)之前就断了。pi 只是把这个错误显示出来,关掉 bili 后请求不经过代理,自然就没有这条提示——但这也说明断流很可能发生在「bili → 上游」这一段,需要日志确认到底是谁切的。
为了定位,麻烦提供以下信息:
使用方式:是 bili pi 启动器、bili plugin install pi 装的 native 插件、还是 /bili/ 前缀直连?
Follow-up with a fully-instrumented local repro of the same error family — root cause found on my instance, and it generalizes.
Chain: client → bili (compress/rewrite) → local routing proxy → vendor SSE endpoint. The vendor answers SSE headers quickly, then goes silent during a long prefill; a 180s no-data read timeout on the routing proxy (Python urlopen(request, timeout=180) — the timeout applies per socket read) kills the connection. bili sees a clean EOF with zero data frames and reports upstream stream ended before a completion event (#721, intentional — it refuses to silently fabricate a turn end). The bili-side audit over v0.1.176..185 found no regression: all upstream-path timeouts are 12min (fetch-util.ts, upstream-proxy.ts), no 180s timer exists anywhere in src.
Why "turning bili off makes it go away": with a direct connection the client SDK transparently retries connection-level failures that happen before any data is received (OpenAI/Anthropic SDKs retry these by default), so the same upstream stall heals silently. bili's #721 policy deliberately turned that into a visible error. That asymmetry — not a bili bug — is what you're seeing.
Fix landed: PR #2173 makes bili retry exactly once when the upstream died with zero visible output (no partial turn was streamed, so the retry cannot duplicate anything). Combined with the fact that the first (timed-out) attempt has usually completed the prefill server-side, the retry hits a warm prefix cache and returns in ~1s — the failure becomes invisible.
Evidence details and the instrumentation used are in #2171. If you can grab bili --version plus the log lines around the error (grep -n "truncated\|stream silent" <log>), we can confirm whether your relay cuts at the same signature (headers OK → long silence → EOF) — every case we instrumented locally matched it.
Activity
ranxianglei commentedon Oct 5, 2026
收到,先说结论方向:截图里这句
upstream stream ended before a completion event; this turn may be incomplete是 billion-context 自己发出的信号(#721 的带内截断提示),意思是:代理看到上游模型的流在没有收到结束事件(stop_reason / message_stop)之前就断了。pi 只是把这个错误显示出来,关掉 bili 后请求不经过代理,自然就没有这条提示——但这也说明断流很可能发生在「bili → 上游」这一段,需要日志确认到底是谁切的。为了定位,麻烦提供以下信息:
bili pi启动器、bili plugin install pi装的 native 插件、还是/bili/前缀直连?bili --versionsed -n 'X,Yp' ~/.local/state/billion-context/bili.log)。其中第 5 条能直接区分两种情况:流被干净地 EOF(上游主动断开,多为 relay/网关侧问题)还是读取时连接失败(传输层重置,多为网络/代理超时问题),两者的修法完全不同。拿到日志我就能继续往下查。
ranxianglei commentedon Oct 5, 2026
补充一条自查(不用等回复,现在就能做):
先确认 pi 里实际跑的是哪个版本的 bili。pi 的 native 插件是用自己目录里的代码起代理的,可能和全局
bili --version不一致:这一行是每次代理启动时打印的版本。如果版本低于 v0.1.173,先升级再观察——这个错误家族有两个已知历史 bug 都已修复:
升级方式(pi 托管的副本走 pi 自己的通道):
pi update --extension npm:billion-context # 然后完全退出并重启 pi(旧进程加载的还是旧代码)如果日志里有
[update] pi npm copy refresh ... failed或leaving the pi copy alone字样,说明自动刷新没跑成,把这几行也贴出来。如果版本已经是最新(≥ v0.1.173)还频繁出现,那就不是这两个历史 bug,需要靠上一条消息里的日志片段来区分是「relay 侧主动断流」还是「传输层重置」,麻烦把 grep 结果发我。
ranxianglei commentedon Oct 5, 2026
本地复现,个人认为大概率是bili导致的而不是上游
ranxianglei commentedon Oct 5, 2026
收到,本地能复现就快了。麻烦同步几个复现细节,我好对着代码定位:
bili pi/ native 插件 //bili/前缀)?上游用的什么(真实 relay + 模型名,还是本地 fake/mock)?大概多长的生成、静默多久后断?grep -nE "upstream stream truncated|upstream stream read failed|watchdog|degenerate" ~/.local/state/billion-context/bili.log | tail,命中行前后各 20 行。重点看是走[acp-proxy: upstream stream truncated ...](干净 EOF)还是[plugin] upstream stream read failed ...(读取异常,异常信息会直接说明是 RST/EOF/abort)。grep "acp-proxy v" ~/.local/state/billion-context/bili.log | tail -3),master HEAD 还是发布的 tag?我这边已经排查过:默认超时(上游 idle 12min 每 chunk 重置、请求看门狗 24min)默认值下不会频繁触发;历史同类 bug #551/#1647 在 v0.1.88/v0.1.173 已修。接下来重点查 pi 走的
/bili/<url>前缀转发路径与普通路径的传输差异——这条链路只有 native pi 用,如果那里有独立计时器或池化差异就能解释「只有 pi 报」。ranxianglei commentedon Oct 5, 2026
收到。我先按「审核先于实现」把自己这边能做的排除法做完了,报告一下结果:
已验证(当前 master / v0.1.184,真实 pi 0.83.6 + native 插件通道 + 可控的模拟上游),以下场景全部通过、无提前终止:
: ping注释帧(llama.cpp/部分 relay 风格)同时静态排除了默认配置下的定时器:上游 idle 超时 12min(每 chunk 重置)、请求看门狗 24min、fake-completion 缓冲默认关闭。结论:在默认配置下,「静默时长 / 总时长 / 连接复用」这几类常见触发条件在 master 上都不会产生这个错误。 所以你的本地复现一定带了我还没覆盖到的条件。
要精确对齐,请给我复现配方:
bili pi启动器 / native 插件 //bili/前缀?upstream stream truncated (xxx) — emitting in-band error= 上游主动发了 EOF(relay/网关侧断了);upstream stream read failed (xxx): <错误>= 传输层失败,后面的错误文本(socket hang up / other side closed / aborted...)直接说明是谁切的线。ranxianglei commentedon Oct 5, 2026
进展:我在 master(v0.1.184)上完整复现了截图里这条错误——用真实 pi + native 插件 + 模拟上游,让上游在流中段直接断开(不发 finish_reason / [DONE] / message_stop),pi 端收到的就是截图原句
upstream stream ended before a completion event; this turn may be incomplete,bili.log 对应行是[acp-proxy: upstream stream truncated (openai) — emitting in-band error]。这确认了两件事:
所以还是需要你那边的两个关键证据来定案:
upstream stream truncated ... — emitting in-band error:上游主动 EOF,拿 grep 命中的时间戳对照 relay 侧日志(同一时刻的断连记录)即可定位是谁切的;upstream stream read failed ... : <错误>:把<错误>原文发我(socket hang up / other side closed / aborted 各指向不同凶手)。外加:通道方式、relay 类型 + 模型名、是否每轮必现。有这些我就能对着复现。
ranxianglei commentedon Oct 5, 2026
上游一定是好的 因为关闭billion-context就没有这个错了 虽然表面原因是上游 但是需要注意 一个巴掌拍不响 需要看最近几个版本改了哪些和上游相关的内容,可能导致不转发上游内容进而导致bug
ranxianglei commentedon Oct 5, 2026
按你说的方向查了「最近版本与上游相关的改动」,结论先摆出来:转发循环本身没被近期版本改坏,证据如下——
代码清点(v0.1.150 → v0.1.185,约 3 周)
sse-util.ts零改动;实证矩阵(真实 pi 0.83.6 + native 插件 + 可控模拟上游,master 上跑):快流 / 中段静默 60s / prefill 静默 60s /
: ping注释帧 / 连续慢流 3 分钟 / anthropic wire / openai wire —— 全部字节完整转发,终止事件无一丢失。唯一能触发截图这条错的场景是:上游在终止事件前把连接断了(S10 复现,逐字一致)。所以逻辑上只剩两种可能,都符合「关掉 bili 就好」:
决定性实验:把失败那轮 bili 实际发出的请求体原样抓下来(bili 有 snapshot;或在 bili↔relay 之间挂 mitmproxy),用 curl
--no-buffer直放 relay——直放也断 = 请求形状触发了 relay 侧处置;直放正常 = 差异在连接层(keep-alive 池化 / TLS 指纹),再往传输层挖。[plugin] degenerate terminal turn ... retrying once就是它。麻烦补三个信息就能收敛:① grep 命中的是
emitting in-band error(干净 EOF)还是read failed ... : <错误>(读取失败,错误原文很关键);② 「老是」是从哪个版本更新后开始的(可以精确二分);③ 单轮还是多轮会话出现(工具是第 2 轮才进请求体的)。ranxianglei commentedon Oct 5, 2026
「从 v0.1.180 开始」这个锚点很有用,我把 v0.1.179→v0.1.180 全窗口(44 个提交)逐文件过完了,先说结论:这一版没有任何能截断/丢失上游流内容的改动。该窗口内全部变更归类:
pi update --extension npm:billion-contextplugin 管道的读流/解析/转发/终止判定循环在这个窗口内一行未动。所以「v0.1.180 引入了断流」在代码层面不成立——要么版本归因有偏差(更新前实际不是 0.1.179?),要么同时间变的不是 bili。
注意一个容易混淆的点:如果你当时跑的是
pi update --all或pi update,pi 本体也一起升级了,而 #1868 让 pi 扩展副本开始跟随全局版本——三个变量(bili 版本、pi 版本、relay 侧)可能同时动了。给你一个 5 分钟的干净 A/B(利用 pi 对钉版 spec 的原生支持):
另外两条信息仍然卡着诊断(日志里一眼就能看到):
grep -nE "upstream stream truncated|upstream stream read failed" ~/.local/state/billion-context/bili.log | tail -5—— 命中的是emitting in-band error(上游干净关流)还是read failed ... : <错误原文>(读取失败,原文直接指向元凶);pi --version多少。ranxianglei commentedon Oct 5, 2026
这两行日志信息量很大,先给判定:两条都是 relay 侧主动关连接,bili 只是如实上报——错误文本本身就把 bili 排除在「断流者」之外了。
逐条拆解:
read failed (openai): other side closed—— 这是 undici 的SocketError,源码里只有一个产生点(client-h1.jsonHttpSocketEnd):TCP 收到对端 FIN、但 HTTP body 还没按协议收尾(chunked 没发 0 终结块)→ 判定「对方把还开着的响应体直接掐了」。是远端硬断。upstream stream truncated — emitting in-band error—— 另一种形态:relay 把 SSE body 按协议正常收尾了(chunked 终结块发了),但从头到尾没发过finish_reason/[DONE]。这是应用层主动提前结束生成(但把响应包得干干净净)。对照排除 bili:bili 自己的所有杀流路径产生的错误文本都不同——idle 超时是
This operation was aborted(AbortError),watchdog/客户端断开走 abort+destroy 分支且日志另有watchdog/client aborted mid-stream字样。你的日志里是other side closed+ 干净 EOF 两种远端行为,bili 侧没有任何自杀痕迹。#721 这条信号的存在意义就是把这个事实显式化——直连 pi 遇到同样的断流只会拿到一个裸 EOF,症状更隐蔽。所以「一个巴掌拍不响」的答案是:bili 的角色是让失败可见;断流的巴掌在 relay 侧。剩下唯一的问题是:relay 为什么只对这些请求断流。三个候选机制,各有判别实验:
要的数据就一样东西:挑 2~3 次失败,各贴 ±30 行日志(带上每次失败之前那条请求日志行,有时间戳和 URL),我直接算间隔分布——聚在常数就是 A,结案;散布就是 B/C,再跑直放实验。另外一句:走的哪个 relay 服务、什么模型?有些服务文档里就写着单流时长上限。
ranxianglei commentedon Oct 5, 2026
x-routify-success: false这条头把问题性质定死了:这是 relay 自己打的失败标记——它知道这次路由/上游调用没成功,然后把失败以「流中途关闭」的形式透传了出来。再叠加「单轮、短 prompt、100% 复现」,之前候选里的时长上限、长输出风控、生成动力学那一类全部出局——这是一个确定性的、请求级的拒绝:relay 对「经 bili 发出的这个请求」本身处置失败。机制层面已经收敛,剩下的只是找出请求里到底是哪个元素触发的:嫌疑元素就两个(连接/TLS 层排除——直连和经 bili 走的是同一个 Node/undici 栈):
x-bili-*请求头(x-bili-plugin、x-bili-plugin-conversation 等,bili 原样透传客户端打上的标记头)——relay 若按头做路由/风控就会中招。bili 自带抓包开关,不用 mitmproxy,一条命令两边都拿到:
把这两个文件贴上来(或私发我)。拿到后我做最小化二分,你本地用 curl 就能验证,每步 30 秒:
x-routify-success: false(证明单靠 bili 的出站字节即可触发,与连接无关);x-bili-*头 → 翻成 true = 头是触发器,结案;另外两个顺带确认:① 直连(关 bili)时响应头里
x-routify-success是不是 true?② routify 是你们自己的服务还是第三方?如果是自己的,拿失败时间点查一下它侧的日志,success:false的内部原因(上游 4xx?路由无后端?)应该直接写在里面——那会跳过所有二分一步到位。ranxianglei commentedon Oct 5, 2026
dsh 也中招这个信息很关键——它把嫌疑范围进一步收窄了:pi 和 dsh 是两条完全独立的宿主扩展,但它们在「经 bili」时共享同一套出站改造,共同点只有三样:
x-bili-*标记头(x-bili-plugin、x-bili-plugin-conversation、x-bili-plugin-model 等);所以如果 dsh 也是全新会话单轮短 prompt 就 100% 复现,嫌疑就只剩 ①②——触发器在 bili 的公共插件层,不在任何单一宿主扩展里。请确认一下 dsh 是不是也是「新开会话第一条消息就挂」。
下一步还是那个抓包(pi、dsh 各来一份最好),拿到后我直接做最小化二分给你出精确的 curl 验证序列:
把 REQ.txt 内容贴上来即可。我本地已经搭好对照环境,可以立刻算出「直连请求 vs 经 bili 请求」在第 1 轮的完整字节级差异清单,然后按嫌疑权重逐个给你 30 秒可跑的 curl 开关实验(先删 x-bili-* 头、再删 ACP 工具数组、最后回退工具数量),哪一步让
x-routify-success翻成 true,触发器就是它。ranxianglei commentedon Oct 5, 2026
你在哪里看到的dsh中招?有个猜想 是不是和acp标签被强制剥离有关 是模型输出的标签被剥离 ? 最近有一个这样的issue合并
ranxianglei commentedon Oct 5, 2026
Follow-up with a fully-instrumented local repro of the same error family — root cause found on my instance, and it generalizes.
Chain: client → bili (compress/rewrite) → local routing proxy → vendor SSE endpoint. The vendor answers SSE headers quickly, then goes silent during a long prefill; a 180s no-data read timeout on the routing proxy (Python
urlopen(request, timeout=180)— the timeout applies per socket read) kills the connection. bili sees a clean EOF with zero data frames and reportsupstream stream ended before a completion event(#721, intentional — it refuses to silently fabricate a turn end). The bili-side audit over v0.1.176..185 found no regression: all upstream-path timeouts are 12min (fetch-util.ts,upstream-proxy.ts), no 180s timer exists anywhere in src.Why "turning bili off makes it go away": with a direct connection the client SDK transparently retries connection-level failures that happen before any data is received (OpenAI/Anthropic SDKs retry these by default), so the same upstream stall heals silently. bili's #721 policy deliberately turned that into a visible error. That asymmetry — not a bili bug — is what you're seeing.
Fix landed: PR #2173 makes bili retry exactly once when the upstream died with zero visible output (no partial turn was streamed, so the retry cannot duplicate anything). Combined with the fact that the first (timed-out) attempt has usually completed the prefill server-side, the retry hits a warm prefix cache and returns in ~1s — the failure becomes invisible.
Evidence details and the instrumentation used are in #2171. If you can grab
bili --versionplus the log lines around the error (grep -n "truncated\|stream silent" <log>), we can confirm whether your relay cuts at the same signature (headers OK → long silence → EOF) — every case we instrumented locally matched it.ranxianglei commentedon Oct 5, 2026
先正面回答你上一条的两个问题,再收口。
① dsh 的信息来源:我依据的是当时平台转发到我的一条、标注为本 issue 的「这个dsh也有问题」评论——但现在线程里(floors 1–20)没有这一条。如果它其实发在别的 issue 或被删了,我那条 dsh 收窄(floor 18)作废,抱歉造成误导;不过按新根因看它也不影响结论:同一 relay 链路上跑的任何 lane(pi/dsh/其他)都会踩同一个 ~180s 掐断,「多 lane 同时中招」恰好与网关侧根因自洽。
② ACP 标签剥离猜想:证据直接排除。#2171 的仪表化签名是零数据帧——网关回完
200 + text/event-stream头后一个 SSE data frame 都没发,~180s 后掐断。没有任何模型输出产生,输出侧的标签剥离过滤器根本没有输入可处理,这条路径在零帧场景下不会执行一行。bili 侧也没有任何 180s 定时器(我的独立审计一致:idle 12min/chunk、watchdog 24min;近期合并的剥离加固 #1881/#1882/#1897 都作用于文本通道,与本签名无关)。本线程所有证据与新根因完全咬合:
x-routify-success: false= 路由代理给自己失败的上游调用打的标记 ✓给 @cherish-ltt 的确认与止血步骤:
grep -n "truncated\|stream silent" ~/.local/state/billion-context/bili.log,看每次失败从请求发出到 truncated 行的间隔是否聚在 ~180s(stream silent行会显示静默时长);npm install -g billion-context@0.0.2221-pr.2173.a503ba8(或等 fix(#2171): re-issue plugin streams once on zero-visible upstream cuts #2173 合并后的正式发布)——零可见输出的断流会自动重发一次,暖缓存下 ~1s 恢复,用户无感;收工判定:诊断阶段结束——根因在 relay 网关 no-first-byte 超时,bili 行为符合设计(#721 如实上报),修复已在 #2173(review 完成、CI 全绿、mergeable,合并由人执行)。@cherish-ltt 确认签名匹配后本 issue 可关。
ranxianglei commentedon Oct 6, 2026
@cherish-ltt 麻烦是否可以补充下使用的模型?我本地最终定位为上游glm5.3并发限制
ranxianglei commentedon Oct 6, 2026
等 @cherish-ltt 回复期间补两点,把「并发限制」和之前的签名串起来:
@cherish-ltt 补充模型信息时,麻烦顺带说下报错形态是阵发性(一阵一阵)还是持续性(连续必现):阵发性更符合并发上限签名,装 PR 构建(
npm install -g billion-context@0.0.2221-pr.2173.a503ba8)后基本无感;持续性则要先解决配额。