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

@@ -1,6 +1,11 @@
import path from "node:path";
import { Type } from "@sinclair/typebox";
import { loadConfig } from "../../config/config.js";
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../../config/sessions.js";
import {
resolveSessionFilePath,
resolveSessionFilePathOptions,
resolveStorePath,
} from "../../config/sessions.js";
import { callGateway } from "../../gateway/call.js";
import { resolveAgentIdFromSessionKey } from "../../routing/session-key.js";
import type { AnyAgentTool } from "./common.js";
@@ -153,16 +158,26 @@ export function createSessionsListTool(opts?: {
const sessionFileRaw = (entry as { sessionFile?: unknown }).sessionFile;
const sessionFile = typeof sessionFileRaw === "string" ? sessionFileRaw : undefined;
let transcriptPath: string | undefined;
if (sessionId && storePath) {
if (sessionId) {
try {
const sessionPathOpts = resolveSessionFilePathOptions({
agentId: resolveAgentIdFromSessionKey(key),
storePath,
const agentId = resolveAgentIdFromSessionKey(key);
const trimmedStorePath = storePath?.trim();
let effectiveStorePath: string | undefined;
if (trimmedStorePath && trimmedStorePath !== "(multiple)") {
if (trimmedStorePath.includes("{agentId}") || trimmedStorePath.startsWith("~")) {
effectiveStorePath = resolveStorePath(trimmedStorePath, { agentId });
} else if (path.isAbsolute(trimmedStorePath)) {
effectiveStorePath = trimmedStorePath;
}
}
const filePathOpts = resolveSessionFilePathOptions({
agentId,
storePath: effectiveStorePath,
});
transcriptPath = resolveSessionFilePath(
sessionId,
sessionFile ? { sessionFile } : undefined,
sessionPathOpts,
filePathOpts,
);
} catch {
transcriptPath = undefined;