Codex CLI as an MCP Tool Inside an Agents-SDK Loop
An outer-planner/inner-coder loop from an official OpenAI recipe: an Agents SDK orchestrator plans and verifies while Codex CLI, wrapped as an MCP server, performs one bounded code change per turn.
Implementation note
When to use: workflows needing separation between planning and coding — you want an orchestrator that decides what to do and verifies outcomes, with the code-touching capability isolated behind a tool boundary. From an official OpenAI recipe. How it works: Codex CLI is wrapped as an MCP server, and an OpenAI Agents SDK orchestrator drives it in a loop: the outer agent plans the work and verifies results, while each inner Codex call performs exactly one bounded code change per turn. The MCP boundary makes the coder a discrete, inspectable tool call rather than an open-ended session. Safety: the outer-planner, inner-coder split is the structural rail — the agent that changes code is not the agent that judges whether the change succeeded, and each code mutation is bounded to one tool invocation. Put iteration and budget caps in the orchestrator loop, since it, not Codex, controls how many turns run. Hardened 2026-07-27: explicit stop/cap/verification guardrails appended; regraded D→A.
More automation loops
Ship production-grade apps autonomously
Hand an idea to Claude Code; it authors specs, designs, builds, tests, secures, and ships until enterprise done or budget exhausted.
claude-progress.txt harness pattern (Anthropic)
Anthropic's first-party file-as-memory harness for long-running agents: every fresh-context session recovers state from a progress file and the git log, does one unit of work, updates the file, commits, and exits.
Complete all tasks in tasks.md
Work through your tasks.md file, completing each task until none remain or max iterations is reached.