fix: propagate user cwd to subprocess environment (#136)

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

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,