Repository navigation
fix(codex): approve installed MCP servers under the local sandbox - #362
Merged
Merged
Conversation
karanb192
requested review from
JHWang-1997,
hittyt and
zpzjzj
as code owners
November 1, 2026 15:38
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2864392c31
ℹ️ 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".
This was referenced Nov 1, 2026
On the none runtime Codex runs with --sandbox workspace-write and the exec approval policy "never", so it rejected every call to an MCP server skill-up installed: "MCP tool call requires approval, but approval policy is never". Record the servers InstallMCP added and pass -c mcp_servers.<name>.default_tools_approval_mode="approve" for each on the first-turn command when the process sandbox is used. The sandbox stays on, and servers from the user's own Codex config are not approved. Names a dotted -c path cannot address are skipped with a warning, since Codex would fail to load its config. Closes alibaba#358
Cases share one CodexAgent and run concurrently, so a single set of installed server names leaked approval overrides into other cases. Keep the set per runtime workspace, replace it on every install, and test the shared-agent pattern. Document the server-name restriction.
karanb192
force-pushed
the
fix/codex-mcp-approval
branch
from
November 3, 2026 06:13
2864392 to
53af207
Compare
zpzjzj
approved these changes
Nov 3, 2026
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the
noneruntime, skill-up runs the first Codex turn with--sandbox workspace-write. With Codex CLI 0.166.0, the #358 repro rejects the installed mock's tool call withMCP tool call requires approval, but approval policy is never.This PR approves tool calls for the installed server names with a per-server Codex config override on the run command. The sandbox stays on. Other server names receive no override.
Related issues
Closes #358
Changes
internal/agent/codex.go:InstallMCPrecords the names of the servers it installed, keyed by the runtime's workspace. Cases share one agent and run concurrently, so each case keeps its own set (replaced on every install, emptied when a case installs none), guarded by a mutex.Runuses the process sandbox (thenoneruntime withoutbypass_sandbox), it adds-c 'mcp_servers.<name>.default_tools_approval_mode="approve"'for each server recorded for its workspace. Runs that already bypass approvals (Docker, OpenSandbox,bypass_sandbox: "true", and the resume path) are unchanged.-cpath cannot address (anything outside^[A-Za-z0-9_-]+$) is skipped with a warning. Codex fails to load its config for such an override.internal/agent/codex_test.go:--sandbox workspace-write, and never carry a dotted name;shop, thendocs, then nothing; each run approves only the latest set;bypass_sandbox, OpenSandbox) get no override.docs/guide/writing-evals.md: thebypass_sandboxrow forcodexnow says installed MCP servers are approved under the defaultnonesandbox, and names the server-name restriction.CHANGELOG.md: one line under Unreleased, Fixed.Test plan
make testpassesmake verifypasses with zero findings on the rebased head.go test -tags e2e ./e2epasses on the rebased head, with agent CLIs absent from PATH.-race.codex exec --sandbox workspace-write: the same MCP call fails without the override and completes with it, nothing else changed.environment.type: none, nobypass_sandbox, existing login): themcp_tool_callcompleted and the answer contained the mocked status, with the session's sandbox policy stillworkspace-write. That run scored 50% becausetool_calledmissed the call. The transcript fix from fix(codex): keep code-tool calls in session transcripts #361 is now in the base; I have not repeated the live Codex repro after rebasing.Notes for reviewers
noneruntime. A same-named server installed by another case can replace the definition before execution. The approval sets are per workspace; the installed definitions are not. The isolation design remains open in bug(codex): mocked MCP servers are written into the user's global ~/.codex/config.toml and left there #360 and the review thread on this PR.config.toml(ascodex mcp addwrites it): it merges, and the server keeps its transport. An override for a server that is not in the config would create a server with no transport and stop Codex from loading, so only installed servers get one.RawMcpServerConfigdoes not deny unknown fields, so the extra key is ignored there. I did not run 0.80.0.default_tools_approval_mode = "approve"approves every tool of that server, including ones a real server marks as destructive. For servers skill-up installs for an eval that matches what the Docker and OpenSandbox runtimes already allow.