惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
H
Help Net Security
Jina AI
Jina AI
V
V2EX
G
Google Developers Blog
B
Blog
GbyAI
GbyAI
U
Unit 42
爱范儿
爱范儿
腾讯CDC
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
小众软件
小众软件
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - Franky
博客园 - 聂微东
The Cloudflare Blog
I
InfoQ
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(lmstudio): honor thinking off for binary reasoning mo...
nxmxbbd · 2026-06-14 · via Recent Commits to openclaw:main

@@ -2,11 +2,13 @@

22

* Tests provider stream shared helpers and stream hook capture.

33

*/

44

import type { StreamFn } from "openclaw/plugin-sdk/agent-core";

5+

import type { Model } from "openclaw/plugin-sdk/llm";

56

import { describe, expect, it } from "vitest";

67

import { createAssistantMessageEventStream } from "../llm/utils/event-stream.js";

78

import {

89

createDeepSeekV4OpenAICompatibleThinkingWrapper,

910

createAnthropicThinkingPrefillPayloadWrapper,

11+

createOpenAICompatibleCompletionsThinkingOffWrapper,

1012

createPayloadPatchStreamWrapper,

1113

createPlainTextToolCallCompatWrapper,

1214

defaultToolStreamExtraParams,

@@ -16,6 +18,27 @@ import {

16181719

type StreamEvent = { type: string } & Record<string, unknown>;

182021+

const lmstudioBinaryModel = {

22+

api: "openai-completions",

23+

provider: "lmstudio",

24+

id: "google/gemma-4-26b-a4b-qat",

25+

baseUrl: "http://127.0.0.1:1234/v1",

26+

reasoning: true,

27+

compat: {

28+

supportsReasoningEffort: true,

29+

supportedReasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh"],

30+

reasoningEffortMap: { off: "none", none: "none", adaptive: "xhigh", max: "xhigh" },

31+

},

32+

} as unknown as Model<"openai-completions">;

33+34+

const lmstudioBareModel = {

35+

api: "openai-completions",

36+

provider: "lmstudio",

37+

id: "qwen3-8b-instruct",

38+

baseUrl: "http://127.0.0.1:1234/v1",

39+

reasoning: true,

40+

} as unknown as Model<"openai-completions">;

41+1942

function requireRecord(value: unknown, label: string): Record<string, unknown> {

2043

if (!value || typeof value !== "object" || Array.isArray(value)) {

2144

throw new Error(`expected ${label} to be a record`);

@@ -35,6 +58,20 @@ function createEventStream(events: unknown[]): ReturnType<StreamFn> {

3558

return output as ReturnType<StreamFn>;

3659

}

376061+

function createPayloadCapture(initialReasoningEffort?: string) {

62+

const payloads: Array<Record<string, unknown>> = [];

63+

const baseStreamFn: StreamFn = (model, _context, options) => {

64+

const payload: Record<string, unknown> = { model: model.id };

65+

if (initialReasoningEffort !== undefined) {

66+

payload.reasoning_effort = initialReasoningEffort;

67+

}

68+

options?.onPayload?.(payload, model);

69+

payloads.push(structuredClone(payload));

70+

return createAssistantMessageEventStream();

71+

};

72+

return { baseStreamFn, payloads };

73+

}

74+3875

function createControlledPlainTextToolCallCompatStream() {

3976

const source = createAssistantMessageEventStream();

4077

const baseStream: StreamFn = () => source as ReturnType<StreamFn>;

@@ -198,6 +235,40 @@ describe("createPayloadPatchStreamWrapper", () => {

198235

});

199236

});

200237238+

describe("createOpenAICompatibleCompletionsThinkingOffWrapper", () => {

239+

it("maps reasoning_effort to the model's disabled value when thinking is off", () => {

240+

const { baseStreamFn, payloads } = createPayloadCapture("high");

241+

const wrapped = createOpenAICompatibleCompletionsThinkingOffWrapper(baseStreamFn, "off");

242+

void wrapped(lmstudioBinaryModel, { messages: [] }, {});

243+244+

expect(payloads[0]?.reasoning_effort).toBe("none");

245+

});

246+247+

it("drops reasoning_effort when the model has no disabled effort", () => {

248+

const { baseStreamFn, payloads } = createPayloadCapture("high");

249+

const wrapped = createOpenAICompatibleCompletionsThinkingOffWrapper(baseStreamFn, "off");

250+

void wrapped(lmstudioBareModel, { messages: [] }, {});

251+252+

expect(payloads[0]).not.toHaveProperty("reasoning_effort");

253+

});

254+255+

it("does not add reasoning_effort when none was sent", () => {

256+

const { baseStreamFn, payloads } = createPayloadCapture();

257+

const wrapped = createOpenAICompatibleCompletionsThinkingOffWrapper(baseStreamFn, "off");

258+

void wrapped(lmstudioBinaryModel, { messages: [] }, {});

259+260+

expect(payloads[0]).not.toHaveProperty("reasoning_effort");

261+

});

262+263+

it("leaves enabled thinking levels unchanged", () => {

264+

const { baseStreamFn, payloads } = createPayloadCapture("high");

265+

const wrapped = createOpenAICompatibleCompletionsThinkingOffWrapper(baseStreamFn, "high");

266+

void wrapped(lmstudioBinaryModel, { messages: [] }, {});

267+268+

expect(payloads[0]?.reasoning_effort).toBe("high");

269+

});

270+

});

271+201272

describe("createPlainTextToolCallCompatWrapper", () => {

202273

it("promotes standalone text tool calls into tool-call stream events", async () => {

203274

const baseStreamFn: StreamFn = () =>