fix(sessions): set transcriptPath to agent sessions directory#24775
Conversation
88c836e to
309821b
Compare
|
Just rebased the PR to fix the conflicts. |
380561e to
e032b75
Compare
|
I just confirmed the bug is still reproducible on 2026.02.26 |
c18611d to
2325b87
Compare
|
While checking on this PR, I noticed another issue (#28379) that describes the same sessions_list transcriptPath symptom as #20320. This PR still contains additional edge-case handling and test coverage beyond what landed in c58d2aa. This PR (#24775) was originally opened to fix #20320. Could a maintainer please review this updated branch? |
2325b87 to
51d42c0
Compare
|
PR #24775 - fix(sessions): set transcriptPath to agent sessions directory (#24775) Merged via squash.
Thanks @martinfrancois! |
|
Correction: merge commit SHA is - 53d6e07 |
|
Thanks @Takhoffman for the quick review! 🎉 |
…aw#24775) thanks @martinfrancois Cherry-pick of upstream 53d6e07.
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#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>
…aw#24775) thanks @martinfrancois Cherry-pick of upstream 53d6e07.
…aw#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>
Summary
Describe the problem and fix in 2-5 bullets:
sessions_listcould computetranscriptPathfrom a non-concretesessions.list.path(for example"(multiple)", missing, non-string, relative, or template values), causing transcript paths to resolve underprocess.cwd()(often the workspace) instead of an agent sessions directory.transcriptPathvalues and missing transcripts even though the actual.jsonlfiles exist under the agent sessions directory.sessions_listnow resolves transcript paths viaresolveSessionFilePathOptions(...)+resolveSessionFilePath(...), and only uses the gatewaypathwhen it can be made concrete. Supported template paths ({agentId},~) are resolved per session agent viaresolveStorePath(...); non-concrete values fall back to agent defaults.sessions_listcomputes and reportstranscriptPath.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
sessions_listnow returns correcttranscriptPathvalues even when gatewaysessions.list.pathis:"(multiple)"{agentId}/~)Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
openai-codex/gpt-5.3-codex(Codex 5.3) for assistant/subagent worksessions_list)session.storeunset (gateway returnssessions.list.pathas"(multiple)")~/.openclaw/agents/main/sessions/Steps
sessions.list.pathis"(multiple)", open the chatExpected (after deploying this PR locally)
(sessionId can vary)
Actual (deployed instance with 2026.02.22-2)
(sessionId can vary)
Evidence
Attach at least one:
Failing test/log before + passing after
Targeted test command (same command for both runs)
✅ With fix (current HEAD)
❌ Without fix (temporary local revert)
Interpretation
Notes:
"(multiple)", missing/non-string/relativepath, and{agentId}template resolution.Human Verification (required)
What you personally verified (not just CI), and how:
sessions_listreturned a workspace path that did not exist, while the agent sessions transcript existed (see "Actual" example from above).sessions_listreturns canonical agent sessions transcript paths that exist on disk for existing sessions and for a freshly spawned session/subagent (see "Expected" example from above).sessions.list.path == "(multiple)"in a live gateway instance; other variants (missing/non-string/relative/template) covered by unit tests.Compatibility / Migration
Failure Recovery (if this breaks)
sessions_listbehavior.src/agents/tools/sessions-list-tool.tssrc/agents/tools/sessions.test.tssrc/config/sessions.test.tssessions_list.transcriptPathpoints under the workspace directorytranscriptPathisundefinedwhensessions.list.pathis absentRisks and Mitigations
pathvalues could still be misinterpreted as concrete, leading to incorrect transcript roots.{agentId},~) are explicitly resolved viaresolveStorePath(..., { agentId }); targeted regression tests cover observed variants ("(multiple)", missing/non-string/relative/template paths).AI-assisted implementation prompts + validation log excerpts
Context
This PR was developed and validated iteratively with AI assistance, with explicit human review and maintainer-style challenge loops.
1) Initial task constraints (human instructions to AI)
This drove the approach throughout.
2) Early regression work (first test pass)
Initial targeted regression tests added in
src/agents/tools/sessions.test.tsfor:sessions.list.path+ cross-agent keysessions.list.pathFail-proof (temporary local revert in
sessions-list-tool.ts):/home/git-projects/openclaw/agents/main/sessions/sess-worker.jsonl/tmp/openclaw-state-.../agents/worker/sessions/sess-worker.jsonltranscriptPath: undefined/tmp/openclaw-state-.../agents/worker/sessions/sess-worker-no-path.jsonlPass-proof (fix restored): tests passed.
3) Maintainer review loop and commit hygiene
A maintainer-style review flagged:
4) Live reproducibility check (deployed runtime validation) - before deploy
Issue was reproduced running the production build of
2026.2.22-2Concrete mismatch observed:
sessionId:7f51e0b4-057e-4b72-9cbf-b305312b2cacsessions_list:~/.openclaw/workspace/7f51e0b4-057e-4b72-9cbf-b305312b2cac.jsonl(missing)~/.openclaw/agents/main/sessions/7f51e0b4-057e-4b72-9cbf-b305312b2cac.jsonl(exists)Also observed similarly for:
dac61fcc-1e79-492a-be21-fec49cc50571This confirmed #20320 behavior in production-like runtime before applying the fix.
5) Deploy/restart + rollback discipline
A staged deploy plan was used:
/tmp/openclaw-global-backup-2026-02-23-175429.tgz)After restart with patched build:
openclaw@2026.2.23 -> /home/git-projects/openclawsessions_list.transcriptPathreturned canonical agent-session paths, not workspace paths.Concrete post-fix examples:
~/.openclaw/agents/main/sessions/09daf166-cdbc-45c1-8cae-8bb7ff722ba5.jsonl(exists)~/.openclaw/agents/main/sessions/7f51e0b4-057e-4b72-9cbf-b305312b2cac.jsonl(exists)6) Follow-up review comments and final hardening
Additional review comments were challenged and incorporated with maintainer judgment:
(multiple)regression test.{agentId}behavior.path.Greptile Summary
Fixed
sessions_listto compute correcttranscriptPathvalues when the gateway returns non-concretesessions.list.pathvalues (like"(multiple)", missing, non-string, or relative paths). Previously, these edge cases caused transcript paths to incorrectly resolve underprocess.cwd()instead of the agent sessions directory.resolveSessionFilePathOptions(...)andresolveSessionFilePath(...), and supports template paths like{agentId}and~throughresolveStorePath(...)"(multiple)", and{agentId}template pathsresolveSessionFilePathOptionsbehavior with explicitagentIdand store pathsConfidence Score: 5/5
resolveSessionFilePathOptionsremain compatible. The PR includes targeted regression tests that demonstrate the failure before the fix and success after.Last reviewed commit: dda7f0c
(2/5) Greptile learns from your feedback when you react with thumbs up/down!