Repository navigation
[PR] fix: #5907 colon-prefixed gateway model ids resolve their window; unknown-window dsh oversize arm falls back to the 1M floor - #5910
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8802-pr.5910.a16617cThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5910.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 这是修 #5907 的 PR(#5910),两个独立缺陷各一个 commit;open/closed 无同机制在途 PR。与今日已合的 #5875/#5613 是互补不是重复——那两个加了校准估算层但构造上保留了缺窗 fail-open,本 PR 正是补那个洞。 我独立核对了 diff(base=当前 master,merge-base==origin/master,无陈旧基线;干净 4 文件 +77/-15,两 commit),并逐条 trace 了逻辑、比对 CONTEXT_LIMIT_TABLE 实际值、读了共享谓词实现、确认作用域。结论如下(结构化八问): 1. 是什么问题:自定义 OpenAI 兼容网关里模型 id 形如 2. 什么原因:(a) 3. 影响范围与严重度:仅 dsh 车道「无归因 + 宿主未声明窗口」子集(自定义 provider 典型场景);有归因流量、已声明窗口请求、omp/opencode 等其它车道完全不受影响。受影响用户该链每轮要么上游 400、要么挂 15s,体验毁灭级(用了就想卸载)→ p1(PR 已打 p1,合理)。有绕行(配 4. 怎么修的:(a) 5. 是否有回归:审过既有行为逐项——
6. 是否破坏缓存:不涉及。窗口估算影响压缩预算,不进缓存键/身份; 7. 是否改了设计方向:不涉及。沿用既有 fallback-tier 架构,只补未知窗口这个洞;反而刻意保持共享谓词「缺数据→undefined」契约不变、把 fallback 收敛到 dsh 两处调用点——边界更干净。 8. 是否引入新配置:不涉及。无新字段/env/默认值;既有 非阻塞观察(不拦):同一「未知窗口失活超窗臂」的洞也存在于通用直连兜底车道( CI(head 665163e)全绿:全部 test 分片(ubuntu/windows × node22/24)+ 全部 guard(config-surface/lock-sync/version/lane/kernel/pi-subagents/docs-sync/unused-exports/lifecycle-ledger/test-import-graph)+ mysql-contract 均 success,无 failure(cancelled/skipped 为不适用/被取代的矩阵腿)。 测试有效性(#3617 双向):routing 正例含 issue 现场 id( 判定:可合。 需人工 merge——涉及 fallback/default 语义变更,按 §7.4 属人工门禁(非 auto-merge 范畴)。labels(bug/p1/dsh)与本 PR diff 相符,无需调整。 |
…mit table (#5907) modelRoots only stripped the slash-prefixed provider segment, so gateway ids like 'liuyue/cn:deepseek-v4.1-flash' yielded roots that start with the namespace prefix and missed every ^-anchored family rule, falling to the 2e5 env default (167232 after output reservation) for a 1M model. Each root now also yields its tail after the last colon as a candidate, tested strictly after the un-stripped root so tag-shaped suffixes cannot hijack an unrelated family rule; ids without a colon produce identical roots.
…no window is declared (#5907) effectiveContextWindow answers undefined until the host resolves model info, which custom providers often never do; bodyProvablyOverWindow then disarms by construction and a provably oversized unattributed body rode DIRECT into a guaranteed upstream rejection (field shape: 1.45M-token sends 400ing or hanging 15s per turn). Both gate arms now size the bar at max(declared ?? 1M floor), keeping the never-assumes-below-1M doctrine of #4079; the refusal log distinguishes 'no window declared; assuming the 1M floor' from a real declaration.
…DRINUSE diag (#5907 minor item a) A host relaunch racing the still-up previous instance lands the loser's EADDRINUSE error block ~40ms beside its [split-brain] notice, which reads like a fatal error although the loser exits cleanly and the serving instance keeps everything. The serving branch of holderHintFragment now states the expectedness explicitly and cross-references a nearby [split-brain] notice naming this exiting pid as the same duplicate start settling — purely additive wording on the ALREADY-SERVING branch only; the wedged/dead diagnostic is untouched.
…leanup hint (#5907 minor item b) A 3k-msg session exceeds the 1s wall budget on EVERY turn, so the warn flooded the log one line per turn while adding nothing after the first. It now fires once per sessionId per process (bounded map, earliest-warned evicted past 512); the first occurrence carries the full size picture — msgs + inbound bytes + bytes/4 est tokens (the repo-wide optimistic floor, labeled est) — plus the 'bili sessions rm <id>' cleanup command (verified existing CLI surface, src/cli.ts). Behavior change: repeat slow turns of the same session are silent; the 'passthrough' pseudo-session shares the same once-per-key semantics.
…t /bili/ fallback (#5907)
a3f01bc to
7b09b2f
Compare
Closes #5907
Two independent defects behind one field symptom (unattributed dsh chains stranded at a 167232-token window while a 1M model sits behind the gateway):
1.
vendor/region:modelids miss the context-limit table (src/config.ts).modelRootsonly stripped the slash-prefixed provider segment, soliuyue/cn:deepseek-v4.1-flashyielded roots starting with the namespace prefix and matched no ^-anchored family rule → env default 2e5 − 32768 output reservation = 167232 for a 1M model. Every root now also yields its tail after the LAST colon as a candidate, tested strictly AFTER the un-stripped root (a tag-shaped suffix likegpt-5:o3-preview→o3-previewmust not false-match an unrelated family rule before the real name is tried). Ids without a colon produce identical roots to before.2. Unknown window disarmed the dsh gate's oversize refusal (src/agent/dsh-native.ts).
Until the host resolves model info,
effectiveContextWindow(ctx)is undefined — which custom providers often never do. The shared predicate then returns undefined by construction and both gate arms fell through to a direct send: a provably oversized UNATTRIBUTED body rode straight into a guaranteed upstream rejection (field shape from the issue: 1.45M-token sends 400ing or hanging 15s per turn). Both arms now passdeclared ?? MIN_ASSUMED_WINDOW_TOKENS, keeping the #4079 never-assumes-below-1M doctrine; the durable refusal line says "no window declared; assuming the 1M floor" instead of echoing a fake declaration.Complementary to #5875/#5613 (merged earlier today), which added the calibrated estimate tier on top of the optimistic floor but kept missing-window fail-open by construction — this PR closes exactly that remaining hole. The shared predicate's contract (undefined on missing data) is unchanged; the fallback lives at the two dsh call sites only, so every other lane (omp/opencode direct-send guards, #5032's pending per-lane arming decisions) is untouched.
Behavior changes (old → new):
:now reach family rules via the colon tail (previously: table miss → env default 2e5). No-colon ids: identical behavior. Affects every lane usinglookupContextLimitas its fallback tier, plustierGatedStandardWindow(claude tier cap) consistently.Config surface: none — no new config fields, env vars, or defaults; the existing
modelContextLimitescape hatch keeps working as before.Tests (both directions per #3617):
Follow-up commits (2026-11-08): the two minor log-surface items from the same report, each its own labeled commit (added pre-merge per the repo standing rule for small direct fixes)
fix: name the expected duplicate-instance outcome in the terminal EADDRINUSE diag— the ALREADY-SERVING branch of the holder diagnostic now states explicitly that a duplicate-instance start is the expected outcome of a host relaunch and cross-references a nearby [split-brain] notice naming this exiting pid as the same race settling, not data corruption. Purely additive wording; the wedged/dead diagnostic branch is untouched.fix: slow-session warn fires once per session with size picture and cleanup hint— behavior change (old → new): the[slow-session]warn fired on EVERY turn past the 1s wall budget; it now fires once per sessionId per process (bounded map, earliest-warned evicted past 512). The first occurrence gains(~N est tok)(bytes/4 optimistic floor, labeled est because JSON overhead skews it) and abili sessions rm <id>cleanup command (verified existing CLI surface). Thepassthroughpseudo-session shares the once-per-key semantics.Item-b direction (once-per-session over hard-cap silence, full size line) follows the affected reporter's choice recorded in the issue thread. Both items are log-surface only — no control-flow change.
Follow-up commits (2026-11-09): rebase + second defect facet of #5907 (turns that never reach ACP at all)
82e2d53c6e); conflict with the [PR] release v0.1.213 #5898 review batch resolved as the union of both intents — master's locale-readable numbers in the gate refusal lines + this PR's unknown-windowwindowNotefallback. All prior commits re-verified on the new head (targeted suites 216/216, typecheck, build).fix: name the no-guard fetch postures in bili.log; document the direct /bili/ fallback (#5907)— the reporter's second observation: some turns produce ZERO bili.log lines because the host-sideglobalThis.fetchtakeover never saw them. Findings verified against the code: assignment-based displacement by third parties is NOT silent since 方式一安装的dsh 原生插件:llm-pi-ai 传输(OpenAI SDK + options.fetch 注入)绕过 globalThis.fetch 拦截,模型请求不进代理、压缩完全不生效 #1158 (logged + re-chained as downstream), so the silent class is the no-guard posture — non-configurable host property orBILI_RECLAIM_FETCH_PATCH=0. That path now logs a ONE-TIME warn naming the degraded posture, its consequence (silent un-routing, zero log lines) and the/bili/remedy; previously it was silent at install time. Behavior change (old → new): two new possible warn lines in bili.log under those postures — additive logging only, no wire/config/control-flow change. Tests pin both branches (reversible env-hatch case + a last-in-file case that locks the slot to simulate the non-configurable host). Docs (en+zh technical-notes) gain a section documenting that/bili/{upstream-URL}is directly addressable without any hook — the supported robust fallback when a lane's hook misses turns (captured fetch refs, non-fetch transports, other realms bypass the patch by construction and are invisible to the proxy).Follow-up commit (2026-11-09): third facet of #5907 — naming the unattributed class in the zero-progress fits-forward warn
fix: name the unattributed-chain class in the zero-progress fits-forward warn (#5907)— field shape from the reporter: a request that reaches bili WITHOUT any conversation identity is resolved by prefix affinity into apfa-*chain whose window comes from the static ladder (never a host report); when that chain then hits "preflight made no progress but the payload fits; forwarding as-is", the forward can die upstream ~20s later (400 / stream silence) with nothing in bili.log naming the class. The existing zero-progress warn (src/server.ts) now appends an unattributed-chain note — window source, mis-size risk, the identity-header remedy — ONLY when the request was anonymous; identified sessions keep the original wording verbatim. Behavior change (old → new): one existing warn line gains an additive suffix on anonymous requests only; log-surface change, no wire/config/control-flow change. New test file pins both directions (Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617): anonymous=false → original wording intact; anonymous=true → suffix with the The defaultmodelContextLimitof 200000 underestimates the context window for custom provider routing, and over-window |modelContextLimit缺省 200000 会把自定义 provider 路由的窗口算小,且超窗的「无归因」请求会被照发而不是本地拒绝 #5907 cross-reference; both assert the branch still forwards (never fail-fasts).