Repository navigation
[PR] fix(dsh): recover boot-race model-info cache on llm/adapters-updated - #1946
ranxianglei wants to merge 3 commits into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2013-pr.1946.bbb54e3This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1946.tgz
npm install -g packageInstall instructions are refreshed on each push. |
PR #1946 审核完成 — 可合并(mergeable)。 结构化七问
验证证据
一个审过但判定为非缺陷的点: 结论:可合并。 §7.4 auto-merge gate 各项均满足(单模块 fix、有辨识度的回归测试、当前 base 上 CI 全绿、无 config/persistence/wire/cross-repo 变更、纯 |
…ions (#1945 eventListeners + HostCtx type)
|
(ai: zhipuai-lb/glm-5.3) 陈旧票清理(第三批动作①):目标 issue #1945 已关。为避免重复劳动关闭本 PR;如判断有误请直接 reopen 并留言。 |
Closes #1945
What
The dsh native plugin's first
refreshModelInfocan run before the selected provider's adapter is registered in the host, where dsh throwsno adapter registered for provider(NO_ADAPTER) and latches a failure-shaped cache ({provider, model}, no window). #1836's cooldown recovers it within ~30s, but every request in that window after a host restart ships withoutx-bili-plugin-context-window, so the proxy sizes against its fallback.Fix
Subscribe to dsh's
llm/adapters-updatedhost event (emitted by dsh-llm'scommitRouteson every adapter register/replace/dispose) through the plugin's existingctx.onsurface. When it fires while a failure-shaped cache is latched, dropmodelInfo.retryAtto now so the NEXTheadersFor -> refreshModelInfore-resolves immediately instead of waiting out the 30s cooldown.contextWindow) - a resolved cache stays final (pinned by test).ctx.onor without the event keep fix(dsh): retry failed model-window resolves — one boot race no longer strips x-bili-plugin-context-window #1836's cooldown as the recovery path (graceful no-op)._resetRegisterForTestnow also resetsmodelInfo.retryAt(completes the lifecycle reset the new path relies on for test isolation).Behavior change (disclosed)
Old: after a host restart, if the first resolve hits NO_ADAPTER, sessions send no context-window header for up to 30s (cooldown) and the proxy sizes against its fallback window.
New: recovery happens on the request right after the provider's adapter registers (typically seconds after boot); the 30s cooldown is unchanged as fallback for hosts that never emit the event. No config-surface change, no default changed.
Verification
dsh-llm/lib/index.jsemitsllm/adapters-updated(no payload) fromcommitRoutes(register/replace) and dispose; the dispatch carries no thisArg, so cordis applies no context filter and plugin listeners receive it; dsh's owndsh-llm/lib/invariant.jssubscribes with exactlyctx.on("llm/adapters-updated", ...).llm/adapters-updated, assert the window header lands on the next stamp with exactly one extra resolve, and that later events do not disturb the final cache. Confirmed discriminating: the test fails with the source change stashed.npm run typecheckclean;tests/dsh-native.test.tsgreen (43/43);npm run buildOK. Full suite left to CI.Scope: single-module fix (
src/agent/dsh-native.ts, client-side header stamping only; proxy mode unaffected). No config schema / persistence / wire-shape / cross-repo changes.