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

推荐订阅源

小众软件
小众软件
博客园 - Franky
罗磊的独立博客
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
V
V2EX
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
U
Unit 42
GbyAI
GbyAI
A
About on SuperTechFans
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
D
DataBreaches.Net
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | 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(qwen): honor chat-template thinking level · openclaw/...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

@@ -5,6 +5,7 @@ import { createQwenThinkingWrapper, wrapQwenProviderStream } from "./stream.js";

5566

function capturePayload(params: {

77

thinkingLevel?: "off" | "low" | "medium" | "high" | "xhigh" | "max";

8+

thinkingFormat?: string;

89

reasoning?: unknown;

910

initialPayload?: Record<string, unknown>;

1011

model?: Partial<Model<"openai-completions">>;

@@ -17,7 +18,11 @@ function capturePayload(params: {

1718

return {} as ReturnType<StreamFn>;

1819

};

192020-

const wrapped = createQwenThinkingWrapper(baseStreamFn, params.thinkingLevel ?? "high");

21+

const wrapped = createQwenThinkingWrapper(

22+

baseStreamFn,

23+

params.thinkingLevel ?? "high",

24+

params.thinkingFormat,

25+

);

2126

void wrapped(

2227

{

2328

api: "openai-completions",

@@ -56,6 +61,37 @@ describe("createQwenThinkingWrapper", () => {

5661

expect(capturePayload({ thinkingLevel: "high" })).toEqual({ enable_thinking: true });

5762

});

586364+

it("overrides qwen-chat-template thinking with the session level", () => {

65+

expect(

66+

capturePayload({

67+

thinkingFormat: "qwen-chat-template",

68+

thinkingLevel: "off",

69+

initialPayload: {

70+

chat_template_kwargs: { enable_thinking: true, preserve_thinking: true },

71+

enable_thinking: true,

72+

reasoning_effort: "high",

73+

},

74+

}),

75+

).toEqual({

76+

chat_template_kwargs: { enable_thinking: false, preserve_thinking: true },

77+

});

78+

});

79+80+

it("uses the runtime model qwen-chat-template format when the wrapper context omits it", () => {

81+

expect(

82+

capturePayload({

83+

thinkingLevel: "off",

84+

model: { compat: { thinkingFormat: "qwen-chat-template" } },

85+

initialPayload: {

86+

chat_template_kwargs: { enable_thinking: true },

87+

enable_thinking: true,

88+

},

89+

}),

90+

).toEqual({

91+

chat_template_kwargs: { enable_thinking: false, preserve_thinking: true },

92+

});

93+

});

94+5995

it("skips non-reasoning and non-completions models", () => {

6096

expect(capturePayload({ model: { reasoning: false } })).toStrictEqual({});

6197

expect(capturePayload({ model: { api: "openai-responses" as never } })).toStrictEqual({});

@@ -64,19 +100,18 @@ describe("createQwenThinkingWrapper", () => {

6410065101

describe("wrapQwenProviderStream", () => {

66102

it("only registers for Qwen-family OpenAI-compatible providers", () => {

67-

expect(

68-

wrapQwenProviderStream({

69-

provider: "qwencloud",

70-

modelId: "qwen3.6-plus",

71-

model: {

72-

api: "openai-completions",

73-

provider: "qwen",

74-

id: "qwen3.6-plus",

75-

reasoning: true,

76-

} as Model<"openai-completions">,

77-

streamFn: undefined,

78-

} as never),

79-

).toBeTypeOf("function");

103+

const streamFn = wrapQwenProviderStream({

104+

provider: "qwencloud",

105+

modelId: "qwen3.6-plus",

106+

model: {

107+

api: "openai-completions",

108+

provider: "qwen",

109+

id: "qwen3.6-plus",

110+

reasoning: true,

111+

} as Model<"openai-completions">,

112+

streamFn: undefined,

113+

} as never);

114+

expect(streamFn).toBeTypeOf("function");

8011581116

expect(

82117

wrapQwenProviderStream({

@@ -91,4 +126,46 @@ describe("wrapQwenProviderStream", () => {

91126

} as never),

92127

).toBeUndefined();

93128

});

129+130+

it("passes qwen-chat-template format to the Qwen wrapper", () => {

131+

let captured: Record<string, unknown> = {};

132+

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

133+

const payload = {

134+

chat_template_kwargs: { enable_thinking: true },

135+

enable_thinking: true,

136+

};

137+

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

138+

captured = payload;

139+

return {} as ReturnType<StreamFn>;

140+

};

141+142+

const wrapped = wrapQwenProviderStream({

143+

provider: "qwen",

144+

modelId: "qwen3.6-plus",

145+

model: {

146+

api: "openai-completions",

147+

provider: "qwen",

148+

id: "qwen3.6-plus",

149+

reasoning: true,

150+

compat: { thinkingFormat: "qwen-chat-template" },

151+

} as Model<"openai-completions">,

152+

streamFn: baseStreamFn,

153+

thinkingLevel: "off",

154+

} as never);

155+156+

void wrapped?.(

157+

{

158+

api: "openai-completions",

159+

provider: "qwen",

160+

id: "qwen3.6-plus",

161+

reasoning: true,

162+

} as Model<"openai-completions">,

163+

{ messages: [] } as Context,

164+

{},

165+

);

166+167+

expect(captured).toStrictEqual({

168+

chat_template_kwargs: { enable_thinking: false, preserve_thinking: true },

169+

});

170+

});

94171

});