Repository navigation
fix(dsh): bind llm.resolveModelInfo to its service receiver (#1942) - #1944
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
dsh registers resolveModelInfo as a class method that delegates through its receiver (this.resolveModelInfoFor(this.registration(provider), …)). refreshModelInfo extracted it as a bare property and called it detached, dropping the receiver (`this === undefined` in strict mode) so every resolve rejected with "Cannot read properties of undefined (reading 'resolveModelInfoFor')" and the failure-shaped cache stripped x-bili-plugin-context-window for 100% of providers/models on every process start. Bind the receiver at the extraction site; harmless if a host ever supplies a plain function that ignores `this`. Regression test drives a real class-instance resolver whose method depends on `this` (object-literal stubs never do, which is why the existing #955/#956/#1812 suites passed despite the detached call). Verified: pre-fix the test times out waiting for the window header; post-fix it stamps model/window/max-output. Fixes #1942.
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1947-pr.1944.fe89945This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1944.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
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.
Summary
refreshModelInfoinsrc/agent/dsh-native.tsextractedllm.resolveModelInfoas a bare property and called it detached. dsh registersresolveModelInfoas a class method whose first statement delegates through its receiver (this.resolveModelInfoFor(this.registration(provider), model, signal)), so the detached call runs withthis === undefinedand every resolve rejects with:The rejection lands in the failure-shaped cache path (
modelInfo.cached = { provider, model }, no window), soheadersFornever stampsx-bili-plugin-context-windowand the proxy sizes the session against its unconfigured fallback. Unconditional: 100% of models on 100% of providers on every process start.Fix
Bind the receiver at the extraction site — one line, no signature or config-surface change:
Binding is harmless if a host ever supplies a plain function that ignores
this, so this is safe across host shapes.Behavior change (old → new)
x-bili-plugin-modelbut neverx-bili-plugin-context-window/x-bili-plugin-max-output— the resolve threw deterministically before returning any numbers, so the proxy sized every dsh session against its fallback window.modelContextLimitworkaround is needed.This restores the intended runtime-info behavior (#955/#956); it is a defect fix, not a new capability.
Verification
this. Object-literal stubs never depend on the receiver, which is why the existing [native] runtime-info protocol: plugins report real model config (model / contextWindow / maxOutput) to the proxy #955/feat: runtime-info protocol — plugins report real model config to the proxy (#955) #956/130k上下文窗口被占满触发无效压缩越压越大 #1812 suites passed despite the detached call. Proven to have teeth by toggling the fix: pre-fix the test times out waiting for the window header; post-fix it stamps model/window/max-output.npm run typecheckclean,npm run buildclean, targetedtests/dsh-native.test.ts43/43 green on the rebased head (based on current master, which includes fix(dsh): retry failed model-window resolves — one boot race no longer strips x-bili-plugin-context-window #1836's retry cadence).Related finding (tracked separately, out of scope here)
While reproducing this, a distinct boot-order race surfaced in the same log: the adapter may not be registered yet when the first
refreshModelInforuns, producing a transientno adapter registered for provider "…"that latches the failure cache until #1836's 30s cooldown retry recovers it (~first 30s after a host restart). Different root cause (host initialization order vs. deterministic receiver loss) and a different fix (event-driven invalidation onllm/adapters-updated, not a wider time-based retry). It is filed as its own issue; this PR fixes only the receiver loss.Fixes #1942