← Back to PRs

#20336: fix(sessions): resolve transcriptPath using agentId when storePath is non-absolute

by Limitless2023 open 2026-02-18 20:13 View on GitHub →
agents size: XS
## Problem When multiple agents are configured, `sessions.list` returns `"(multiple)"` as the `path` field (or a template string like `{agentId}/sessions.json`). The `sessions-list tool` then used `path.dirname(storePath)` to compute `sessionsDir`, which resolves to the process CWD (typically `~/.openclaw/workspace`) instead of the actual agent sessions directory (`~/.openclaw/agents/<id>/sessions`). This caused `transcriptPath` in every session's metadata to point to a file that does not exist, causing: - Dashboard lag/unresponsiveness due to repeated ENOENT errors when reading non-existent transcript files - Incorrect session metadata visible via `sessions_list` tool ## Root Cause ```ts // sessions-list-tool.ts (before) sessionsDir: path.dirname(storePath), // path.dirname("(multiple)") === "." → resolves to CWD ``` ## Fix Use `resolveSessionFilePathOptions()` instead of manually computing `path.dirname(storePath)`. The helper already handles the multi-agent case: when `storePath` is not a valid absolute file-system path, it falls back to `agentId`-based directory resolution, which correctly maps to `~/.openclaw/agents/<id>/sessions/`. ```ts // sessions-list-tool.ts (after) const effectiveStorePath = storePath && path.isAbsolute(storePath) ? storePath : undefined; const opts = resolveSessionFilePathOptions({ agentId, storePath: effectiveStorePath }); transcriptPath = resolveSessionFilePath(sessionId, sessionFile ? { sessionFile } : undefined, opts); ``` ## Affected configurations - Multi-agent setups (most common case) - Any config where `session.store` uses a template (e.g. `~/.openclaw/agents/{agentId}/sessions/sessions.json`) - Single-agent configs are unaffected (storePath is a real absolute path in that case) Fixes #20320 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR fixes `transcriptPath` resolution in the `sessions_list` tool for multi-agent configurations. Previously, when multiple agents were configured, the gateway returned `"(multiple)"` as the store path, and `path.dirname("(multiple)")` resolved to `"."` (current working directory), producing incorrect transcript file paths. This caused ENOENT errors and dashboard lag. The fix: - Removes the `storePath` truthiness requirement from the `if (sessionId)` guard, so transcript paths are resolved even when `storePath` is absent or invalid - Uses the existing `resolveSessionFilePathOptions()` helper instead of manual `path.dirname()`, which properly falls back to `agentId`-based directory resolution when `storePath` is not an absolute path - Adds a `path.isAbsolute()` check to only pass real filesystem paths to the resolver The change is well-scoped and uses existing infrastructure (`resolveSessionFilePathOptions`) rather than introducing new logic. Single-agent configs are unaffected since their `storePath` is always a valid absolute path. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it correctly fixes a real bug using existing helper infrastructure with no behavioral change for single-agent setups. - Score of 4 reflects a well-targeted bug fix that uses existing, tested helper functions (`resolveSessionFilePathOptions`) rather than introducing new logic. The change is small, the root cause is clearly identified, and single-agent configurations are unaffected. Deducted one point because there are no new unit tests covering the multi-agent `transcriptPath` resolution path. - No files require special attention. The single changed file (`src/agents/tools/sessions-list-tool.ts`) is straightforward. <sub>Last reviewed commit: a4673d0</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs