#10185: fix: pass effective workspace as cwd to Pi SDK createAgentSession
agents
stale
Cluster:
Workspace Path Fixes
## Summary
- In sandbox mode, `createAgentSession()` received `resolvedWorkspace` (the original user workspace) instead of `effectiveWorkspace` (the sandbox directory)
- The process had already `chdir`'d into `effectiveWorkspace` (line 166), but the Pi SDK session was initialized with the wrong `cwd`, causing a mismatch
- One-line fix: pass `effectiveWorkspace` instead of `resolvedWorkspace` to `createAgentSession`
Closes #10136
## Test plan
- [x] Verified `effectiveWorkspace` is correctly computed at lines 158-162 based on sandbox state
- [x] Confirmed `process.chdir(effectiveWorkspace)` already uses the correct value (line 166)
- [x] The fix aligns `createAgentSession` cwd with the actual process working directory
🤖 Generated with [Claude Code](https://claude.ai/code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes a sandbox/workspace mismatch in the Pi embedded runner by passing `effectiveWorkspace` (the sandboxed directory when applicable) as the `cwd` to `createAgentSession()`, aligning the SDK session’s working directory with the process `chdir` and the rest of the runner’s workspace usage.
Change is localized to `src/agents/pi-embedded-runner/run/attempt.ts` within `runEmbeddedAttempt()` where the Pi SDK session is created.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a one-line swap from `resolvedWorkspace` to `effectiveWorkspace` at the Pi SDK session initialization, matching the already-applied `process.chdir(effectiveWorkspace)` and other code paths that consistently use `effectiveWorkspace` for workspace operations. No new logic branches or external side effects were introduced.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17757: fix(agents): resolve relative workspace paths against state dir, no...
by Phineas1500 · 2026-02-16
79.3%
#16922: fix: remove incorrect sandbox file tool guidance
by carrotRakko · 2026-02-15
78.9%
#22917: fix: Use agent's configured workspace when spawned as subagent
by jriff · 2026-02-21
78.9%
#4226: Fix/sandbox containerworkdir rw access
by ozgur-polat · 2026-01-29
78.2%
#19344: fix(sandbox): allow writes when workspaceAccess is 'none'
by mingming099 · 2026-02-17
77.0%
#3967: fix(sandbox): correct workspace prompt path
by sweepies · 2026-01-29
77.0%
#18914: fix: use per-session workspaceDir instead of process.cwd() for post...
by irchelper · 2026-02-17
77.0%
#12174: fix(agents): add path containment check in apply_patch for non-sand...
by coygeek · 2026-02-08
76.3%
#20851: fix: harden resolveUserPath and compact against undefined workspaceDir
by davidrudduck · 2026-02-19
75.8%
#20991: fix(sandbox): fall back to gateway UID:GID when no user is configur...
by cluster2600 · 2026-02-19
75.6%