Repository navigation
Description
sbx up wires Claude Code and OpenCode. Codex CLI (openai/codex) is the obvious third: it speaks MCP over stdio, it reads AGENTS.md — which up already writes — and it has a project-local config file, so the configuration would stay an uncommitted working-tree file like the others.
moca already assumes Codex elsewhere (skills/moca-delegate-task/README.md documents $moca-delegate-task in Codex; docs/concepts/context-workflows.md names it alongside Claude Code, OpenCode and Pi), so this would close a gap between sbx and the rest of the project rather than add a new dependency.
There is one real asymmetry, in §"Containment" below: Codex has no documented per-tool deny list, so the isolation would be best-effort rather than the guarantee up makes for Claude Code. That is the decision this issue is really asking for.
What up would write
| Claude Code (today) | Codex (proposed) |
|---|---|
.mcp.json → mcpServers.sandbox |
.codex/config.toml → [mcp_servers.sandbox] |
.claude/settings.json → permissions.deny: [Bash, Read, Edit, Write, …] |
features.shell_tool = false, web_search = "disabled", default_permissions = ":read-only" |
CLAUDE.md / AGENTS.md sbx block |
AGENTS.md — already written, read natively |
Sketch of the server entry:
[mcp_servers.sandbox]
command = "mocactl"
args = ["sbx", "mcp"]The MCP server already exposes a complete toolset — bash, read, write, edit, grep, find, ls, sandbox_info (packages/sandbox-client/src/tools.ts) — so Codex loses no capability by having its local tools off. The same mocactl sbx mcp process serves it; no server-side change.
AGENTS.md is the nice part: up writes the <!-- sbx:begin --> block there already, and Codex reads AGENTS.md from the git root downward (32 KiB cap by default, project_doc_max_bytes). The steering comes free.
Containment: weaker than Claude Code's, and worth deciding deliberately
Claude Code takes an explicit per-tool deny list, which is what lets up state that every local built-in is denied. Codex has no documented equivalent. The closest is layering:
features.shell_tool = false # command execution off
web_search = "disabled"
default_permissions = ":read-only"
features.apps = false
tools.view_image = falseWhat I could not establish from OpenAI's documentation:
- Whether that combination leaves only MCP tools reachable, or whether other built-ins remain. There is no documented "MCP-only" mode.
- Whether
mcp_servers.*is honoured in project-local.codex/config.toml. The config reference lists keys that are ignored there (openai_base_url,model_provider(s),notify,profile(s),otel) andmcp_serversis not among them — suggestive, not confirmed. - Whether
apply_patchexists as a built-in and, if so, how to disable it.
So the honest framing is best-effort denial, and docs/sbx/user-guide.md §4 plus SBX0 §6.3 would need to say so rather than implying parity. If that does not meet the bar, the alternatives are to gate Codex behind an opt-in flag (--agent codex), or to hold until OpenAI documents a deny mechanism.
Note the per-Exec microVM boundary is unaffected either way — this is only about what the local harness can do on the laptop, which is precisely what permissions.deny exists to constrain.
Prerequisite
pull --apply does not refuse .codex/ (#592). .codex/config.toml can name an arbitrary command, so a pulled patch could plant one that runs locally on the next codex start. That gap exists today, independent of this feature, and should land first — shipping Codex support while pull still accepts .codex/ would actively increase the exposure by making the file routine.
Suggested shape
- Fix the
pull --applyrefuse-list (prerequisite above). - Add Codex to
agent-config.ts: aCODEX_SERVERconstant, a.codex/config.tomltarget (TOML, so a new parser/merger alongside the existing JSON/JSONC and Markdown handling — this is the bulk of the work), andCODEX_OFFfor the restriction keys. Keepup's merge-never-overwrite andConfigConflictbehaviour. - Extend
checkAgentConfig(sbx doctor) andtakeBackAgentConfig/removeAgentConfigsosbx rmcleans up whatupwrote. - Update SBX0 §6.3, the §4 table in the user guide, and the acceptance list in §"Acceptance" (which today names headless
claude -pandopencode run;codex exec "…"is the equivalent). - Decide the containment framing and document it.
Verification
The Claude Code path was just confirmed end to end against a live sandbox (fresh clone → up → run → agent fix via MCP → pull --apply → local suite green → one-line git diff), and the same walkthrough is the natural acceptance test here with codex substituted. I have not been able to run it: Codex is not installed in the environment I investigated from, so everything above about Codex's configuration comes from OpenAI's documentation, not from a working setup. The inferred items in §"Containment" need a real run before any of this ships.
Happy to do the implementation and the end-to-end verification if the containment question lands on "best-effort is acceptable, documented as such".
Activity
fix(sbx): pull --apply refuses .codex/, which can start MCP servers
mrsabath commentedon Oct 27, 2026
Measured against the real CLI (
codex-cli0.163.0 in a sandbox, 0.164.0 on a host), the premise this issue was written on is wrong, and one of its open questions now has a hard answer. Rescoping.1. There is no project-local MCP config (the premise is dead)
The issue proposed
.codex/config.tomlas the.mcp.jsonanalogue. It is not read. With the file present andcwdinside the repository:config.toml parse okrefers to the global file; the project-local one is not read at all, not rejected. Same result on 0.163.0, so this is not version-specific.codex mcp addhas no project-scope flag, and every-coverride documents itself against~/.codex/config.toml.So
sbx upcannot wire Codex the way it wires Claude Code and OpenCode.codex mcp add sandbox -- mocactl sbx mcpwrites~/.codex/config.toml, which would redirect Codex in every repository on the machine — including ones with no sandbox — and breakup's stated property that what it writes are "ordinary files in your working tree, sogit statusshows them", removable bysbx rm.2.
unified_execcannot be disabled (the containment answer)The issue asked whether the layered restrictions leave only MCP tools reachable. They do not:
shell_toolflips.unified_execdoes not — both the--disableflag and the-coverride are silently ignored. It is a local command-execution tool, so there is no configuration that reduces Codex to MCP-only. Any Codex support must say so plainly rather than imply parity with Claude Code'spermissions.deny.What Codex offers instead is its own sandbox layer, which
doctorreports asrestricted fs + restricted network · approval OnRequest, withsandbox_mode(read-only,workspace-write,danger-full-access) andapproval_policy. That is a different shape of protection — process-level confinement rather than tool denial — and worth considering on its own terms. I could not test whether it actually blocks local writes: the attempt hit my own outer sandbox (Operation not permitted), so that remains unverified.apply_patchexists only as removed/under-development feature flags (apply_patch_freeform,apply_patch_streaming_events), not as a live built-in to deny.3. What does work: per-invocation
-c, with no persistent state-cregisters the server for one run, writing nothing:The dotted form works too (
-c 'mcp_servers.sandbox.command="mocactl"' -c 'mcp_servers.sandbox.args=["sbx","mcp"]'), anddoctorvalidates the command (it reportedstdio command "mocactl" is not resolvablewheremocactlwas off-PATH — a useful preflight).--disable shell_toolcomposes with it:overrides shell_tool.AGENTS.mdalso needs no work: Codex reads it from the git root down, andupalready writes thesbxblock there.Proposed rescope
Drop the
.codex/config.tomlwriter and the TOML merger entirely —agent-config.tsis built onjsonc-parserand there is no TOML dependency in the repo, so that was the bulk of the original estimate and it is now unnecessary.Instead, one of:
mocactl sbx codex [args…]execs Codex with the-cserver registration and--disable shell_toolapplied. Nothing persists, nothing global, no new file format, andsbx rmhas nothing to undo. My recommendation — and the form verified end to end in §4.upends with thecodex -c …line for the user to copy. Zero new surface; costs a manual step.up --agent codexwrites~/.codex/config.tomlandrmreverts it, clearly flagged as machine-wide. Honest but breaks the working-tree property.up's current contract.Either of the first two keeps
up's guarantees intact. All four need the containment caveat in §2 documented indocs/sbx/user-guide.md§4 and SBX0 §6.3: with Codex, local execution is restricted, not denied.4. Verified: an authenticated run routes through the sandbox
The open question was whether a real session would use the MCP server or fall back to the undisableable
unified_exec. Measured on a host with credentials,codex-cli0.164.0, from a repository bound withsbx up:Every tool call was
sandbox.bash, the MCP server's; none usedunified_exec. Theroot-owned files confirm the microVM, not the laptop. So withshell_tooldisabled the model reaches for the sandbox tools in practice, and the launcher is sound.This is behavioural, not a guarantee:
unified_execis still present and cannot be denied (§2), so the honest claim remains "local execution restricted, and in practice unused" rather than "denied". A deny-list equivalent would need an upstream change.(The suite reported
OKbecause that sandbox's workspace still held a previously fixedcalc.py; irrelevant to the routing question being tested.)Unrelated note: refusing
.codex/and.agents/inpull --apply(#592, PR #594) is correct regardless of what happens here, since a pulled patch can create those files whether or notupever writes them.docs(sbx): how to set Codex up and use it with the sandbox
fix(sbx): drop codex's unreachable --json guard, and pin what the tes…
mrsabath commentedon Oct 27, 2026
A follow-up worth recording, raised by a question about whether
mocactl sbx codexgoes through Cortex: it does not, and Cortex may be the one route that could close theunified_exechole. Framing this as an open question, not a recommendation — I have not verified Cortex supports Codex.Today's path is direct
No
agentop, no Cortex. PR #639'scodex.tshas no Cortex reference, andagentop.tsis explicit that "nothing here runs unless the repository is in Cortex mode".That is the right default:
--cortexexists for a Claude-Code-specific problem — denyingReadin.claude/settings.jsonalso drops the project'sCLAUDE.md(sbx-up-cortex design §1) — and Codex does not have it. Codex readsAGENTS.mdnatively,upalready writes that file, and no deny list is interfering because Codex has no deny list at all.Why it is nonetheless interesting here
The containment gap in #639 is that
unified_execcannot be disabled by configuration:--disable unified_execand-c features.unified_exec=falseare both ignored. The launcher's protection is therefore behavioural — withshell_tooloff the model chooses the sandbox tools (verified: every call wassandbox.bash/sandbox.edit) — not a denial.Cortex's
moca-sandboxscript does its blocking in the model proxy, not in harness configuration:Nothing in that mechanism is specific to a harness's config format. If it applies to Codex, it would deny
unified_execthe only way left — at the point the tool call is made — turning #639's best-effort containment into the same guarantee Claude Code gets. That is exactly the gap the spec notes the denies cannot close on their own: "the model calls localBashwhen it judges that easier, even with the sandbox tools present."Routing Codex through Cortex already exists, partly
agentopdoes know about Codex (checked on agentop v0.8.0):So the transport question is answered:
agentop exec -- codexruns Codex under Cortex today, and persistent configuration is planned. Composing it with this PR would beagentop exec -- mocactl sbx codex, or the-c …line insideagentop exec. Codex also honoursOPENAI_BASE_URL(present in the binary), which is presumably how that works.What I still could not determine
moca-sandboxscript recognises Codex sessions. It keys on "sessions whose tool list carriesmcp__sandbox__*tools" — Claude-Code-shaped naming. Codex exposes the same server assandbox.<tool>, so the script would likely need to match a second shape. That is a question for rossoctl/cortex.tool_usetoblocked__<name>in the model response. Whether Codex's wire format and its reaction to an unknown tool name behave like Claude Code's ("No such tool available", runs nothing) is untested.AGENTOP_MIN_VERSIONhere is0.9.3foragentop script install; the agentop I checked is v0.8.0, so I could not exercise the script path at all, only readconfigure's help.Suggested disposition
Leave #639 as it is — direct, no Cortex dependency, containment caveat documented. Nothing here needs to change for Cortex to be tried:
agentop exec -- mocactl sbx codexcomposes today, with no code in this repository, so a user who wants the stronger blocking can already attempt it.If maintainers decide best-effort is not enough for a first-class subcommand, the next step is a question to rossoctl/cortex — does
moca-sandboxblock a Codex session'ssandbox.<tool>list, and does renaming atool_usestop Codex the way it stops Claude Code — rather than a change here. Only if that answer is yes would--cortexbe worth extending to Codex, andsbx doctor's Cortex check with it.Worth noting what it would cost: a Cortex dependency on a path that currently has none, and a second way for the setup to be silently wrong.
fix(sbx): give codex's mcp server the environment it needs
feat(sbx): mocactl sbx codex, Codex CLI on the sandbox's MCP tools
feat(sbx): add mocactl sbx claude, a launcher that asks nothing (#577)
pdettori commentedon Nov 16, 2026
Shipped as
mocactl sbx codex(#639); the prerequisite #592 was fixed by #594.up: Codex reads no project-local MCP config, so this is a per-run launcher rather than anupintegration.unified_execcannot be disabled. This is documented indocs/sbx/user-guide.md, §Codex CLI.unified_execis a question for rossoctl/cortex. Open a new issue if that turns out to be possible.