Rules: Extend it to configure sandbox_policy
Open 💬 14 comments Opened Feb 20, 2026 by amit-mittal
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What variant of Codex are you using?
CLI
What feature would you like to see?
I want some commands to always run outside codex sandbox since inside the sandbox, they _sometimes_ fail. If we can extend the rules to be able to configure that part, it would be great.
Currently, one way to work around is to use some other shell MCP server, but using that for just one CLI and not others seem like an overkill.
Additional information
bazel is an example tool that starts server and many a times, it fails in sandbox with failed to bind to socket or failing to write to /var/tmp directory (I guess this would be another type of issue).
14 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
You should be able to do this with the existing rules engine. Specify "allow" for the decision field. This tells the engine to run the command outside of the sandbox. For details, refer to this documentation.
Oh, that's interesting! Thanks @etraut-openai, we already had configured
allowfor some of thebazelcommands and they would still occasionally fail. I will investigate more on our side.Does running outside sandbox would also give
bazelby default access to write to/var/tmp?When you run outside the sandbox, your normal user permission checks should apply, so yes, it should have access to
/var/tmp.Even though I have below rules:
codexfailed with:Is there anything that I can share, so it can be reproed on your side?
To add I think sometimes codex chose to run commands that are composed (or extra SHELL script constructs) and not just direct
bazel build. In that case, maybe it will run the full command in sandbox and run into this issue?If you want to do some additional diagnosis, you could clone the codex repo and ask codex to diagnose the issue.
@etraut-openai I think I know what's happening now:
rulesconfigured, a subset ofbazelcommand runs outside sandbox. This means many-a-times, it will just work without any issues.codextry running small shell snippets invlovingbazel, codex would treat them as bash scripts and run them inside sandbox where it won't be able to discoverbazelserver running outside the sandbox.bazelserver insidesandboxor it will try to skip the sandbox.bazelserver again. I don't know yet why this might occur unlessbazelis getting switched on/off sandbox.Since I see
codexis itself trying to migrate tobazel's build system, are you running into the issue? I can runcodexwith--sandbox=danger-full-access, but that would disable sandbox for all the tools and not justbazel. Is there no way to selectively disable sandboxing or allow network just forbazelin sandbox whenever it is invoked from any script?Yeah, your diagnosis sounds quite plausible.
No, there's unfortunately no way to selectively run
bazelin a sandbox when it's invoked from an arbitrary script. The script is either running in the sandbox or it's not.Is there a way to use new multi-agent workflow to have a subagent just do
bazeloperations outside sandbox?I think that subagents work under the same sandbox settings as the parent agent.
Here's an idea... you could encapsulate it as an MCP server. MCP servers run outside of the sandbox.
I did consider that, but IIUC
bazelMCP server will only be used for nativebazelcommands and if there is a little involved shell snippet, it would still run outside sandbox. If I use some shell MCP directly, that would basically be same assandbox_mode = danger-full-access.Also, MCP output might end up polluting the context, which running CLIs natively might help avoid.
In the doc, it was suggesting that sandbox_mode can be overridden to read-only, so I was assuming you can give full access to one of the subagent too. Maybe not.
That feature is still evolving, and I haven't been watching it that closely this past week. You may be right.
Thanks, Eric! Appreciate the discussion with me to find solution to this issue 😄. I will update this thread if I find some solution to my problem and will also be tracking the release notes.