Windows permissions issue: Codex agent cannot run pytest if tests write temp files
What version of Codex is running?
Latest extension for VS Code
What subscription do you have?
Plus
Which model were you using?
gpt-5.1-codex
What platform is your computer?
Windows 11
What terminal emulator and version are you using (if applicable)?
VS Code
What issue are you seeing?
Hi all — I’m running into a persistent issue with the OpenAI Codex extension in VS Code on Windows when using agent mode to run my Python test suite.
What I’m trying to do
I have an AGENTS.md instruction that asks Codex to run my pytest suite after changes (as part of a normal “edit -> run tests” workflow).
Some tests create temporary files/folders at runtime (e.g. writing small files, creating temp dirs, etc.).
The problem
When Codex agent tries to execute pytest, it hangs or fails due to drive permission issues when creating/writing temp files.
What’s confusing is:
If I run the same tests manually from VS Code (Test Explorer “Run All”) everything works normally.
The same repo and same tests have no issues when run manually.
What I tried (all failed)
Temp folder inside repo (e.g. ./tmp_test_artifacts/)
Temp folder under my user profile (e.g. %USERPROFILE%\tmp\...)
Creating a brand new temp folder for each run
Giving Codex explicit instructions to use a specific temp path
Ensuring folders exist beforehand
Codex still seems to hit permission issues (or gets stuck) when it runs the tests.
How Codex is running tests
From the Codex logs / terminal it appears to run something like:
conda run -n <env_name> python -m pytest
(sometimes via a shell wrapper depending on environment)
Expected behavior
Codex agent should be able to run pytest successfully, including tests that create temp files, same as when I run tests manually inside VS Code.
Questions
Is this a known issue with Codex agent execution context on Windows (permissions / sandboxing / different user)?
Is there a recommended temp directory strategy for Codex on Windows (e.g. force %TEMP%, tempfile.gettempdir(), etc.)?
Are there known settings / workarounds for:
Running Codex under a different shell (PowerShell vs cmd)
Forcing a different working directory
Ensuring permissions match normal VS Code test execution?
Happy to share more details (exact error output + minimal repro) if needed.
Thanks!
What steps can reproduce the bug?
Ask codex to run pytest suite where a test file needs to write a temp file to drive.
What is the expected behavior?
_No response_
Additional information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗