Extend sandbox policy to support MPS

Resolved 💬 3 comments Opened Jan 9, 2026 by taralloc Closed Mar 29, 2026

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

  1. 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

  1. 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

  1. 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗