README
¶
Codex CLI adapter
What this is
This directory is the Codex CLI host adapter for Orch: a Codex plugin
that connects a Codex CLI session to the shared orch binary. It is
deliberately thin (PRD §6) — "the detailed state machine must not be
independently reimplemented in Markdown skills or platform-specific
shell scripts." Every policy decision (what is writable, what routing
applies, what a Delivery run's state is) is made by the orch binary.
This adapter only translates Codex CLI host events into calls against
that binary, presents native dialogs, and dispatches role agents. It
never re-derives a decision the engine already made.
The Claude Code adapter lives at adapters/claude/ and passes the same
shared parity suite (internal/adaptertest) this adapter's plugin tests
do. Question and approval checks are document-contract checks, not proof
of live agent behavior.
Before #292, the manual plugin was Orch's Codex execution path. After #292, it remains that path; an internal metadata preflight adds no execution CLI or model turns. See the native protocol subset for its authentication/catalog checks, bounds and version-sensitive Windows diagnostics. The manual adapter's workflows and restrictions below still hold.
#293 adds a separate native workspace preflight and an opt-in no-model Windows isolation smoke in the same protocol document. Its worker/reviewer command profiles were tested with synthetic fixtures; at that stage native model execution was unavailable because 0.159.2 could not establish the required inherited-tool boundary. Since #322, the existing native bridge conditionally admits reviewed Windows amd64 Codex 0.160.0 with verified controls; other versions remain refused. The preflights added no execution CLI and did not change any manual role's guard or instruction-based read-only restrictions. Live evaluation trials and current-version qualification remain outstanding; see the protocol document for the exact boundary.
Released engine v0.15.2 pairs with manual adapter 0.13.0. Guided setup and manual Delivery are implemented, and completed child usage has been captured in a fresh manual Delivery exercise. Automatic Codex Architect usage, Codex grants and context relay remain missing. Installation and source/CI success do not prove a fresh installed initial-setup/survey exercise or full host parity. See the current parity matrix, including the separate Claude/OpenCode baseline caveats. The protected-list status reports added by #434 are unreleased source behavior, not part of the installed v0.15.2 binary.
Artifact map
.codex-plugin/plugin.json— the plugin manifest (name, description, version, author). Theskills/andhooks/hooks.jsoncomponent directories are auto-discovered by Codex CLI; there is nothing else to declare here yet. Codex plugins cannot bundle agent TOMLs or prompts (see Install order below).hooks/hooks.json— two hooks:PreToolUseonapply_patchrunsorch guard codex, which reads the tool-call event on stdin and denies the write when Orch's policy (Assist read-only, Delivery worktree containment) says so. All file mutations on Codex CLI — create, update, delete, rename — route through this single tool, so this one matcher covers every file mutation the same way Claude Code's four-tool matcher does. An allow is silence: guard never bypasses Codex CLI's own approval and sandbox prompts.SessionStartonstartup|resumerunsorch hook codex session-start, which injects a short context block at session start when the current directory is inside an Orch repository with a readable configuration and state: the operating mode, the memhub mode, a reminder to load theorch-architectskill before planning or making a change, and a pointer to theorch-setupskill for the three setup interviews. Outside an Orch repository, or if the repository is unreadable, it injects nothing and never blocks the session. (Codex has noclear/compactSessionStart sources to mirror Claude Code's matcher, hencestartup|resumeonly.)
skills/orch-architect/SKILL.md— the Architect's standing posture: never edit tracked files directly, never re-derive engine policy, theorch run status --json/ PROJECT.md / memhub-recall session ritual, mode conduct, the five-agent dispatch whitelist and theconcurrency.max_subagentscap, and memhub write discipline.skills/orch-delivery/SKILL.md— the Delivery wire contract: the scratch-file JSON request/response pattern for everyorch run <verb>call,PlanDocconstruction, the plan gate and its four logical outcomes presented according to current host capabilities, activation, the full per-issue dispatch → execute → pr-open → review → ci → merge-report → merge gate → merge → cleanup loop, completion and the memhub wrap-up cue, escalation, and block/abandon.skills/orch-setup/SKILL.md— the shared step-loop driver for the threeorch <cmd> --stepinterviews: the resubmitted-in-fullAnswerSet, one-question-at-a-time presentation ofquestionsdocuments via supported native questions or plain text, thesummary/blockers/complete/aborteddocument kinds, and each interview's terminal form.agents/orch-scout.toml,agents/orch-implementer.toml,agents/orch-specialist.toml,agents/orch-reviewer.toml,agents/orch-reviewer-safe.toml— the five role agents the Architect dispatches during Delivery, each pinning its ownmodelandmodel_reasoning_effort.orch-reviewer-safeis the §10 safe-review downgrade encoding: since Codex has no per-spawn model override, the downgrade the engine computes for a mechanical/low-risk/ fully-specified/unsurprising issue has to have its own project TOML under.codex/agents/, dispatched by name exactly likeorch-reviewer.
No commands/ directory and no prompt files ship with this adapter:
Codex custom prompts (slash commands) are deprecated, so skills are
invoked directly instead of through a command surface (a recorded
decision, not an oversight).
Install order
-
Install the
orchbinary onPATHfirst. Every hook in this plugin shells out to it with a bare command; if it is not resolvable, both hooks fail (see Known limitations). Use the root agent-led installation prompt; its installer verifies the release binary against published checksums before execution. -
Install this plugin (
.codex-plugin/plugin.json, its bundledhooks/andskills/) from the repository's marketplace manifest:codex plugin marketplace add kninetimmy/orch codex plugin add orch@orchThe manifest at the repository root (
.claude-plugin/marketplace.json) serves both hosts — install this host's entry by its exact name,orch. The Claude entry (orch-claude, sourceadapters/claude) also shows up incodex plugin listas installable (verified on codex-cli 0.144.1); it bundles Claude-format components and is not this adapter. -
Approve the plugin-bundled hooks' one-time trust prompt. Codex CLI requires the user to review and trust plugin-bundled hooks before they run at all. Until that approval happens,
orch guard codexandorch hook codex session-startsilently do not run — the same fail-open class as a missing binary, not a denial or an error. Restart Codex after installation before relying on the plugin. Inside an initialized repository, check for the Orch session-start block; installation during an existing session does not prove the hooks and skills were loaded there. -
Check the current session's question-tool capabilities. Before this update, this step prescribed both tables below in
~/.codex/config.toml(verified on codex-cli 0.144.1) and treated them as enabling native setup and approval questions, including a four-option native plan gate:[tools.experimental_request_user_input] [features] default_mode_request_user_input = trueOn that version, the
[tools]entry was a struct, not a boolean; the bare table enabled its defaults. After this update, userequest_user_inputonly when available, permitted for the question's purpose, and able to represent all options within its current contract; otherwise present the same complete question as plain text. All four logical plan outcomes and each PR's fresh merge choice remain. Historical flags do not override current tool restrictions, including prohibitions on approval requests and limits on option counts. Those restrictions describerequest_user_input, not every question tool; any other tool must satisfy its own current contract and the same requirements for complete questions and human approval.Setup, plan activation, and each PR merge require an actual affirmative human answer. Defaults, preselection, silence, timeout, unavailable tools, or an unanswered question never count as approval.
-
Open the repository root and ask your agent:
Initialize Orch in this repository using the orch-setup skill.It guides the host/model choices, protected-path survey and final change summary, then opens the initialization PR only after your approval. Review and merge that PR yourself. Preserve existing host configuration and project instructions outside Orch's managed block. See the full per-repository setup prompt.Earlier root guidance made bare
orch initsound interactive. Bareorch init,orch configureandorch configure-localprint reports; the setup skill drives the interactive steps. For an existing project, ask the agent to configure Orch using that skill. Codex does not ship Claude's/orch:initor/orch:configurecommands. -
Bootstrap leaves the primary checkout unchanged. After the initialization PR is merged, update that checkout with the merged configuration, for example with
git pull --ff-onlyon the repository's default branch. Confirm.orchestrator/config.tomlis present locally, then runorch render-agents. Codex plugins cannot bundle agent definitions, so the command writes the five canonical TOMLs to the project's.codex/agents/, substitutingmodelandmodel_reasoning_effortfrom the effectivehosts.codex.roles. It also renders every other enabled host, and refuses before writing unless every enabled destination is git-ignored. Re-render after effective role changes, or after an upgrade changes definitions or doctor reports them stale. Earlier guidance said to re-render after every upgrade; unchanged definitions need no refresh. Before the rendering workflow a manual five-file copy was an accepted alternative; afterward,orch render-agentsis the single per-repository workflow. -
Run
orch doctor --host codexin the initialized repository. Check every failure and advisory; other configured hosts' failures are reported as advisories rather than hidden. This checks the manual adapter environment, not native-evaluation qualification or full parity.
Upgrade
The marketplace-add and plugin-add commands above are for a first installation. Upgrade an existing adapter with:
codex plugin marketplace upgrade orch
Update the compatible engine/adapter pair together between runs in Assist;
never replace either during an active run. Restart Codex CLI after the upgrade
so it loads the updated adapter, run orch render-agents if definitions changed
or are stale, and run orch doctor --host codex. Preserve existing configuration.
Compare actual installed skills and source provenance with the intended release,
then exercise the installed workflow under a fresh approved plan; matching
version labels alone are insufficient. See the root
upgrade and compatibility guidance.
Known limitations
These are accepted for this PR and the adapter as a whole, not open bugs:
- Bash-mediated writes are not guarded. The
PreToolUsehook only coversapply_patch. A file write made throughBash(for exampleecho > fileor a script) does not go throughorch guard codex. Codex CLI's own approval and sandbox prompts onBashare the backstop here. This limitation is shared with the Claude adapter — but on Codex,Bashitself is a hookable tool_name, which makes the shared task-27 core feature (closing this gap for real) more tractable on this host than on Claude Code, where no comparable hook point exists for shell-mediated writes today. - Role read-only-ness rests on
developer_instructions, not on the guard.orch guard's--rolenarrowing is the only mechanism that could make a role mechanically read-only, and this adapter never passes it: Codex hooks are plugin-global rather than scoped per dispatched agent, sohooks/hooks.jsonruns the bareorch guard codexcommand. What the guard enforces is containment — inside a registered worktree, on its registered branch, in a writable phase — applied to every agent alike; it cannot attribute a write to a role. Since Codex agent definitions carry no tool whitelist, nothing mechanical stopsorch-scoutor either reviewer from writing inside a worktree the guard currently treats as writable, including the one under review. Their read-only discipline is stated in theirdeveloper_instructionsand rests there. The Claude adapter leaves--roleunused for the same reason. Its tool whitelist backsorch-scout's read-only-ness fully —orch-scoutcarries noBash— butorch-reviewerandorch-reviewer-safeboth carryBash, so their whitelist leaves that same Bash-mediated write path open there too, even though it excludes every guarded write tool; their read-only discipline for anything Bash-mediated rests on instructions, same as this host's. - A missing
orchbinary fails open, not closed. As described under Install order: a hook command that cannot be found exits non-blocking by the hook protocol's own rules, so both the write guard and the session-start context silently stop working rather than erroring loudly. The same is true while the one-time hook trust approval is outstanding. Install order,orch doctor, and the visible absence of session-start context are the mitigations; there is no way to make either gap fail closed from inside the hook itself. - No per-spawn model override. Codex CLI dispatches an agent with
whatever
model/model_reasoning_effortits project TOML pins — there is no host mechanism to override either per dispatch. This is not a Codex-specific constraint relative to Claude Code: both hosts require the routed selection to match an active project agent definition exactly, because Claude Code's Task toolmodelparameter only accepts coarse tier aliases (sonnet/opus/haiku/fable), never an exact version string, so a per-spawn override cannot express a routed selection there either.orch-delivery's spawn step therefore stops and tells the human on a mismatch, on either host, rather than silently substituting a mismatched agent or reporting the routed selection as if it ran. Effort is pinned the same way on both hosts: in the project TOML on Codex and in the agent definition'seffortfrontmatter field on Claude Code, and the host applies it.orch-reviewer-safeexists specifically so the §10 safe-downgrade row has a real project TOML to dispatch, instead of dead-ending at that same stop-and-tell-human rule on every routine downgrade. - A configured non-default model is applied by
orch render-agents, not automatically. A repository that overrides the §10 defaults must runorch render-agents(PRD §22) itself — install and upgrade do not run it for you — to re-render every enabled host's project definitions from the effective role configuration before the override takes effect for dispatched agents.orch doctorand plan activation fail closed on missing, unreadable, or stale definitions. - An unrecognized future
apply_patchenvelope directive denies, fail-closed.internal/guard's envelope parser treats any***directive line it does not already recognize as a malformed envelope and denies the write (seeErrPatchEnvelope). This is deliberate — an upstream Codex CLI format addition must never silently allow an unparsed write — but it also means a Codex CLI upgrade that adds a newapply_patchdirective kind can cause spurious denies untilorchitself is updated to parse it.
Host version
Formal minimum: the first hooks-GA Codex CLI release (2026-05-14).
Rationale: apply_patch PreToolUse hook events only fire correctly on
builds after openai/codex PR #18391 (2026-04-22, the fix that made
apply_patch write events actually reach hooks); a build older than
that silently never sees file-write events at all — no error, no
denial, just a guard hook that never runs. That failure mode has no
visible symptom short of a write landing that should have been denied,
which is why the floor is pinned at the first release confirmed to
include the fix rather than left to a de-facto smoke-tested version, as
the Claude adapter's is.
Two behaviors verified live in the task-30 parity smoke (codex-cli
0.144.1, 2026-07-12): PreToolUse hooks do fire on dispatched-agent
(subagent) apply_patch calls — load-bearing here, since it puts every
dispatched agent's writes under the guard's worktree, branch, and phase
containment, the only mechanical write boundary this adapter ships —
and request_user_input was root-thread only. Before this update, that
observation was generalized to say a dispatched agent could never raise
a native question. After this update, it remains an observation about
request_user_input on that tested version, not every question tool or
version. Check the current tool contract; dispatched agents surface
questions and approval needs through the Architect.
As defense in depth — complementary to the guard hook, not a
substitute for it, and no configuration is shipped by this adapter to
enforce it — a repository operator adopting this adapter should also
consider running Codex CLI with sandbox_mode set to workspace-write
and a non-never approval_policy. The guard hook denies by orch's own
Delivery/Assist policy; Codex CLI's own sandbox and approval settings
are a second, independent layer that catches what the hook cannot (a
missing binary, an unapproved plugin, a write the hook fails to
classify). One Windows caveat, observed live: workspace-write
requires Codex's sandbox helper infrastructure to be installed and
healthy — where it is absent, every agent apply_patch fails before
any mutation (orchestrator_helper_launch_failed), which stops
Delivery execution cold. Verify the sandbox works before adopting that
mode on Windows.
Documentation
¶
Overview ¶
Package codex anchors the adapters/codex directory as a Go package so its validation tests (plugin_test.go) build and run under the module's ordinary `go test ./...`. The Codex CLI plugin itself is non-Go: the manifest, hooks, skills, and agent TOMLs under this directory are read directly by Codex CLI, never compiled. This file carries no runtime code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AgentTOMLs embed.FS
AgentTOMLs embeds the five shipped Codex agent definitions under agents/ verbatim (LF-only, byte-identical to what this plugin ships, since go:embed reads the file at build time). internal/agents reads from this embed.FS to render `.codex/agents/*.toml` from the effective configuration, so the shipped adapter files and `orch render-agents`'s output share exactly one canonical source and cannot silently diverge: any edit to a file under agents/ changes what both the plugin ships and the render command produces, in the same build.
var PluginManifestJSON string
PluginManifestJSON is the shipped plugin manifest and therefore the canonical adapter version for this build.
Functions ¶
This section is empty.
Types ¶
This section is empty.