Pairing two agents sounds like a free upgrade. It isn’t, unless you’re clear about why you’re doing it. Reach for the other agent because it’s different, not because it’s better. A model from another lab fails in other places, so you’re buying uncorrelated errors, not extra IQ.
The short version: almost every route shells out to the other agent’s headless mode—claude -p "…" or codex exec, each of which runs one non-interactive session and exits. Even the plugins wrap that call. The one real exception is claude mcp serve, covered below. The real work is containing the other agent’s output, its sandbox, and its bill.
Calling Codex from Claude Code
There are two routes.
- The easy way: OpenAI’s official Codex plugin for Claude Code.
/codex:reviewand/codex:adversarial-revieware read-only reviews./codex:rescuehands Codex a task through a subagent. Long jobs take--background, then/codex:statusand/codex:result. It drives your local Codex install and login. - The do-it-yourself way:
codex exec --sandbox read-only.codex execis Codex’s headless mode: it runs one non-interactive session and exits. Pin the sandbox explicitly: loaded user configuration can replace the default.
verdict_file=$(mktemp) || exit 1
trap 'rm -f "$verdict_file"' EXIT
if ! codex exec --sandbox read-only --ephemeral -o "$verdict_file" "Is the retry path in src/queue.ts safe?" < /dev/null; then
echo "Review process failed" >&2
exit 1
fi
if [ ! -s "$verdict_file" ]; then
echo "Review produced no verdict" >&2
exit 1
fi
cat "$verdict_file"That pins a read-only shell sandbox (--sandbox read-only), runs one question with no saved session (--ephemeral), writes only the final answer to a file (-o), and closes stdin. A few habits make it dependable:
- Read the
-ofile, not the stream: It holds just the final message. Add--output-schema schema.jsonwhen code needs to act on the answer. - Close stdin and check the file:
codex execappends anything on stdin to your prompt. When another agent or script launches it, stdin may never close, so Codex can wait forever or exit0having done no work, printing onlyReading additional input from stdin...(thecodex execdocs cover the stdin behavior). Redirect stdin from/dev/null, write to a freshmktemppath every time so a failed call can’t reuse an earlier verdict, and require both a successful exit and a nonempty file. A reviewer that produced nothing hasn’t approved anything. Agent reviewers covers using agents as reviewers. - Control configuration:
--ephemeralonly disables session persistence. Add--ignore-user-configwhen the review must exclude user configuration and its MCP servers too, as the non-interactive reference describes. Review any remaining project configuration and enabled tools separately; the shell sandbox does not constrain an external MCP service. - Contain it: Call it from a subagent (a helper agent with its own fresh context) or a skill that runs with
context: fork, so Codex’s output stays out of your main context. A plain skill loads into your current conversation, so it won’t.
Calling Claude Code from Codex
- For a second opinion: Run
claude -p "…" --permission-mode plan --output-format json --max-turns 5 --max-budget-usd 1. Plan mode keeps it from editing. The caps keep it from wandering:--max-turnscounts agentic turns (each model request and the tool calls it makes), and--max-budget-usdcaps spend. Add--json-schemafor a validated answer, which comes back in.structured_output. - For Claude Code’s tools, not its judgment:
codex mcp add claude-code -- claude mcp serve, which runs Claude Code as an MCP server (a program that adds tools to a harness). Codex gets Claude Code’s tools, including Bash, Edit, and Write, but not its judgment. That’s a lot of power to expose, so scope it deliberately. - As a plugin: There’s no official one that I’ve found. Sendbird’s community
cc-plugin-codexmirrors OpenAI’s ($cc:review,$cc:rescue) and spawns a freshclaude -pper call.
Things that will bite you
- Sandboxes don’t nest: A sandbox is operating-system-level isolation for what an agent’s shell commands can reach. On macOS, Codex can’t start its own sandbox inside Claude Code’s (
sandbox_apply: Operation not permitted). Take the Codex call out withsandbox.excludedCommandsand let Codex sandbox itself. - Redirects keep a call sandboxed: Excluding a command from Claude Code’s sandbox doesn’t work if the command contains a redirect, even
< /dev/null. So thecodex exec … < /dev/nullexample above works from a terminal or script, but stays sandboxed and fails when Claude Code runs it directly. Put the redirect in a small wrapper script outside the repository, so nothing the agent edits can change what runs unrestricted, and exclude the wrapper. - Codex’s sandbox has no network by default:
claude -phas to reach Anthropic. Approve the escalation, or setnetwork_access = trueunder[sandbox_workspace_write], which opens the network for everything Codex runs. - Two bills: An
ANTHROPIC_API_KEYin Codex’s environment quietly movesclaude -ponto per-token API billing. - Latency: A consult can take minutes. Give the wrapper a timeout, and decide what happens when it fires.
- Review gates loop: Both plugins (OpenAI’s for Claude Code and Sendbird’s for Codex) offer an optional review gate, a hook that runs a review each time the agent tries to stop, and both warn it can drain your usage limits fast.
- Pin and probe: Pin the model (
-m,--model), and rerun your first invocation by hand after you upgrade either CLI.
The sandbox and credential issues here are the same ones that make blast radius worth planning for. Give the second agent the narrowest permissions that still let it answer.