mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 21:11:26 +00:00
fix: align cron session key routing (#18637) (thanks @vignesh07)
This commit is contained in:
36
src/agents/tools/cron-tool.flat-params.test.ts
Normal file
36
src/agents/tools/cron-tool.flat-params.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const callGatewayMock = vi.fn();
|
||||
vi.mock("../../gateway/call.js", () => ({
|
||||
callGateway: (opts: unknown) => callGatewayMock(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../agent-scope.js", () => ({
|
||||
resolveSessionAgentId: () => "agent-123",
|
||||
}));
|
||||
|
||||
import { createCronTool } from "./cron-tool.js";
|
||||
|
||||
describe("cron tool flat-params", () => {
|
||||
beforeEach(() => {
|
||||
callGatewayMock.mockReset();
|
||||
callGatewayMock.mockResolvedValue({ ok: true });
|
||||
});
|
||||
|
||||
it("preserves explicit top-level sessionKey during flat-params recovery", async () => {
|
||||
const tool = createCronTool({ agentSessionKey: "agent:main:discord:channel:ops" });
|
||||
await tool.execute("call-flat-session-key", {
|
||||
action: "add",
|
||||
sessionKey: "agent:main:telegram:group:-100123:topic:99",
|
||||
schedule: { kind: "at", at: new Date(123).toISOString() },
|
||||
message: "do stuff",
|
||||
});
|
||||
|
||||
const call = callGatewayMock.mock.calls[0]?.[0] as {
|
||||
method?: string;
|
||||
params?: { sessionKey?: string };
|
||||
};
|
||||
expect(call.method).toBe("cron.add");
|
||||
expect(call.params?.sessionKey).toBe("agent:main:telegram:group:-100123:topic:99");
|
||||
});
|
||||
});
|
||||
@@ -299,6 +299,7 @@ Use jobId as the canonical identifier; id is accepted for compatibility. Use con
|
||||
"description",
|
||||
"deleteAfterRun",
|
||||
"agentId",
|
||||
"sessionKey",
|
||||
"message",
|
||||
"text",
|
||||
"model",
|
||||
|
||||
Reference in New Issue
Block a user