Skip to content

Commit ec87cc7

Browse files
committed
Harden Codex MCP execution
1 parent bd665ea commit ec87cc7

12 files changed

Lines changed: 1515 additions & 148 deletions

File tree

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ The plugin lets Claude Code launch one Codex agent or several Codex agents in pa
1515
- Transport: stdio MCP, launched by Claude Code for the active session. No daemon is required.
1616
- Prompt delivery: stdin, not command-line arguments.
1717
- Codex home: uses the user's Codex home by default; pass `isolated_codex_home: true` to use a temporary Codex home with auth but without inherited `config.toml` MCP servers.
18+
- Concurrency: Codex processes run through a global queue. Defaults are `CODEX_SUBAGENTS_MAX_GLOBAL_PROCESSES=4` and `CODEX_SUBAGENTS_MAX_PROJECT_PROCESSES=2`.
1819

1920
Optional environment overrides:
2021

2122
- `CODEX_SUBAGENTS_CODEX_BIN`: explicit Codex CLI path.
2223
- `CODEX_SUBAGENTS_DEFAULT_MODEL`: model to use when a tool call omits `model`.
2324
- `CODEX_SUBAGENTS_DEFAULT_REASONING_EFFORT`: `low`, `medium`, `high`, or `xhigh`. `minimal` is ignored as a default and falls back to `medium`.
25+
- `CODEX_SUBAGENTS_MAX_GLOBAL_PROCESSES`: maximum Codex child processes across this MCP server.
26+
- `CODEX_SUBAGENTS_MAX_PROJECT_PROCESSES`: maximum Codex child processes per project key.
27+
- `CODEX_SUBAGENTS_JOB_TTL_SECONDS`: completed async job retention window. Defaults to one hour.
2428

2529
## Spark And Nested Subagents
2630

@@ -63,7 +67,9 @@ npm run test:claude-desktop
6367

6468
`test:ci` is the GitHub-safe suite. It uses the fake Codex binary and does not require Claude Code, the Codex desktop app, or live model credentials.
6569

66-
`test:comprehensive` runs the TypeScript build, unit tests, stdio MCP smoke test, reliability matrix, Codex desktop runtime probe, Claude plugin validation, and desktop-shipped Claude Code CLI plugin/auth checks. The runtime probe validates local Codex capabilities without invoking a model.
70+
`test:comprehensive` runs the TypeScript build, unit tests, stdio MCP smoke test, reliability matrix, MCP stress test, Codex desktop runtime probe, Claude plugin validation, and desktop-shipped Claude Code CLI plugin/auth checks. The runtime probe validates local Codex capabilities without invoking a model.
71+
72+
`test:stress` uses the fake Codex binary to exercise queued async jobs, noisy output, malformed JSONL, and truncation behavior.
6773

6874
`test:claude-orchestration` is an opt-in live Claude Code test. It loads the plugin inside Claude Code, lets Claude call the plugin MCP tools, and uses the fake Codex binary so no Codex model tokens are spent. It is kept out of `test:comprehensive` because it does spend Claude tokens.
6975

@@ -87,14 +93,22 @@ After startup, ask Claude to use Codex subagents, or invoke the plugin skill:
8793

8894
`codex_usage_guide` returns the operating guide and example calls Claude can use when deciding how to delegate to Codex.
8995

90-
`run_agent` launches one Codex `exec` process.
96+
`run_agent` launches one Codex `exec` process and waits for it. It uses the same bounded queue as async jobs.
97+
98+
`run_agents` launches multiple Codex `exec` processes concurrently with a bounded `max_parallel` setting and the global queue.
99+
100+
`start_agent_run` starts one queued Codex run and returns a `job.id` immediately.
91101

92-
`run_agents` launches multiple Codex `exec` processes concurrently with a bounded `max_parallel` setting.
102+
`start_agents_run` starts a queued parallel Codex run and returns a `job.id` immediately.
103+
104+
`get_agent_run`, `wait_agent_run`, and `cancel_agent_run` inspect, wait for, or cancel async jobs.
93105

94106
`codex_status` reports the resolved Codex binary, server working directory, Claude project directory, default model, default reasoning effort, and version probe.
95107

96108
Each agent accepts model, reasoning effort, sandbox, project directory, timeout, isolated Codex home, and output-size controls. Pass `project_dir` when Claude Code wants Codex to inspect the same repository or subdirectory Claude is currently working in. If `project_dir` is omitted, the server uses `CLAUDE_PROJECT_DIR` when Claude Code provides it. Omit model to use Codex's configured default or the plugin's optional configured default model.
97109

110+
Prefer `start_agent_run` or `start_agents_run` for work that may run longer than a normal MCP request. The async job API keeps Claude responsive, supports cancellation, and avoids request failures caused by long-running Codex subprocesses.
111+
98112
## License
99113

100114
MIT

0 commit comments

Comments
 (0)