fix(sessions): set transcriptPath to agent sessions directory (openclaw#24775) thanks @martinfrancois

Verified:
- pnpm build
- pnpm check
- pnpm test:macmini

Co-authored-by: martinfrancois <14319020+martinfrancois@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
François Martin
2026-03-01 16:41:06 +01:00
committed by GitHub
parent 0f36ee5a2e
commit 53d6e07a60
4 changed files with 242 additions and 11 deletions

View File

@@ -8,6 +8,7 @@ import {
deriveSessionKey,
loadSessionStore,
resolveSessionFilePath,
resolveSessionFilePathOptions,
resolveSessionKey,
resolveSessionTranscriptPath,
resolveSessionTranscriptsDir,
@@ -598,6 +599,31 @@ describe("sessions", () => {
});
});
it("resolveSessionFilePathOptions keeps explicit agentId alongside absolute store path", () => {
const storePath = "/tmp/openclaw/agents/main/sessions/sessions.json";
const resolved = resolveSessionFilePathOptions({
agentId: "bot2",
storePath,
});
expect(resolved?.agentId).toBe("bot2");
expect(resolved?.sessionsDir).toBe(path.dirname(path.resolve(storePath)));
});
it("resolves sibling agent absolute sessionFile using alternate agentId from options", () => {
const stateDir = path.resolve("/home/user/.openclaw");
withStateDir(stateDir, () => {
const mainStorePath = path.join(stateDir, "agents", "main", "sessions", "sessions.json");
const bot2Session = path.join(stateDir, "agents", "bot2", "sessions", "sess-1.jsonl");
const opts = resolveSessionFilePathOptions({
agentId: "bot2",
storePath: mainStorePath,
});
const sessionFile = resolveSessionFilePath("sess-1", { sessionFile: bot2Session }, opts);
expect(sessionFile).toBe(bot2Session);
});
});
it("falls back to derived transcript path when sessionFile is outside agent sessions directories", () => {
withStateDir(path.resolve("/home/user/.openclaw"), () => {
const sessionFile = resolveSessionFilePath(