fix(gateway): ensure agent:main:main in combined store when sessions.json missing
Add ensureMainSessionKey call to the combined-store path so agent:main:main is injected even when the store file does not exist yet. Add test covering the missing-store scenario reported in #45754.
This commit is contained in:
parent
5479a62726
commit
305ccc168a
@ -1085,4 +1085,28 @@ describe("listSessionsFromStore returns agent:main:main (#45754)", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test("agent:main:main included when sessions.json does not exist yet", async () => {
|
||||
await withStateDirEnv("openclaw-no-store-file-", async ({ stateDir }) => {
|
||||
const agentsDir = path.join(stateDir, "agents");
|
||||
const mainDir = path.join(agentsDir, "main", "sessions");
|
||||
// Create directory structure but do NOT create sessions.json
|
||||
fs.mkdirSync(mainDir, { recursive: true });
|
||||
|
||||
const cfg = {
|
||||
session: {
|
||||
mainKey: "main",
|
||||
store: path.join(stateDir, "agents", "{agentId}", "sessions", "sessions.json"),
|
||||
},
|
||||
agents: {
|
||||
list: [{ id: "main", default: true }],
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
const { store } = loadCombinedSessionStoreForGateway(cfg);
|
||||
|
||||
// agent:main:main must be present even when store file does not exist
|
||||
expect(store["agent:main:main"]).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -709,6 +709,7 @@ export function loadCombinedSessionStoreForGateway(cfg: OpenClawConfig): {
|
||||
canonicalKey,
|
||||
});
|
||||
}
|
||||
ensureMainSessionKey(cfg, combined);
|
||||
return { storePath, store: combined };
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user