Conversation
Adds a runner for the OpenAI Codex CLI (npm: @openai/codex), enabling the factory to use Codex as an alternative agent backend via FACTORY_RUNNER=codex or --runner codex. Key differences from ClaudeRunner: - Headless via `codex exec --json --ask-for-approval never "<task>"` - System prompt injected via AGENTS.md in project dir (no CLI flag) - Auth via OPENAI_API_KEY - No session management (name/resume/session-id) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…enticated Matches ClaudeRunner's approach: the factory assumes the CLI binary is installed and authenticated, rather than checking for specific env vars. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ty REPL Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use --dangerously-bypass-approvals-and-sandbox for headless (codex exec) - Use --ask-for-approval never for interactive mode - Use -C instead of --cd for working directory - Strip Claude-specific model aliases (sonnet/opus/haiku/claude-*) so Codex uses its own default model - Respect request.skip_permissions instead of always bypassing Verified with live smoke test against codex-cli 0.151.0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The AGENTS.md approach had two problems: - If the project already has an AGENTS.md, the factory's agent prompt (researcher.md, builder.md, etc.) was silently dropped - AGENTS.md is designed for persistent project instructions, not per-invocation role prompts Now combines the system prompt and task into a single positional arg passed to `codex exec`, which is the reliable way to deliver both since Codex has no --append-system-prompt-file equivalent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3d08901 to
098a9f0
Compare
Code ReviewDecision:
Intent & Optimality (pr-intent-review)Understood intent: Add Optimality: mostly optimal — clean, purely additive, correctly conforms to the
Breaking Changes (code-review-breaking-change)No breaking change issues found. The change is purely additive; default runner stays Change Size (code-review-change-size)Pass. +395/-0 (210 lines non-test production code) is well within the 500/800 thresholds. Single cohesive concern (implementation + registration + tests) — no scope creep. Split not recommended. Test Integrity (code-review-test-integrity)No test integrity issues found. 17 new behavioral tests, no deletions, no CI tampering, no skip/xfail.
Comment Density (code-review-comment-density)No file-level issue (density well under 30%). Three nit-level docstrings that restate the method name (Findings 5). The module docstring and the "no Race Condition (code-review-race-condition-check)No race condition issues found. Spec Compliance
Action Items
DetailsOutside spec scope (no PRD); functional correctness issue. The parser scans stdout lines in reverse for a dict containing a top-level if isinstance(parsed, dict) and ("result" in parsed or "message" in parsed):
data = parsed
breakPer the Codex CLI docs,
The unit tests don't catch this because they call Recommendation: Parse the actual Codex event schema — extract the final
DetailsOutside spec scope; doc correctness. The module docstring still states the system prompt "is injected via an
DetailsOutside spec scope; metadata accuracy. The description says the runner is registered "alongside ClaudeRunner and GlaudeRunner" — there is no
DetailsOutside spec scope; test coverage. The 17 tests cover metadata,
DetailsOutside spec scope; style.
DetailsOutside spec scope; dead code.
— Reviewed by Coding Agent |
Summary
CodexRunner(factory/runners/codex.py) — a runner for the OpenAI Codex CLI (npm: @openai/codex), enabling the factory to use Codex as an alternative agent backend viaFACTORY_RUNNER=codexor--runner codexfactory/runners/__init__.pyalongside ClaudeRunner and GlaudeRunnerKey design decisions:
AGENTS.mdin the project directory (Codex has no--append-system-prompt-fileflag). ExistingAGENTS.mdfiles are preserved; factory-created ones are cleaned up after the run.codex exec --json --ask-for-approval never "<task>"prompt_tokens/completion_tokens) and standard (input_tokens/output_tokens) field names--name/--resume/--session-id)Usage:
Test plan
pytest tests/test_codex_runner.py -v)pytest tests/test_runner.py -v)ruff check)codexCLI installed andOPENAI_API_KEYset🤖 Generated with Claude Code