fix: validate lmstudio preload context length · openclaw/openclaw@8e806e9
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -222,6 +222,32 @@ describe("lmstudio stream wrapper", () => {
|
222 | 222 | }); |
223 | 223 | }); |
224 | 224 | |
| 225 | +it("omits malformed preload context lengths", async () => { |
| 226 | +const baseStream = buildDoneStreamFn(); |
| 227 | +const wrapped = createWrappedLmstudioStream(baseStream, { |
| 228 | +baseUrl: "http://lmstudio.internal:1234/v1", |
| 229 | +}); |
| 230 | +const stream = runWrappedLmstudioStream( |
| 231 | +wrapped, |
| 232 | +{ |
| 233 | +contextTokens: 64000.5, |
| 234 | +contextWindow: Number.POSITIVE_INFINITY, |
| 235 | +}, |
| 236 | +{ apiKey: "lmstudio-token" }, |
| 237 | +); |
| 238 | +const events = await collectEvents(stream); |
| 239 | + |
| 240 | +expectSingleDoneEvent(events); |
| 241 | +expect(ensureLmstudioModelLoadedMock).toHaveBeenCalledTimes(1); |
| 242 | +expectEnsureLoadedFields({ |
| 243 | +baseUrl: "http://lmstudio.internal:1234/v1", |
| 244 | +modelKey: "qwen3-8b-instruct", |
| 245 | +requestedContextLength: undefined, |
| 246 | +apiKey: "lmstudio-token", |
| 247 | +ssrfPolicy: { allowedHostnames: ["lmstudio.internal"] }, |
| 248 | +}); |
| 249 | +}); |
| 250 | + |
225 | 251 | it("continues inference when preload fails", async () => { |
226 | 252 | ensureLmstudioModelLoadedMock.mockRejectedValueOnce(new Error("load failed")); |
227 | 253 | const baseStream = buildDoneStreamFn(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。