-
Notifications
You must be signed in to change notification settings - Fork 221
Change of CWD in loadSession not respected in read/write #512
Description
I create a new session specifying the project root directory that I want to use:
@agent-explorer/acp:dev: [acp-sessions] createAcpSession request {
@agent-explorer/acp:dev: "agentId": "claude-acp",
@agent-explorer/acp:dev: "projectId": "9583ae70-414c-4b19-bbd6-029a398aee6d",
@agent-explorer/acp:dev: "newSessionRequest": {
@agent-explorer/acp:dev: "cwd": "/Users/dmeehan/Documents/Projects/agent-explorer",
@agent-explorer/acp:dev: "mcpServers": []
@agent-explorer/acp:dev: }
@agent-explorer/acp:dev: }
If I then change the directory, here to a worktree specifically for the session:
@agent-explorer/acp:dev: 2026-04-06T19:31:10.621Z [acp:claude-acp] loadSession request: {"sessionId":"372a506a-f303-45dd-ac4c-bbe0aef95748","cwd":"/Users/dmeehan/.acp-explorer/projects/9583ae70-414c-4b19-bbd6-029a398aee6d/sessions/372a506a-f303-45dd-ac4c-bbe0aef95748/worktree","mcpServers":[]}
Subsequent tool uses use the project root instead of the CWD specified in the loadSession.
@agent-explorer/acp:dev: 2026-04-06T19:32:22.087Z [acp:session] update {"sessionId":"372a506a-f303-45dd-ac4c-bbe0aef95748","raw":{"_meta":{"claudeCode":{"toolName":"Edit"}},"content":[{"newText":" title: \"XXX\",","oldText":" title: \"ACP Explorer\",","path":"/Users/dmeehan/Documents/Projects/agent-explorer/apps/acp/src/app/layout.tsx","type":"diff"}],"kind":"edit","locations":[{"path":"/Users/dmeehan/Documents/Projects/agent-explorer/apps/acp/src/app/layout.tsx"}],"rawInput":{"replace_all":false,"file_path":"/Users/dmeehan/Documents/Projects/agent-explorer/apps/acp/src/app/layout.tsx","old_string":" title: \"ACP Explorer\",","new_string":" title: \"XXX\","},"title":"Edit apps/acp/src/app/layout.tsx","toolCallId":"toolu_016ndUNiSpBV29LH76Dddcyz","sessionUpdate":"tool_call_update"}}
I'm using the @agentclientprotocol/sdk Typescript SDK.
At least as I've planned my code, I can't store the CWD for changes (a git worktree) within a session specific directory (as the session ID is allocated by newSession where I have to specify the project root, before I can create a worktree).
I would have expected the CWD change to be respected on loadSession, as one would hope MCP servers changes are.
Looking at bash usage, these seem to use relative paths, and one assumes that the ACP sets the CWD appropriately before spawning, but that's a little harder to validate in a trivial example. If ask the ACP to use pwd to get the path, it reports the project root, not the CWD specified in the loadSession. It's not clear therefore how I can influence this across sessions when the ACP binary is spawned once.
As a workaround, I can allocate worktrees relative to the project ID, but it makes cleanup harder because they are not associated with the filesystem storage for other session data in my app.