fix: pass agentId to resolveSessionFilePath for multi-agent path validation#15103
Closed
jalehman wants to merge 1 commit into
Closed
fix: pass agentId to resolveSessionFilePath for multi-agent path validation#15103jalehman wants to merge 1 commit into
jalehman wants to merge 1 commit into
Conversation
jalehman
force-pushed
the
fix/session-file-path-agent-id
branch
from
February 13, 2026 01:36
ee26f95 to
7e808d3
Compare
Contributor
|
Closing per maintainer direction. What was completed locally:
Local commits (not pushed from this environment):
Credit: thanks @jalehman for the original contribution and fix direction. |
Contributor
|
Closing per maintainer direction after documenting local rebase+test work and credit. |
steipete
added a commit
that referenced
this pull request
Feb 13, 2026
Co-authored-by: Josh Lehman <[email protected]>
steipete
added a commit
that referenced
this pull request
Feb 13, 2026
Co-authored-by: Josh Lehman <[email protected]>
skyhawk14
pushed a commit
to skyhawk14/openclaw
that referenced
this pull request
Feb 13, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
GwonHyeok
pushed a commit
to learners-superpumped/openclaw
that referenced
this pull request
Feb 15, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
This was referenced Feb 17, 2026
6 tasks
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 1, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9904135) # Conflicts: # CHANGELOG.md # src/auto-reply/status.test.ts # src/auto-reply/status.ts
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 3, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]> (cherry picked from commit 9904135) # Conflicts: # CHANGELOG.md # src/auto-reply/status.ts # src/infra/session-cost-usage.test.ts # src/infra/session-cost-usage.ts
lovewanwan
pushed a commit
to lovewanwan/openclaw
that referenced
this pull request
Apr 28, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
ogt-redknie
pushed a commit
to ogt-redknie/OPENX
that referenced
this pull request
May 2, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
May 9, 2026
…openclaw#15448) Co-authored-by: Josh Lehman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Non-main agents crash when running
/compactor hitting other session file resolution paths:Root Cause
resolveSessionFilePath()takes an optionalopts.agentIdto determine which agent's sessions directory to validate against. Multiple callers omit this parameter, so it defaults to themainagent's sessions dir.When a non-main agent has an absolute
sessionFilepath in its session store (e.g.~/.openclaw/agents/other-agent/sessions/xxx.jsonl), the path validation inresolvePathWithinSessionsDir()computes a relative path from the main agent's dir — which starts with../..— and rejects it as directory traversal.Introduced by
Commit
4199f9889(fix: harden session transcript path resolution) addedresolvePathWithinSessionsDiras a security hardening measure for path traversal prevention. It updatedresolveSessionFilePathto validate thesessionFilecandidate against the sessions directory, but only updated some callers (gateway, subagent-announce, transcript) to passagentId— missing the auto-reply paths (commands-compact,get-reply-run,status,session-cost-usage, etc.).Before that commit,
resolveSessionFilePathreturnedentry.sessionFileas-is with no validation, so the missingagentIdwas harmless.Fix
Pass
agentIdto all call sites ofresolveSessionFilePath()that were missing it:commands-compact.ts— the immediate crash site (/compactcommand)get-reply-run.ts— main reply pathsession.ts— session fork/initstatus.ts—/statustranscript usage readingcommands-status.ts— status commandcommands-session.ts—/usagecommandsession-status-tool.ts— agent session status toolsession-cost-usage.ts— cost summary, time series, and log loading (3 call sites)usage.ts(gateway) — usage API handlers (3 call sites)All patched callers already had
agentIdavailable in their scope/params.Testing
pnpm buildsucceedsmain), non-main agents now resolve paths against their own sessions directoryGreptile Overview
Greptile Summary
This PR fixes multi-agent session transcript path validation by consistently passing
agentIdtoresolveSessionFilePath()at call sites that resolve/validate a session’s transcript path.The underlying issue is that
resolveSessionFilePath()validatesentry.sessionFileagainst an agent-scoped sessions directory; if callers omitopts.agentId, it defaults to the main agent’s sessions dir and rejects non-main agents’ absolute stored paths as traversal. The updates in:/compact,/status,/usage)ensure that non-main agents validate and resolve against their own sessions directory while leaving main-agent behavior unchanged (default remains
main).Confidence Score: 5/5
agentIdthrough toresolveSessionFilePath()and related usage loaders. Verified thatresolveSessionFilePathusesagentIdto select the correct agent sessions directory for validation, and that gateway session keys are canonicalized withagent:<agentId>:so the newagentIdderivation is stable.Last reviewed commit: ee26f95
Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)