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

推荐订阅源

云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
小众软件
小众软件
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
Last Week in AI
Last Week in AI
博客园_首页
I
InfoQ
T
Tailwind CSS Blog
爱范儿
爱范儿
雷峰网
雷峰网
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
WordPress大学
WordPress大学
A
About on SuperTechFans
V
Visual Studio Blog
有赞技术团队
有赞技术团队
P
Proofpoint News Feed

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(gateway): resolve message actions against runtime con...
funmerlin · 2026-05-30 · via Recent Commits to openclaw:main

@@ -28,6 +28,8 @@ const mocks = vi.hoisted(() => ({

2828

getChannelPlugin: vi.fn(),

2929

loadOpenClawPlugins: vi.fn(),

3030

applyPluginAutoEnable: vi.fn(),

31+

getRuntimeConfigSnapshot: vi.fn(),

32+

getRuntimeConfigSourceSnapshot: vi.fn(),

3133

}));

32343335

vi.mock("../../config/config.js", async () => {

@@ -79,6 +81,17 @@ vi.mock("../../config/plugin-auto-enable.js", () => ({

7981

mocks.applyPluginAutoEnable({ config, env }),

8082

}));

818384+

vi.mock("../../config/runtime-snapshot.js", async () => {

85+

const actual = await vi.importActual<typeof import("../../config/runtime-snapshot.js")>(

86+

"../../config/runtime-snapshot.js",

87+

);

88+

return {

89+

...actual,

90+

getRuntimeConfigSnapshot: mocks.getRuntimeConfigSnapshot,

91+

getRuntimeConfigSourceSnapshot: mocks.getRuntimeConfigSourceSnapshot,

92+

};

93+

});

94+8295

vi.mock("../../plugins/loader.js", () => ({

8396

loadOpenClawPlugins: mocks.loadOpenClawPlugins,

8497

resolveRuntimePluginRegistry: vi.fn(),

@@ -280,6 +293,8 @@ describe("gateway send mirroring", () => {

280293

changes: [],

281294

autoEnabledReasons: {},

282295

}));

296+

mocks.getRuntimeConfigSnapshot.mockReturnValue(null);

297+

mocks.getRuntimeConfigSourceSnapshot.mockReturnValue(null);

283298

mocks.resolveOutboundTarget.mockReturnValue({ ok: true, to: "resolved" });

284299

mocks.resolveOutboundSessionRoute.mockImplementation(

285300

async ({ agentId, channel }: { agentId?: string; channel?: string }) => ({

@@ -303,6 +318,251 @@ describe("gateway send mirroring", () => {

303318

});

304319

});

305320321+

it("uses the resolved runtime config for message.action when the source snapshot matches", async () => {

322+

const sourceConfig = {

323+

channels: {

324+

discord: {

325+

accounts: {

326+

drclaw: {

327+

token: {

328+

source: "env",

329+

provider: "default",

330+

id: "DISCORD_BOT_TOKEN_DRCLAW",

331+

},

332+

},

333+

},

334+

},

335+

},

336+

};

337+

const runtimeConfig = {

338+

channels: {

339+

discord: {

340+

accounts: {

341+

drclaw: {

342+

token: "resolved-token",

343+

},

344+

},

345+

},

346+

},

347+

};

348+

mocks.applyPluginAutoEnable.mockImplementation(({ config }) => ({

349+

config,

350+

changes: [],

351+

autoEnabledReasons: {},

352+

}));

353+

mocks.getRuntimeConfigSnapshot.mockReturnValue(runtimeConfig);

354+

mocks.getRuntimeConfigSourceSnapshot.mockReturnValue(sourceConfig);

355+356+

const context = {

357+

...makeContext(),

358+

getRuntimeConfig: () => sourceConfig,

359+

} as unknown as GatewayRequestContext;

360+

const respond = vi.fn();

361+

await sendHandlers["message.action"]({

362+

params: {

363+

channel: "discord",

364+

action: "channel-info",

365+

params: { channelId: "123", accountId: "drclaw" },

366+

idempotencyKey: "idem-action-runtime-config",

367+

} as never,

368+

respond,

369+

context,

370+

req: { type: "req", id: "1", method: "message.action" },

371+

client: null as never,

372+

isWebchatConnect: () => false,

373+

});

374+375+

expect(mocks.getRuntimeConfigSnapshot).toHaveBeenCalledTimes(1);

376+

expect(mocks.getRuntimeConfigSourceSnapshot).toHaveBeenCalledTimes(1);

377+

expect(lastDispatchChannelMessageActionCall()?.cfg).toBe(runtimeConfig);

378+

const response = firstRespondCall(respond);

379+

expect(response?.[0]).toBe(true);

380+

});

381+382+

it("matches message.action runtime config against the canonical pre-auto-enable source config", async () => {

383+

const sourceConfig = {

384+

channels: {

385+

discord: {

386+

accounts: {

387+

drclaw: {

388+

token: {

389+

source: "env",

390+

provider: "default",

391+

id: "DISCORD_BOT_TOKEN_DRCLAW",

392+

},

393+

},

394+

},

395+

},

396+

},

397+

};

398+

const autoEnabledSourceConfig = {

399+

channels: {

400+

discord: {

401+

enabled: true,

402+

accounts: {

403+

drclaw: {

404+

token: {

405+

source: "env",

406+

provider: "default",

407+

id: "DISCORD_BOT_TOKEN_DRCLAW",

408+

},

409+

},

410+

},

411+

},

412+

},

413+

plugins: { allow: ["discord"] },

414+

};

415+

const autoEnabledRuntimeConfig = {

416+

channels: {

417+

discord: {

418+

enabled: true,

419+

accounts: {

420+

drclaw: {

421+

token: "resolved-token",

422+

},

423+

},

424+

},

425+

},

426+

plugins: { allow: ["discord"] },

427+

};

428+

mocks.applyPluginAutoEnable

429+

.mockReturnValueOnce({

430+

config: autoEnabledSourceConfig,

431+

changes: [{ path: "channels.discord.enabled", value: true }],

432+

autoEnabledReasons: {},

433+

})

434+

.mockReturnValueOnce({

435+

config: autoEnabledRuntimeConfig,

436+

changes: [{ path: "channels.discord.enabled", value: true }],

437+

autoEnabledReasons: {},

438+

});

439+

mocks.getRuntimeConfigSnapshot.mockReturnValue(autoEnabledRuntimeConfig);

440+

mocks.getRuntimeConfigSourceSnapshot.mockReturnValue(sourceConfig);

441+442+

const context = {

443+

...makeContext(),

444+

getRuntimeConfig: () => sourceConfig,

445+

} as unknown as GatewayRequestContext;

446+

const respond = vi.fn();

447+

await sendHandlers["message.action"]({

448+

params: {

449+

channel: "discord",

450+

action: "channel-info",

451+

params: { channelId: "123", accountId: "drclaw" },

452+

idempotencyKey: "idem-action-runtime-config-auto-enabled",

453+

} as never,

454+

respond,

455+

context,

456+

req: { type: "req", id: "1", method: "message.action" },

457+

client: null as never,

458+

isWebchatConnect: () => false,

459+

});

460+461+

expect(lastDispatchChannelMessageActionCall()?.cfg).toBe(autoEnabledRuntimeConfig);

462+

expect(mocks.applyPluginAutoEnable).toHaveBeenNthCalledWith(1, {

463+

config: sourceConfig,

464+

env: undefined,

465+

});

466+

expect(mocks.applyPluginAutoEnable).toHaveBeenNthCalledWith(2, {

467+

config: autoEnabledRuntimeConfig,

468+

env: undefined,

469+

});

470+

const response = firstRespondCall(respond);

471+

expect(response?.[0]).toBe(true);

472+

});

473+474+

it("keeps the post-auto-enable request config for message.action when the runtime source snapshot does not match", async () => {

475+

const sourceConfig = {

476+

channels: {

477+

discord: {

478+

accounts: {

479+

drclaw: {

480+

token: {

481+

source: "env",

482+

provider: "default",

483+

id: "DISCORD_BOT_TOKEN_DRCLAW",

484+

},

485+

},

486+

},

487+

},

488+

},

489+

};

490+

const autoEnabledRequestConfig = {

491+

channels: {

492+

discord: {

493+

enabled: true,

494+

accounts: {

495+

drclaw: {

496+

token: {

497+

source: "env",

498+

provider: "default",

499+

id: "DISCORD_BOT_TOKEN_DRCLAW",

500+

},

501+

},

502+

},

503+

},

504+

},

505+

plugins: { allow: ["discord"] },

506+

};

507+

mocks.applyPluginAutoEnable.mockReturnValue({

508+

config: autoEnabledRequestConfig,

509+

changes: [{ path: "channels.discord.enabled", value: true }],

510+

autoEnabledReasons: {},

511+

});

512+

mocks.getRuntimeConfigSnapshot.mockReturnValue({

513+

channels: {

514+

discord: {

515+

accounts: {

516+

drclaw: { token: "stale-runtime-token" },

517+

},

518+

},

519+

},

520+

});

521+

mocks.getRuntimeConfigSourceSnapshot.mockReturnValue({

522+

channels: {

523+

discord: {

524+

accounts: {

525+

other: { token: "different-source" },

526+

},

527+

},

528+

},

529+

});

530+531+

const context = {

532+

...makeContext(),

533+

getRuntimeConfig: () => sourceConfig,

534+

} as unknown as GatewayRequestContext;

535+

await sendHandlers["message.action"]({

536+

params: {

537+

channel: "discord",

538+

action: "channel-info",

539+

params: { channelId: "123", accountId: "drclaw" },

540+

idempotencyKey: "idem-action-stale-runtime-config",

541+

} as never,

542+

respond: vi.fn(),

543+

context,

544+

req: { type: "req", id: "1", method: "message.action" },

545+

client: null as never,

546+

isWebchatConnect: () => false,

547+

});

548+549+

expect(lastDispatchChannelMessageActionCall()?.cfg).toBe(autoEnabledRequestConfig);

550+

});

551+552+

it("does not read the runtime config snapshot for send requests", async () => {

553+

mockDeliverySuccess("m-no-runtime-config-read");

554+555+

await runSend({

556+

to: "channel:C1",

557+

message: "hi",

558+

channel: "slack",

559+

idempotencyKey: "idem-send-no-runtime-config-read",

560+

});

561+562+

expect(mocks.getRuntimeConfigSnapshot).not.toHaveBeenCalled();

563+

expect(mocks.getRuntimeConfigSourceSnapshot).not.toHaveBeenCalled();

564+

});

565+306566

it("dedupes concurrent message.action requests while inflight", async () => {

307567

const context = makeContext();

308568

const firstRespond = vi.fn();