Skip to content

sbx up: support Codex CLI alongside Claude Code and OpenCode #593

Closed

Description

@mrsabath

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 = false

What 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) and mcp_servers is not among them — suggestive, not confirmed.
  • Whether apply_patch exists 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

  1. Fix the pull --apply refuse-list (prerequisite above).
  2. Add Codex to agent-config.ts: a CODEX_SERVER constant, a .codex/config.toml target (TOML, so a new parser/merger alongside the existing JSON/JSONC and Markdown handling — this is the bulk of the work), and CODEX_OFF for the restriction keys. Keep up's merge-never-overwrite and ConfigConflict behaviour.
  3. Extend checkAgentConfig (sbx doctor) and takeBackAgentConfig / removeAgentConfig so sbx rm cleans up what up wrote.
  4. Update SBX0 §6.3, the §4 table in the user guide, and the acceptance list in §"Acceptance" (which today names headless claude -p and opencode run; codex exec "…" is the equivalent).
  5. 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

  1. added
    ready-for-ai-review
    on Oct 23, 2026
  2. mrsabath commented on Oct 27, 2026

    @mrsabath
    MemberAuthor

    Measured against the real CLI (codex-cli 0.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.toml as the .mcp.json analogue. It is not read. With the file present and cwd inside the repository:

    $ codex --version
    codex-cli 0.164.0
    $ cat .codex/config.toml
    [mcp_servers.probe]
    command = "echo"
    args = ["hi"]
    $ codex mcp list
    No MCP servers configured yet. Try `codex mcp add my-tool -- my-command`.
    $ codex doctor | grep -A3 config.toml
          config.toml              ~/.codex/config.toml
          config.toml parse        ok
          MCP servers              0

    config.toml parse ok refers 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 add has no project-scope flag, and every -c override documents itself against ~/.codex/config.toml.

    So sbx up cannot wire Codex the way it wires Claude Code and OpenCode. codex mcp add sandbox -- mocactl sbx mcp writes ~/.codex/config.toml, which would redirect Codex in every repository on the machine — including ones with no sandbox — and break up's stated property that what it writes are "ordinary files in your working tree, so git status shows them", removable by sbx rm.

    2. unified_exec cannot be disabled (the containment answer)

    The issue asked whether the layered restrictions leave only MCP tools reachable. They do not:

    $ codex features list | grep -E "^shell_tool|^unified_exec "
    shell_tool                               stable             true
    unified_exec                             stable             true
    
    $ codex --disable shell_tool --disable unified_exec features list | grep -E "^shell_tool|^unified_exec "
    shell_tool                               stable             false
    unified_exec                             stable             true
    
    $ codex -c 'features.unified_exec=false' features list | grep "^unified_exec "
    unified_exec                             stable             true

    shell_tool flips. unified_exec does not — both the --disable flag and the -c override 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's permissions.deny.

    What Codex offers instead is its own sandbox layer, which doctor reports as restricted fs + restricted network · approval OnRequest, with sandbox_mode (read-only, workspace-write, danger-full-access) and approval_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_patch exists 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

    -c registers the server for one run, writing nothing:

    $ codex -c 'mcp_servers.sandbox={command="mocactl",args=["sbx","mcp"]}' mcp list
    Name     Command  Args     Env  Cwd  Status   Auth
    sandbox  mocactl  sbx mcp  -    -    enabled  Unsupported
    
    $ ls ~/.codex/config.toml
    ls: no such file
    $ codex mcp list
    No MCP servers configured yet.

    The dotted form works too (-c 'mcp_servers.sandbox.command="mocactl"' -c 'mcp_servers.sandbox.args=["sbx","mcp"]'), and doctor validates the command (it reported stdio command "mocactl" is not resolvable where mocactl was off-PATH — a useful preflight). --disable shell_tool composes with it: overrides shell_tool.

    AGENTS.md also needs no work: Codex reads it from the git root down, and up already writes the sbx block there.

    Proposed rescope

    Drop the .codex/config.toml writer and the TOML merger entirely — agent-config.ts is built on jsonc-parser and 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:

    • A launcher. mocactl sbx codex [args…] execs Codex with the -c server registration and --disable shell_tool applied. Nothing persists, nothing global, no new file format, and sbx rm has nothing to undo. My recommendation — and the form verified end to end in §4.
    • Print the command. up ends with the codex -c … line for the user to copy. Zero new surface; costs a manual step.
    • Global config with explicit consent. up --agent codex writes ~/.codex/config.toml and rm reverts it, clearly flagged as machine-wide. Honest but breaks the working-tree property.
    • Decline, and document that Codex is not supportable under up's current contract.

    Either of the first two keeps up's guarantees intact. All four need the containment caveat in §2 documented in docs/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-cli 0.164.0, from a repository bound with sbx up:

    $ codex -c 'mcp_servers.sandbox={command="mocactl",args=["sbx","mcp"]}' \
            --disable shell_tool \
            "Run the test suite in sbx/demo and report what fails. Do not edit anything."
    
    • Called sandbox.bash
      └ -rw-r--r-- 1 root root   32 Oct 22 23:50 calc.py
    • Called sandbox.bash
    • Called sandbox.bash
      └ Ran 1 test in 0.000s
        OK

    Every tool call was sandbox.bash, the MCP server's; none used unified_exec. The root-owned files confirm the microVM, not the laptop. So with shell_tool disabled the model reaches for the sandbox tools in practice, and the launcher is sound.

    This is behavioural, not a guarantee: unified_exec is 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 OK because that sandbox's workspace still held a previously fixed calc.py; irrelevant to the routing question being tested.)

    Unrelated note: refusing .codex/ and .agents/ in pull --apply (#592, PR #594) is correct regardless of what happens here, since a pulled patch can create those files whether or not up ever writes them.

  3. mrsabath commented on Oct 27, 2026

    @mrsabath
    MemberAuthor

    A follow-up worth recording, raised by a question about whether mocactl sbx codex goes through Cortex: it does not, and Cortex may be the one route that could close the unified_exec hole. Framing this as an open question, not a recommendation — I have not verified Cortex supports Codex.

    Today's path is direct

    mocactl sbx codex
      └─ spawn('codex', ['-c', 'mcp_servers.sandbox={…}', '--disable', 'shell_tool', …])
           └─ codex spawns: mocactl sbx mcp        (stdio MCP server)
                └─ gRPC → relay → microVM
    

    No agentop, no Cortex. PR #639's codex.ts has no Cortex reference, and agentop.ts is explicit that "nothing here runs unless the repository is in Cortex mode".

    That is the right default: --cortex exists for a Claude-Code-specific problem — denying Read in .claude/settings.json also drops the project's CLAUDE.md (sbx-up-cortex design §1) — and Codex does not have it. Codex reads AGENTS.md natively, up already 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_exec cannot be disabled by configuration: --disable unified_exec and -c features.unified_exec=false are both ignored. The launcher's protection is therefore behavioural — with shell_tool off the model chooses the sandbox tools (verified: every call was sandbox.bash / sandbox.edit) — not a denial.

    Cortex's moca-sandbox script does its blocking in the model proxy, not in harness configuration:

    • it removes the 17 local tools from the list the model sees;
    • it renames a local tool_use in the response to blocked__<name>, so Claude Code answers "No such tool available" and runs nothing;
    • it replaces the result of a local call that already ran with an error.

    Nothing in that mechanism is specific to a harness's config format. If it applies to Codex, it would deny unified_exec the 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 local Bash when it judges that easier, even with the sandbox tools present."

    Routing Codex through Cortex already exists, partly

    agentop does know about Codex (checked on agentop v0.8.0):

    $ agentop configure --help
      agentop configure codex | opencode
    
    $ agentop configure codex --help
    Persistent Codex configuration coming soon.  Until then, use `agentop exec -- codex` to run Codex under Cortex.

    So the transport question is answered: agentop exec -- codex runs Codex under Cortex today, and persistent configuration is planned. Composing it with this PR would be agentop exec -- mocactl sbx codex, or the -c … line inside agentop exec. Codex also honours OPENAI_BASE_URL (present in the binary), which is presumably how that works.

    What I still could not determine

    • Whether the moca-sandbox script recognises Codex sessions. It keys on "sessions whose tool list carries mcp__sandbox__* tools" — Claude-Code-shaped naming. Codex exposes the same server as sandbox.<tool>, so the script would likely need to match a second shape. That is a question for rossoctl/cortex.
    • Whether the proxy sees Codex tool calls in a form it can rename. The blocking works by rewriting a tool_use to blocked__<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.
    • Version floor. AGENTOP_MIN_VERSION here is 0.9.3 for agentop script install; the agentop I checked is v0.8.0, so I could not exercise the script path at all, only read configure's help.
    • The same caveat the spec already records would apply, and more sharply: agentop has no machine-readable answer for whether the agent actually reaches the model through Cortex, so "a repository in Cortex mode whose Claude Code bypasses Cortex runs with no blocking" (§5). For Codex that silent-bypass case would be the difference between denied and merely discouraged.

    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 codex composes 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-sandbox block a Codex session's sandbox.<tool> list, and does renaming a tool_use stop Codex the way it stops Claude Code — rather than a change here. Only if that answer is yes would --cortex be worth extending to Codex, and sbx 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.

  4. pdettori commented on Nov 16, 2026

    @pdettori
    Member

    Shipped as mocactl sbx codex (#639); the prerequisite #592 was fixed by #594.

    • Why not up: Codex reads no project-local MCP config, so this is a per-run launcher rather than an up integration.
    • Containment is best-effort because unified_exec cannot be disabled. This is documented in docs/sbx/user-guide.md, §Codex CLI.
    • Cortex: whether Cortex can block unified_exec is a question for rossoctl/cortex. Open a new issue if that turns out to be possible.
  5. added this to the v0.11.0 milestone on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-ai-review

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions