mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:41:25 +00:00
fix: run BOOT.md for each configured agent at startup (#20569)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 9098a4cc64
Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -9,7 +9,7 @@ const agentCommand = vi.fn();
|
||||
vi.mock("../commands/agent.js", () => ({ agentCommand }));
|
||||
|
||||
const { runBootOnce } = await import("./boot.js");
|
||||
const { resolveAgentIdFromSessionKey, resolveMainSessionKey } =
|
||||
const { resolveAgentIdFromSessionKey, resolveAgentMainSessionKey, resolveMainSessionKey } =
|
||||
await import("../config/sessions/main-session.js");
|
||||
const { resolveStorePath } = await import("../config/sessions/paths.js");
|
||||
const { loadSessionStore, saveSessionStore } = await import("../config/sessions/store.js");
|
||||
@@ -99,6 +99,24 @@ describe("runBootOnce", () => {
|
||||
await fs.rm(workspaceDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("uses per-agent session key when agentId is provided", async () => {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-boot-"));
|
||||
await fs.writeFile(path.join(workspaceDir, "BOOT.md"), "Check status.", "utf-8");
|
||||
|
||||
agentCommand.mockResolvedValue(undefined);
|
||||
const cfg = {};
|
||||
const agentId = "ops";
|
||||
await expect(runBootOnce({ cfg, deps: makeDeps(), workspaceDir, agentId })).resolves.toEqual({
|
||||
status: "ran",
|
||||
});
|
||||
|
||||
expect(agentCommand).toHaveBeenCalledTimes(1);
|
||||
const perAgentCall = agentCommand.mock.calls[0]?.[0];
|
||||
expect(perAgentCall?.sessionKey).toBe(resolveAgentMainSessionKey({ cfg, agentId }));
|
||||
|
||||
await fs.rm(workspaceDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("generates new session ID when no existing session exists", async () => {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-boot-"));
|
||||
const content = "Say hello when you wake up.";
|
||||
|
||||
Reference in New Issue
Block a user