Skip to content

Respect Codex sandbox config in plugin threads#241

Open
msl2246 wants to merge 1 commit intoopenai:mainfrom
msl2246:fix/inherit-codex-sandbox-config
Open

Respect Codex sandbox config in plugin threads#241
msl2246 wants to merge 1 commit intoopenai:mainfrom
msl2246:fix/inherit-codex-sandbox-config

Conversation

@msl2246
Copy link
Copy Markdown

@msl2246 msl2246 commented Apr 18, 2026

Summary

Fixes #240.

The plugin previously had no escape hatch for environments where Codex's Linux sandbox cannot initialize. At the same time, review commands need to keep their documented read-only contract and task --write needs to request a writable sandbox by default.

This change keeps the existing safe defaults:

  • native review uses read-only
  • adversarial review uses read-only
  • read-only task runs use read-only
  • task --write uses workspace-write

It adds an explicit CODEX_COMPANION_SANDBOX_MODE override for plugin-launched Codex threads. Setting it to inherit omits the sandbox field so the Codex app server applies the user's configured sandbox_mode; it also accepts read-only, workspace-write, and danger-full-access for explicit forcing.

The rescue agent and codex-cli-runtime skill now document when to preserve or apply that override, so Claude Code can route bwrap/bubblewrap sandbox failures through the same single helper command.

Testing

  • npm test
  • node --test tests/commands.test.mjs
  • node --check plugins/codex/scripts/codex-companion.mjs
  • node --check plugins/codex/scripts/lib/codex.mjs
  • git diff --check

Notes

Also updates the existing result/cancel command test expectations to match the currently quoted $ARGUMENTS command text.

@msl2246 msl2246 requested a review from a team April 18, 2026 06:57
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e0a1e31c73

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 408 to 412
const result = await runAppServerTurn(context.repoRoot, {
prompt,
model: request.model,
sandbox: "read-only",
outputSchema: readOutputSchema(REVIEW_SCHEMA),
onProgress: request.onProgress
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep adversarial review threads in read-only sandbox

This call no longer pins a sandbox mode for adversarial reviews, so /codex:adversarial-review now inherits the user's global Codex sandbox. In environments configured as workspace-write or danger-full-access, the review turn can run with write-capable tooling and mutate the repo, which breaks the command’s documented read-only contract (README.md says adversarial review "does not fix code"). Please keep review flows explicitly read-only (or otherwise enforce read-only behavior independent of global task defaults).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 56cb002. Native and adversarial review flows now keep the default read-only sandbox, preserving the documented review-only contract. The Codex-config inheritance path is now explicit via CODEX_COMPANION_SANDBOX_MODE=inherit, with README and regression coverage for the opt-in behavior.

Comment on lines 484 to 486
defaultPrompt: resumeThreadId ? DEFAULT_CONTINUE_PROMPT : "",
model: request.model,
effort: request.effort,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use --write flag to request writable task sandbox

executeTaskRun no longer maps request.write into the thread sandbox request, so task --write and read-only task runs now send the same sandbox params unless some external caller injects one. For users whose Codex config is read-only, --write silently loses its functional effect and rescue workflows that depend on write-capable runs will be unable to apply edits.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 56cb002. task --write now defaults back to workspace-write, while read-only task runs default to read-only. The only way to omit/override that sandbox request is the new explicit CODEX_COMPANION_SANDBOX_MODE escape hatch, so --write keeps its functional effect for users with read-only Codex defaults.

@msl2246 msl2246 force-pushed the fix/inherit-codex-sandbox-config branch from e0a1e31 to 56cb002 Compare April 18, 2026 07:07
@msl2246
Copy link
Copy Markdown
Author

msl2246 commented Apr 18, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@msl2246 msl2246 force-pushed the fix/inherit-codex-sandbox-config branch from 56cb002 to f89b868 Compare April 18, 2026 07:14
@msl2246
Copy link
Copy Markdown
Author

msl2246 commented Apr 18, 2026

Follow-up for the rescue path: I added the same sandbox escape-hatch guidance to the codex-rescue agent and codex-cli-runtime skill docs. If a user reports bwrap/bubblewrap/Linux sandbox failures, the rescue forwarder now has explicit instructions to keep the single helper call but prefix it with CODEX_COMPANION_SANDBOX_MODE=inherit; existing environment values are preserved. Added command-doc assertions and reran npm test (91 passed).

@msl2246
Copy link
Copy Markdown
Author

msl2246 commented Apr 18, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin overrides Codex sandbox config and can trigger bwrap failures

1 participant