fix: propagate user cwd to subprocess environment (#136)
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled

The subprocess transport was ignoring user-specified cwd from
ClaudeCodeOptions, causing the working directory preference to be
overridden by os.environ. This fix ensures the CWD environment variable
is properly passed to child processes.

- Add PWD env var when self._cwd is set in SubprocessCLITransport
- Fixes issue where custom working directory was not respected
- Maintains backward compatibility

Tests: All existing tests pass
This commit is contained in:
Anudeep Yegireddi 2025-08-29 22:36:52 -07:00 committed by GitHub
parent ea7e86714f
commit 9a64bc3a64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,6 +182,9 @@ class SubprocessCLITransport(Transport):
"CLAUDE_CODE_ENTRYPOINT": "sdk-py",
}
if self._cwd:
process_env["PWD"] = self._cwd
self._process = await anyio.open_process(
cmd,
stdin=PIPE,