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

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
I
InfoQ
D
Docker
F
Fortinet All Blogs
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
月光博客
月光博客
B
Blog
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
罗磊的独立博客
博客园_首页
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
IT之家
IT之家
V
V2EX

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(message-tool): normalize send body aliases (#84102) ·...
zhangguiping · 2026-05-23 · via Recent Commits to openclaw:main

@@ -1,4 +1,4 @@

1-

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

1+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

22

import type { OpenClawConfig } from "../../config/config.js";

33

import { setActivePluginRegistry } from "../../plugins/runtime.js";

44

import { createTestRegistry } from "../../test-utils/channel-plugins.js";

@@ -278,3 +278,119 @@ describe("runMessageAction send validation", () => {

278278

).rejects.toThrow(/use action "poll" instead of "send"/i);

279279

});

280280

});

281+282+

describe("message body alias normalization", () => {

283+

beforeEach(() => {

284+

setActivePluginRegistry(

285+

createTestRegistry([

286+

{

287+

pluginId: "workspace",

288+

source: "test",

289+

plugin: workspaceTestPlugin,

290+

},

291+

]),

292+

);

293+

});

294+295+

afterEach(() => {

296+

setActivePluginRegistry(createTestRegistry([]));

297+

vi.restoreAllMocks();

298+

});

299+300+

it.each([

301+

{ alias: "SendMessage", value: "hello from alias" },

302+

{ alias: "content", value: "hello from content" },

303+

{ alias: "text", value: "hello from text" },

304+

])("normalizes $alias alias to message for send", async ({ alias, value }) => {

305+

const result = await runDrySend({

306+

cfg: workspaceConfig,

307+

actionParams: {

308+

channel: "workspace",

309+

target: "#C12345678",

310+

[alias]: value,

311+

},

312+

toolContext: { currentChannelId: "C12345678" },

313+

});

314+315+

expect(result.kind).toBe("send");

316+

});

317+318+

it("does not overwrite an explicit message with an alias", async () => {

319+

const result = await runDrySend({

320+

cfg: workspaceConfig,

321+

actionParams: {

322+

channel: "workspace",

323+

target: "#C12345678",

324+

message: "explicit",

325+

SendMessage: "alias value",

326+

},

327+

toolContext: { currentChannelId: "C12345678" },

328+

});

329+330+

expect(result.kind).toBe("send");

331+

});

332+333+

it("emits a diagnostic warning when normalizing an alias", async () => {

334+

const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});

335+336+

await runDrySend({

337+

cfg: workspaceConfig,

338+

actionParams: {

339+

channel: "workspace",

340+

target: "#C12345678",

341+

SendMessage: "alias body",

342+

},

343+

toolContext: { currentChannelId: "C12345678" },

344+

});

345+346+

expect(warnSpy).toHaveBeenCalledWith(

347+

expect.stringContaining('[message-tool] normalized alias "SendMessage" to "message"'),

348+

);

349+

});

350+351+

it.each([

352+

{

353+

name: "reasoning tag",

354+

SendMessage: "<think>internal reasoning</think>Visible answer",

355+

},

356+

{

357+

name: "formatted reasoning prefix",

358+

SendMessage: "Reasoning:\n_internal plan_\n\nVisible answer",

359+

},

360+

])("sanitizes SendMessage alias $name before delivery", async ({ SendMessage }) => {

361+

const result = await runMessageAction({

362+

cfg: emptyConfig,

363+

action: "send",

364+

params: {

365+

SendMessage,

366+

},

367+

toolContext: {

368+

currentChannelProvider: "webchat",

369+

},

370+

sessionKey: "agent:main",

371+

sourceReplyDeliveryMode: "message_tool_only",

372+

});

373+374+

expect(result).toMatchObject({

375+

kind: "send",

376+

payload: {

377+

sourceReply: {

378+

text: "Visible answer",

379+

},

380+

},

381+

});

382+

});

383+384+

it("still rejects send with no message and no alias", async () => {

385+

await expect(

386+

runDrySend({

387+

cfg: workspaceConfig,

388+

actionParams: {

389+

channel: "workspace",

390+

target: "#C12345678",

391+

},

392+

toolContext: { currentChannelId: "C12345678" },

393+

}),

394+

).rejects.toThrow(/message required/i);

395+

});

396+

});