Repository navigation
[PR] fix: over-window requests are no longer rejected by local estimation — after folding, always forward; let upstream decid | fix: 超窗请求不再被本地估算拒发——折叠后一律转发,超不超窗让上游自己说 (#7537) - #7548
Conversation
…rd, and let the upstream's own verdict be authoritative (#7537) Owner ruling 2026-11-22 (issue #7537, KDD #19/#20): every LOCAL estimate- based 413 refusal is a product of bili's local guess multiplied by a window value that is itself often wrong (fallback windows #7205). Their product silently killed requests that would have succeeded (the #7167/#7382/#2490/ #2847/#2847/#736/#737/#4079 family). - server.ts: the four local size-413 sites (probe doom gate, #1839 measured gate, post-fold measured/doom-bytes gates, deterministic-exhaustion mapping) now FORWARD with the local measurement logged as evidence. Relay-side refusals keep their status: summary relay down -> 502, relay 429 -> 503. The BILI_MAX_MESSAGES count gate and the 5GiB byte cap are exact resource guards and stay. - relay.ts: the egress window fuse's two size gates log a profile and forward; a NEW upstream size-verdict annotation (413 / size-keyword 400) logs bili's own measurement, marks the response x-bili-retryable: false and merges a bili_evidence block into JSON error bodies so status-driven hosts do not retry-loop an unchanged body. - server.ts: NEW evidence-backed loop guard — an outbound body that already drew an upstream size verdict (SHA-1 scoped, 10-min TTL) is refused locally as a byte-identical resend (#496 family); changed bodies and the identity fast path re-forward freely. - The window-shrink note now rides the forward warns (the 413 fail-fast it decorated is gone); the duplication profile moved onto the over-window forward. - AGENTS.md KDD #19 + reference/design-decisions.md #20 record the ruling. - Tests: NEW tests/issue7537-preflight-passthrough.test.ts (3); re-pinned issue1841/2490/2847/3645/4079/4185/preflight-fail-fast to passthrough semantics; tests/issue3846-local-refusal-evidence.test.ts deleted (the local refusal it pinned no longer exists — the loop guard replaces it). Supersedes PR #7507 (whose two new gates no longer need to exist under this ruling). Refs #7537 #7507 #7167 #7382 #2490 #2847 #736 #737 #4079 #4543 #1841 #3645 #496 #3846 #3461 #5000
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11522-pr.7548.5f69c14This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr7548.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ate-refusal behavior The #7537 PR (owner ruling 2026-11-22: no local estimate-based size refusal) removed every estimate 413 and updated 7 preflight test files plus deleted issue3846, but missed tests/fix-identity-fast-path-preflight.test.ts — its 3 tests still pinned the old 413-veto, so the full suite went red. Apply the PR's own rewrite pattern (issue2847/issue4185): the 413-veto assertions become forward/upstream-decides assertions; the log-line assertion moves from 'identity fast path' to the #7537 no-estimate-refusal forward line. A2 (fresh evidence) keeps the 200-forward behavior; B (stale-origin) and B2 (stale-model) drop the 413 veto and assert the payload is forwarded, the upstream decides. Verified locally: file 5/5 green, typecheck clean.
(ai: vllm-qwen/qwen3.8-27b) CI fix for PR #7548 (e-work mirror #7550) — attempt 1/6What I did this run:
Current CI status: the mirror cache is stale (fetched_at 2026-11-22T16:14:49Z, before my push ~17:25 UTC); the 30 checks shown are from the previous head. The CI for the new head 八问
判定: 最终 head |
… the body merge (#7537) The preflight loop guard (byte-hash of an upstream-refused body) fired before the fit check and the fold walk, so it 413'd two contracts: #3900's identical retry while the local estimate still fits (the learning loop needs a second forward) and #987 T3's resend that preflight can fold under the declared window. The guard is gone — the anti-loop protection for the truly-doomed payload is the EVIDENCE branch restored in the deterministic-exhaustion path: nothing more can fold AND the upstream has already proved the wall (stated/armed overflow) AND the calibrated meter agrees → local 413, retryable=false (#3461/#496/#767/#857). Estimation- only exhaustion keeps forwarding (#7537). The relay size-verdict annotation now marks x-bili-cause/x-bili-retryable via headers only; the upstream body passes through byte-identical (#1195 B and request-input-lifetime pin verbatim bodies). Test re-pins: #2391 eager/loaded tool overflow forwards (measured tier is an evidence logger, not a judge); #1841 A splits into wall-413 (evidence survives) + A2 no-wall forward; #4185 resend hits the evidence 413; #4079/#7537 assert the header-only annotation; ci-shard weights drop the deleted #3846 pin.
…7537 forward semantics preflight-zero-fold-calibration: the anonymous-baseline and image-reserve pins expected the #5000/#4543 measured-doom 413 — exactly the estimate-refusal family #7537 removes. They now pin the forward contract (no local refusal, upstream decides; scoped refusal demoted to evidence input). preflight-responses-wire: the two unfoldable 4.6MB body/tool pins expected local 413; they now forward (mock upstream accepts → 200, exactly one forward each).
(ai: vllm-qwen/qwen3.8-27b) Event is stale — no work needed this run. The reported head
The 8 failing shards in the event (windows 22 1/2, ubuntu 24 1/2/3, ubuntu 22 1/2/3) were on head Live check state: the mirror cache is stale (fetched_at 2026-11-23T01:29:08Z, 8.6 min old at check time) — the current head's CI is running or just completed, but I cannot verify green/red from the cache. No further work from this run. |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1282-master.9236576 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…lict, round 7) Master moved 0b68ade -> 15f06c6 (kernel 0.0.205, +preflight emergency-digest default-off #7549, +preflight 413 passthrough #7548, +sessions reattach #7512, +opencode user-fork detection #5511, +acp-status uncompressed nudge-align #7536, +preflight gate epoch exception #7558, +413 egress fuse pins #7488, +Korean README #7551, +many host/test changes). Conflicts: 3 version-only files (kernel/package.json, kernel/package-lock.json, root package-lock.json). Resolved to kernel 0.0.206 (merged kernel = superset of master's 0.0.205 + PR #6720/#6762 changes; kernel/src changed vs master => must bump above master's 0.0.205). Auto-merged clean: kernel/src/compress.ts (PR markers 13x + master changes), src/stream.ts (PR markers 3x), src/server.ts, master's new test files, docs. Local verification: typecheck ✓, build ✓, kernel 1671 pass / 0 fail, host nudge/receipt 7 pass / 0 fail, kernel-guard ✓ (SRC_CHANGED=2 BUMPED=1 0.0.205->0.0.206), version-guard ✓ (root 0.1.216 untouched), lock-sync ✓.
超窗请求不再被本地估算拒发:折叠后一律转发,超不超窗让上游自己说
1. 这是啥问题?
bili 在转发前用「本地估算 token 数 × 本地记录的窗口值」判断请求会不会超窗。
两者都是猜的:窗口值经常是错的(fallback 窗口、#7205),估算也常偏。
这个乘积只要偏大,bili 就直接回 413「NOT forwarded」——请求根本没发出去,
而实际上很多这种请求上游是能正常处理的。这一家族的问题全部源于此:
#7167、#7382、#2490、#2847、#736、#737、#4079(详见 #7537 的讨论)。
2. 根本原因
一个「本地估算 × 本地窗口」的确定性拒发门。窗口值本身没有上游背书时,
任何基于它的拒发都是在替上游做决定——而且经常做错。
3. 修了什么(owner 2026-11-22 拍板,写入 AGENTS.md KDD #19 / design-decisions #20)
原则:本地估算一律不得拒发;折叠照做,然后转发;超不超窗以上游的真实报错为准。
src/server.ts:四处本地估算 413 全部改为「记录本地测量值 + 转发」(probe doom 门、任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 测量门、post-fold 测量/字节门、deterministic 耗尽映射)。
relay 侧失败保留状态码:摘要 relay 挂了 → 502,relay 吃 429 → 503。
保留的本地拒发只有三类非估算门:
BILI_MAX_MESSAGES消息数门(精确计数,非估算)、5GiB 字节上限(纯字节护栏)、以及证据分支(见下条)。
src/server/relay.ts:egress window fuse 的两个尺寸门改为「记 profile + 转发」。新增上游尺寸裁决注解:上游真回了 413(或尺寸类 400)时,bili 把自己的
测量值写进日志(本地 token 数/字节数/窗口值),响应加
x-bili-cause: upstream-size+x-bili-retryable: false两个 header,防止按状态码重试的宿主拿同一个 body 反复烧速率限制。上游 body 逐字节透传
(不合并任何字段——使用pi 压缩后就提示prompt is too long #1195 B / request-input-lifetime 钉的就是逐字节透传)。
确定性地无可再折、上游自己证明过这堵墙(显式 overflow 数字或
400/413 触发的 overflow-arm)、且 bili 自己的校准计量也认超窗 —— 三个条件
同时成立才本地 413(retryable=false,不烧线)。背后是上游真实裁决 + 穷举
折叠证明,不是估算,所以 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 裁定不删它。没有证明墙的会话一律转发。
重复率 profile 改挂到「折叠后仍超窗」的转发上(Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079 诊断能力保留)。
tests/issue3846-local-refusal-evidence.test.ts删除:它钉的「本地估算拒发」已不存在,由证据分支 + 转发语义替代([Bug][preflight] Local 413 is forgotten when the baseline becomes an estimate, reopening oversized probes #3846/413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185 的回归测试已改为钉新语义)。
4. 能否合并
issue2490 9/9、issue2847 1/1、issue4079 4/4、preflight-fail-fast 8/8、
issue1841 3/3、issue3645 4/4、issue4185 5/5、issue496 1/1、
issue3918 2/2、issue5000 3/3、issue5191 1/1、fix-arm-headroom-clamp 3/3、
preflight-nonstream-400-probe 2/2、issue3004 7/7;
tsc --noEmit干净。「本来会成功的超大请求」不再被本地拦截(这正是目的),以及
「注定失败的请求」真实打到上游一次(换来上游的权威裁决 + 回环保护)。
5. URL
6. 影响面
所有走 preflight 的超窗路径(Anthropic/OpenAI/Responses 三条线共用
preflightCompressIfNeeded)+ egress fuse 两道尺寸门 + 上游错误注解(header + 日志;上游 body 一律逐字节透传)。
7. 测试
见 §4。新增
tests/issue7537-preflight-passthrough.test.ts钉三件事:① 折叠后仍超窗(无证明墙)→ 转发,上游 413 透传 +
x-bili-retryable:falseheader(body 逐字节);② 测量超窗但上游接受 → 现在能送达(旧:本地 413 杀死);
③ 消息数门仍是本地拒发。另:#1841 拆成 A(有证明墙 → 证据 413 保留)+
A2(无墙 → 转发);#2391 eager/loaded 工具溢出改为转发;#3900/#987/#496/
#767/#857/#1195 等既有钉全部复绿(见 §4 清单)。
8. 风险
但上游一旦回过尺寸裁决(overflow-arm 落地),同一会话同形状 payload 的
后续重发走证据分支本地 413,不会二次烧线。