feat #167: add --sandbox flag and CODEX_SANDBOX env var for review and task commands#226
feat #167: add --sandbox flag and CODEX_SANDBOX env var for review and task commands#226BryanBorck wants to merge 3 commits intoopenai:mainfrom
Conversation
…k commands (openai#167) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
72d41f1 to
9074d53
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9074d537ee
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| effort, | ||
| prompt, | ||
| write, | ||
| sandbox: options.sandbox, |
There was a problem hiding this comment.
Validate sandbox before enqueuing background tasks
The background branch in handleTask forwards options.sandbox into the stored job request without validating it, while validation only occurs later inside executeTaskRun via resolveSandbox. In environments where Codex is available, task --background --sandbox <invalid> will report a successful queue launch and then fail asynchronously in the worker, which is inconsistent with foreground behavior and gives users a misleading success response. Validate/normalize the sandbox value before calling enqueueBackgroundTask so invalid flags fail fast.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Closes #167
Problem
The plugin hardcodes
sandbox: "read-only"for reviews and tasks, with no override. On Linux hosts where Codex's bwrap sandbox can't initialize (Devbox, EC2, VPS kernels missingCAP_NET_ADMIN), every review fails:Setting
sandbox = "danger-full-access"in~/.codex/config.tomlhas no effect — the plugin explicitly overrides it per-thread. There is currently no way to fix this without patching plugin source files, which get overwritten on every update.Solution
Add a
resolveSandbox()helper that resolves sandbox mode from:--sandbox <mode>flag — per-call override (aliased as-s)CODEX_SANDBOXenv var — persistent override for sandboxed environments"read-only"for reviews,"workspace-write"when--writeis passed (unchanged behavior)Before
No way to override. Reviews fail silently in sandboxed environments.
After
One-time setup — add to
~/.zshrcor~/.bashrc:export CODEX_SANDBOX=danger-full-accessThen
/codex:reviewjust works.danger-full-accessis safe in these environments because the host is already externally sandboxed (Devbox, Docker, Claude Code's own sandbox on EC2).Or per-call:
Note on
~/.codex/config.tomlIdeally the plugin should read the
sandboxkey from~/.codex/config.toml, which the Codex CLI already respects for direct invocations. The plugin currently ignoresconfig.tomlentirely — it doesn't parse it for any setting. The env var approach in this PR is a pragmatic fix that doesn't require adding a TOML parser to a zero-dependency plugin, but properconfig.tomlsupport would be the right long-term solution.Changes
codex-companion.mjs: addedresolveSandbox(), wired--sandboxintohandleReviewCommand,handleTask,executeReviewRun,executeTaskRun, andbuildTaskRequestlib/codex.mjs:runAppServerReviewnow respectsoptions.sandboxinstead of hardcoding"read-only"Test plan
RTM_NEWADDR: Operation not permittedCODEX_SANDBOX=danger-full-access /codex:reviewcompletes end-to-endread-onlybehavior is unchanged