Skip to content

[PR] fix: disable the 32 MiB ingest cost band by default for all lanes (#7426) - #7443

Merged
ranxianglei merged 2 commits into
masterfrom
fix/7426-ingest-cap-unlimited
Nov 21, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
fix/7426-ingest-cap-unlimited

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

把 ingest 成本带默认关掉(所有车道,不再限制)

这是什么

把 #5794 的 32 MiB「ingest 成本带」默认对所有车道关闭(DEFAULT_INGEST_BODY_BYTES 从 32 MiB 改成 0)。
也就是:进来的请求体不再因为超过 32 MiB 就在 stage: ingest 被 413 拒收。想重新启用时,
把 BILI_INGEST_BODY_BYTES(或 network.ingestBodyBytes)设成具体字节数即可(0 = 关闭)。

为什么要关

那个 32 MiB 带本意是「可解析的 32 MiB+ 文本体已经 ≈800 万 token、超过一切真实模型窗口,
解析它注定失败还烧事件循环」——这对一次性会话成立,但对重发车道不成立:
opencode / dsh 每轮把整段原始台账重发进来、bili 会折叠它,此时「原始入站字节数」跟真实(折叠后)的
上下文大小没有对应关系。

#7426 就是这个错伤:一个 opencode 会话折叠后上下文很小,但原始重发体 33.5 MB,
于是每轮都被 ingest 带 413(stage: ingest),永远发不出去。

用户拍板:任何车道都放宽,放宽到不限制。所以直接把默认关掉(而不是像 #6933 那样只豁免插件车道)。

关掉之后还有什么兜底

ingest 带是三段闸里最靠后的一段。前两段还在、且远高于任何真实会话,所以「不限制」的实际上限是:

  • receive(收件原始字节)默认 5 GiB
  • decode(解码后字节)默认 10 GiB

这两段是内存 / DoS 的传输层保护,不是 token 窗口保护,正常会话远远够不到。
所以关掉 ingest 带后,#7426 的 33.5 MB 请求完全畅通;只有真正病态的超大体才会被这两段拦。

改动

验证

  • typecheck 通过;tests/issue5794-ingest-cap.test.ts 4 pass / 0 fail;build 通过(dist 标注 / external 均 OK)。
  • 两个 config 门(config-surface-guard、gen-config-docs check-coverage)都绿。

取代

本 PR 取代 #6933(那只豁免插件车道的方案)。ingest 带默认关闭后,#6933 的豁免已无意义,关闭它。

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/7426-ingest-cap-unlimited (6f4f050)

Latest build — install this exact version

npm install -g billion-context@0.0.11171-pr.7443.e0557db

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
6f4f050 billion-context@0.0.11171-pr.7443.e0557db build
d351a4d billion-context@0.0.11169-pr.7443.f84a0f7 build
bfb1de3 billion-context@0.0.11167-pr.7443.7ad4397 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr7443.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: disable the 32 MiB ingest cost band by default for all lanes (#7426) [PR] fix: disable the 32 MiB ingest cost band by default for all lanes (#7426) Nov 21, 2026
)

#5794's ingest band proxied 'beyond every model window' by raw decoded bytes,
which is invalid on the re-send lanes (opencode/dsh re-send the whole raw ledger
every turn and bili folds it) — it 413'd a 33.5 MB opencode turn whose folded
context was tiny. Default -> 0 (unlimited, all lanes); the sibling receive (5 GiB)
/ decode (10 GiB) transport guards still bound pathological bodies.
BILI_INGEST_BODY_BYTES re-enables the band. Supersedes #6933.
@ranxianglei
ranxianglei force-pushed the fix/7426-ingest-cap-unlimited branch from bfb1de3 to d351a4d Compare November 21, 2026 06:48
…ANGELOG entry (#7426)

Drive-by: three code comments still described the 32 MiB band as the active
default (content-encoding.ts, config.ts, handle.ts) — comments that disagree
with the code are defects; reworded to 'disabled by default since #7426, set
a byte value to re-enable'. Added the [Unreleased] Changed entry for the
default flip (32 MiB -> 0, all lanes) per the per-PR CHANGELOG convention.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: opencode/qwen3.8-27b)

查重: 不重复 —— 本线程即 PR #7443 的镜像,修的是 #7426(opencode 车道长会话被 32 MiB ingest 带永久 413);同主题的前置方案 #6933(只豁免 dsh 车道)已关闭未合并、被本 PR 取代,无并行重复工作(镜像 open [PR] 行中本线程仅此一条)。

标签: bug + opencode + scope/wiring + p1(缺陷修复;受影响车道 opencode;ingest 闸在请求接收边界;长会话永久 413 = 用户不能用 → p1)

审核结论:PR #7443 —— 可合(两处收尾我已修进分支)

⓪ 独立性:以下全部基于我自己读的 diff、代码与 CI 状态,不是复述 PR 描述。

① 方向(原 issue):#7426 的根因成立且已逐行核验——ingest 闸(src/server/handle.ts:537-540)在 decode 之后、session 解析与 preflight 折叠之前按「解码后原始字节」判死;而重发车道(opencode/dsh)每轮重发整段宿主台账、bili 的职责恰恰是折叠它,「原始入站字节 ≈ 模型输入」的前提在这些车道不成立,且自锁(越需要折叠的会话越先撞闸)。owner 已在 #7426 拍板「任何车道都放宽到不限制」,本 PR 的修法(默认 0 全车道关闭 + env 保留重启用逃生门)与拍板一致,比 #6933 的逐车道豁免更彻底也更简单。

② 回归审查——diff 触碰路径的既有行为逐项清点:

  • ingest 闸语义:ingestCap > 0 && bytes > cap && 无图 才 413。0 = 闸整体不触发——有意变更(默认 32 MiB → 0),PR 描述与文档均已披露旧值→新值+原因;
  • 前两段兜底未动:receive 默认 5 GiB、decode 默认 10 GiB(内存/DoS 传输层保护)——已核对 knobs 默认值;
  • Responses 车道原本就豁免(protocol === "responses" ? 0),行为不变;带图体豁免(countImagesInRawBody 探针)不变;
  • 显式设置 BILI_INGEST_BODY_BYTES / network.ingestBodyBytes 的部署:env > file > default 解析链未动,行为逐字节不变;
  • 既有 3 个 e2e(开带→413 / 未超→200 / 带图豁免)显式设 1 MiB 测试带,不受默认值变化影响——本地实跑 4/4 通过(含新增默认值单测);
  • 高危模式逐项:无 fail-fast 变吞错、无阈值/时序/输出格式漂移(413 响应形状不变,只是默认不再触发)、无缓存/重试策略变化。

③ 代码:改动面极小且干净——knobs 默认值+注释、1 个新单测(双向断言:默认 0 + env 重启用,符合 #3617 负向断言纪律)、4 份文档同步。测试有牙:精确断言 0 与 33554432,回归时抓得住。

④ 我修掉的两个问题(已 push 到 PR 分支):

  1. docs-sync 门红(CI 红,已修):原提交只改了生成的 docs/configuration*.md,没改单一事实源 website/config-reference/process.yaml(默认仍是 33554432)——docs-sync 是「重新生成 + diff」,必然漂移,并经 needs 级联把全部 test 车道拖成 skip。PR 描述里「两个 config 门都绿」指的是 check-coverage 与 config-surface-guard,漏了这条漂移门。注:我动手期间远端分支被 amend 补上了 seed 修复(d351a4d,措辞与我不同)——我核对了它的 seed↔docs 一致性(重新生成零漂移)后,撤掉自己的 seed 提交、只在其上收尾,不重复修;
  2. 顺手修(6f4f050):三处代码注释仍写着「default 32 MiB」(src/content-encoding.ts:17、src/config.ts:2386、src/server/handle.ts:522-536)——注释与代码事实不符是缺陷,已改为「[Bug][opencode][ingest/0.1.216] Long sessions on the opencode lane are permanently 413'd by the 32 MiB ingest hard limit | [Bug][opencode][ingest/0.1.216] opencode 车道的长会话被 32 MiB ingest 硬闸永久 413(且 #6908/#6933 的修复只豁免 dsh 车道,opencode 仍在外) #7426 起默认关闭,设值重启用」;另补 CHANGELOG [Unreleased] Changed 条目(默认值翻转按仓库惯例每 PR 记一条)。

⑤ diff 整洁度:干净,每行都与本 PR 目的相关;无锁文件/生成物噪音(website/main.js、website/docs/index.html 重新生成后零变化)。

验证(本地,定向):typecheck 通过;tests/issue5794-ingest-cap.test.ts 4/4 通过;docs-sync / docs-coverage / config-surface-guard 三门本地全绿。全量回归以 CI 为准——新 head 6f4f050 的 check 正在跑,绿了我再回一条。

八问

  1. 是什么问题:opencode(及同类重发)车道的长会话,原始重发体一旦超过 32 MiB 就被 ingest 闸 413,而折叠后上下文可能很小——会话永久发不出去。
  2. 什么原因导致的:ingest 成本带拿「解码后原始入站字节」当「超模型窗口」的代理,该前提只对出站/增量车道成立;重发车道的入站体是折叠前的宿主台账,与折叠后上下文无对应关系,且判死发生在折叠之前,形成自锁。
  3. 影响范围与严重程度:所有重发车道(opencode/dsh)中原始台账 >32 MiB 的长会话完全不可用;一次性/增量车道不受影响。p1(用户不能用)。
  4. 怎么修复的:按 owner 拍板把默认值 32 MiB → 0(全车道关闭),保留 env/配置重启用逃生门;传输层 receive 5 GiB / decode 10 GiB 两段兜底不变。
  5. 是否有回归问题:无。显式设值的部署逐字节不变;Responses/带图豁免不变;413 响应形状不变;既有 3 个 e2e 显式设带、不受影响(本地 4/4 绿)。
  6. 是否破坏缓存:不涉及——ingest 闸在 JSON 解析之前,不触碰缓存/重试/游标/去重键。
  7. 是否改了设计方向:不涉及架构转向;只改一个默认值(行为变更已披露:32 MiB → 0,全车道)。
  8. 是否引入了新的配置:无新键;既有 network.ingestBodyBytes / BILI_INGEST_BODY_BYTES 默认值 33554432 → 0,无需迁移(0 = 关闭,设值即恢复旧行为)。

判定:可合(CI 新 head 全绿后收工;PR 合并由你操作)。

@ranxianglei
ranxianglei merged commit 98fa957 into master Nov 21, 2026
91 of 131 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1250-master.98fa957 (rolling master tag).

npm install -g billion-context@0.0.1250-master.98fa957  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant