Extend sandbox policy to support MPS
What version of Codex is running?
0.80.0
What subscription do you have?
Plus
Which model were you using?
gpt-5.2
What platform is your computer?
Darwin 23.5.0 arm64 arm
What issue are you seeing?
TL;DR: in Pytorch, the MPS device cannot be used within codex.
In Codex’s tool session (shell commands executed by the agent), torch.backends.mps.is_available() is False and MPS allocation fails, even though the exact same conda env + torch version returns True when run in my own terminal.
Environment
- Codex CLI: codex-cli 0.80.0
- MacBook Air (Apple M3), 16GB
- macOS 14.5
- Conda env: myenv - Python 3.13.2
- PyTorch 2.9.1 (MPS built)
Repro steps
- In user terminal (works):
bash -lc "conda activate myenv && which python && python -V && python -c \"import torch; print('torch', torch.__version__); print('mps',
torch.backends.mps.is_available())\""
Output:
/Users/me/miniconda3/envs/myenv/bin/python
Python 3.13.2
torch 2.9.1
mps True
- In Codex tool session (fails):
conda activate myenv && python -c "import torch; print(torch.backends.mps.is_available()); x=torch.randn(1, device='mps')"
Output:
False
RuntimeError: The MPS backend is supported on MacOS 14.0+. Current OS version can be queried using sw_vers
- conda run also fails in Codex tool session:
conda run -n myenv python -c "import torch; print('mps', torch.backends.mps.is_available())"
Output:
mps False
Expected behavior
MPS should be available in Codex tool session just as in the user’s terminal when using the same conda env and torch build.
Actual behavior
MPS is unavailable and allocating on device='mps' throws a runtime error, despite macOS 14.5 and Metal supported.
Additional context
- torch.backends.mps.is_built() returns True in Codex session
- system_profiler SPDisplaysDataType shows Apple M3 GPU + Metal supported
- sw_vers reports macOS 14.5
What steps can reproduce the bug?
See above
What is the expected behavior?
_No response_
Additional information
_No response_
3 Comments
Seeing the same issue with the new Codex macOS app when running in sandbox
This feature request hasn't received enough upvotes, so I'm closing it.
I'm having this same issue. I can run the same code manually in macOS Terminal and MPS is available but if Codex runs it then MPS is not available.
Update: just found out it's because of the sandbox, and runs fine outside of that if prompted. Here's another related ticket in case its useful for anyone else: https://github.com/pytorch/pytorch/issues/177819