Repository navigation
fix(dsh): retry failed model-window resolves — one boot race no longer strips x-bili-plugin-context-window - #1836
Merged
Merged
Conversation
…r strips x-bili-plugin-context-window for the process lifetime Root cause of the #1812 mis-sizing handshake gap: dsh's catalog always knows a window (user-set models[].contextWindow or the built-in default), and headersFor stamps x-bili-plugin-context-window from the ModelInfoCache — but refreshModelInfo cached {provider, model} (no window) whenever resolveModelInfo failed once, and the early-return only compared provider+model, so a single boot-time race (catalog still loading) latched the process headerless. Every request of the session then sized against bili's unconfigured 200k fallback. Observed live on the same dsh install against the same model: two proxy runs sent x-bili-plugin-model without any context-window header (proxy warned #1569 and only survived via a lucky registry-peek match), a third run sent the header on every request — intermittency = the boot race. Fix: a matching cache entry is final only when it carries a window; a failure-shaped entry retries after a 30s cooldown (test hook: BILI_MODEL_INFO_RETRY_MS). Successful resolves with a window clear the retry state; selection-change semantics from #956 are untouched. Test: new dsh-native unit test — resolve fails twice, model id still stamped, window absent; after the cooldown the next stamp carries x-bili-plugin-context-window: 262144 (attempts >= 3). Part of #1812 (handshake root cause; the error-text extraction rework stays in #1818).
This was referenced Oct 1, 2026
Closed
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1820-pr.1836.73deb36This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1836.tgz
npm install -g packageInstall instructions are refreshed on each push. |
#1836) The retry-cooldown env var introduced by the fix commit was left out of the env-var tables; BILI_UPDATE_REGISTRY/BILI_UPDATE_CHECK_INTERVAL_MS set the precedent that test-hook seams get a CONFIGURATION.md row (en + zh mirror).
Owner
Author
[bot] 🏷 Review 完成(代码 + CI + 本地定向验证),结论:可合并,等新 head 的 test 矩阵收尾即可人工合并。 审核前置(方向关 / 复现查证)
结构化七问
Review 中直接补的两处小修(已推到 PR 分支,commit
验证证据
判定:代码审查通过、无回归信号、测试真实有效;等 |
This was referenced Oct 1, 2026
Merged
This was referenced Oct 2, 2026
This was referenced Oct 2, 2026
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1812 — the dsh→bili window handshake root cause. The error-text extraction rework stays in #1818.
Root cause
The
#1812session sized everything against bili's unconfigured 200k fallback even though the client knew the real window. The handshake chain:models[].contextWindowor the built-in default), andheadersForstampsx-bili-plugin-context-windowfrom theModelInfoCache.refreshModelInfocached{provider, model}(no window) wheneverresolveModelInfofailed once, and the early-return only comparedprovider+model— so a single boot-time race (catalog still loading) latched the process headerless: every request of the whole session sized against the fallback, and the proxy only survived via a lucky registry-peek match (or not at all behind relays with unknown models → 130k上下文窗口被占满触发无效压缩越压越大 #1812's 400 loop).Live evidence
Same dsh install, same model, three proxy runs:
x-bili-plugin-modelpresent, nocontext-windowheader on any request (proxy warned#1569, window recovered only by models.dev peek);Intermittency = the boot race.
Fix
BILI_MODEL_INFO_RETRY_MStest hook).Test
New dsh-native unit test: resolve fails twice → model id still stamped, window absent; after the cooldown the next stamp carries
x-bili-plugin-context-window: 262144(attempts ≥ 3). Suite: 42/42.Config surface
New env var, test-hook species (same class as
BILI_UPDATE_CHECK_INTERVAL_MS, #1153):BILI_MODEL_INFO_RETRY_MS— cooldown (ms) before a failed / window-less dsh model-window resolve retries. Default30000; non-numeric or negative values fall back to the default. Unset in production; the dsh-native unit test shortens it to1so the cadence is exercised without wall-clock waits.7046efab.Intended behavior change (disclosed): a failed or window-less resolve used to latch headerless for the whole process lifetime; it now retries every 30s until the catalog yields a window. Minor side effect during persistent failure: the best-effort runtime-info report repeats each retry cycle instead of once per process/model (payload unchanged — no window claim).