Skip to content

Codex

The agent plugin assay-agent holds Codex to the gate with the same three hooks it has for Claude Code: a mark at session start, a note after each patch of Codex’s edit tool apply_patch, and assay gate at turn end. While the gate fails, Codex makes the message of what fails the prompt of a continuation of the turn, and the agent works on.

One plugin serves both agents, at one version. This page covers what differs under Codex; for everything else (the mark, the message, the baseline and configuration changes, whole-project results, judging by hand) see the Claude Code page.

Claude Code Codex
Hooks run once the plugin is enabled once it is enabled and you have trusted its hooks, again after each update
The command of assay the setting assay_command the environment variable ASSAY_COMMAND
The project root CLAUDE_PROJECT_DIR the directory the session works in
The hook after an edit after Edit and Write, one file each after apply_patch, each file the patch adds, updates, moves or deletes
A gate that passes with something new the agent reads the message and goes on for one round you are shown the message; the agent stops
Blocks with no state to compare Claude Code ends the turn after eight continuations in a row the plugin lets the agent go at the ninth such turn end of a turn
Windows Git Bash or PowerShell runs the one command cmd.exe runs the Windows command

assay’s repository is a Codex marketplace too. From a terminal:

codex plugin marketplace add gundogduali/assay
codex plugin add assay-agent@assay

A checkout works as a marketplace too: codex plugin marketplace add /absolute/path/to/assay. Codex then reads the checkout where it is.

You need what the plugin needs under Claude Code: a project that has adopted assay, the program assay, and dart on the PATH until the plugin’s program is built (see Installing the plugin). Then:

  • Trust the hooks. Codex runs a hook that no administrator manages only after you have trusted it: choose “Trust all and continue” at start-up (not “Continue without trusting (hooks won’t run)”), or review them with /hooks. Until then nothing of the plugin runs, and it cannot tell you so.
  • Trust them again after every update. The trust is pinned to a digest of every file of the installed plugin, checked before each run. A file written into the installed plugin stops all its hooks, and a symbolic link in it fails the digest. The launchers write only into the data directory, and the release checks refuse symbolic links.
  • Updates. For the repository as a marketplace, codex plugin marketplace upgrade assay refreshes the marketplace and reinstalls its plugins. For a checkout, Codex copies the plugin again when it finds another version there.
  • Per person. The plugin is enabled per person (plugins."assay-agent@assay".enabled in ~/.codex/config.toml), so it runs in every project you open with Codex. A project with no Dart files costs a mark and a gate run.

The plugin follows Codex 0.172.0. No AGENTS.md text and no skill ship with the plugin: they carry instructions to the agent and cannot hold a turn end.

What Codex reads, and where it runs the plugin from
  • The marketplace is .agents/plugins/marketplace.json, read before Claude Code’s .claude-plugin/marketplace.json; both name it assay and list assay-agent from ./plugins/assay-agent, installed on request (AVAILABLE).
  • The manifest is .codex-plugin/plugin.json, read before Claude Code’s .claude-plugin/plugin.json. It names the hooks file ./hooks/codex.json and holds the same version as Claude Code’s. The release checks keep both manifests, both marketplaces and the hooks file in step.
  • Codex runs the plugin from its cache, ~/.codex/plugins/cache/assay/assay-agent/<version>/, and builds its program in the data directory ~/.codex/plugins/data/assay-agent-assay.

The project root is the session’s working directory: where Codex was started, or the one codex --cd names. The plugin runs every assay command there, so start Codex in the root of the package, which holds pubspec.yaml and the root analysis_options.yaml.

The plugin never reads CLAUDE_PROJECT_DIR under Codex (a Codex started from a Claude Code session inherits it). A relative path in a patch is read from the root, and a file outside the project is not recorded. A session whose hooks run in another directory than before is, there, a session first seen late.

At every hook the plugin looks in this order:

  1. the environment variable ASSAY_COMMAND;
  2. assay on the PATH;
  3. assay in the pub cache’s bin directory, as under Claude Code.

Under Codex the plugin never reads Claude Code’s CLAUDE_PLUGIN_OPTION_ASSAY_COMMAND. ASSAY_COMMAND holds the whole command line, split as the setting assay_command is. Set it where you start Codex, as export ASSAY_COMMAND='dart pub global run assay_cli:assay' before codex, or in your login profile. Codex hands its environment to the hooks through a login shell, so the PATH is the one Codex was started with, as the login profile leaves it; a PATH that only ~/.zshrc sets up is there only if you started Codex from such a shell. The assay version --json check is the same as under Claude Code.

If no program is found, you are told once per session:

assay gate: COULD NOT RUN - The program assay is not on PATH and not in the directory of the programs of the pub cache, and the environment variable `ASSAY_COMMAND` is not set.
The change of this turn was not judged.
Next: install assay, or set the command that runs it in the environment variable `ASSAY_COMMAND`. This is said once in a session; the agent is not held while assay is missing.

For a program that writes another result schema, the last line says set the command that runs one in the environment variable `ASSAY_COMMAND` .

The hook reads hook_event_name, session_id and source, and nothing else, so a field Codex adds or drops breaks nothing. It then does what the Claude Code hook does. It prints nothing, because Codex adds what this hook prints to the agent’s developer context.

startup, clear and fork open a session. resume, compact and any start the plugin does not know go on from earlier work. A wrong guess costs one first-seen-late notice, never a judgement.

The hook reads tool_name and, of apply_patch, tool_input.command: the patch text. Codex runs the hook only after a patch that applied whole. The plugin records each file the patch names, in order; only a file’s first touch in the session counts:

The patch What is recorded
*** Add File: the file did not exist
*** Update File: for a Dart file, the earlier text, recovered by undoing the chunks where each new text stands in exactly one place; otherwise not known
*** Move to: removed at the old path; at the new one, what it held at the old path, so a file that only moved holds nothing new
*** Delete File: removed

A Dart file’s earlier text is not known, never guessed, where Codex matched a chunk leniently (white space at line ends, typographic punctuation) or the file has CRLF line ends. The plugin reads patches as Codex’s own parser does, here-documents included. A text that is no patch goes to .dart_tool/assay_agent/hooks.log. A patch that names an environment of its own (*** Environment ID:) records nothing.

As under Claude Code, the ledger is only used in a project with no git repository. There the change is the files of the patches that applied whole. A patch the agent runs through the shell (apply_patch <<'EOF' … EOF sent as a shell command) runs no hook, so its files are not recorded. Nor does a patch that failed partway: its files are judged once a later patch names them, as it left them. A file a patch adds over one you had is taken for new, so its standing suppressions count as new and block once, as for a file Claude Code’s Write overwrites. In a repository, git sees what changed, whatever wrote it.

A move in a git repository. Git sees a rename only where it tracks the new path (git diff-index -M reads the index). A patch’s move leaves it untracked, so the moved file’s standing suppressions and coverage-ignore comments count as new and block the turn end once; the same state then lets the agent go. Track the new path first (git add or git add -N) and the file holds nothing new. A file moved with mv in a shell behaves the same under Claude Code.

Subagents. A subagent’s hooks run with its parent’s session identifier, so its patches are judged at the parent’s turn end. SubagentStop is not wired.

The hook reads hook_event_name, session_id and stop_hook_active (“Whether this turn was already continued by Stop” in Codex’s schema): false at the first turn end of a turn, which each of your prompts starts, true after a block in that turn. A value that is not a boolean says nothing. The gate judges whatever the field says; the field only decides how long the agent can be held.

It runs the gate as under Claude Code and answers:

The gate The hook writes (exit code 0 in every case) What follows
fails, or the change holds a new suppression or a new coverage-ignore comment {"decision":"block","reason":"<message>"} Codex makes the reason the prompt of a continuation of the same turn, and the agent works on.
blocks again, and nothing has changed since the agent was last blocked {"systemMessage":"<notice>"} The agent stops. Codex shows you the notice as a warning.
blocks with no state to compare, after eight such turn ends in a row of one turn {"systemMessage":"<notice>"} The agent stops.
passes, with something new {"systemMessage":"<the message>"} The agent stops. You are shown the message.
passes, with nothing new no output The agent stops.
could not be run {"systemMessage":"<notice>"}, or no output if you were told before in the session; the notice also goes to standard error The agent stops and is handed nothing.

Codex reads the answer strictly: one object on one line, alone on standard output, holding only continue, stopReason, suppressOutput, systemMessage, decision ("block" alone) and reason. Any other field, such as Claude Code’s hookSpecificOutput, or plain text, makes it invalid. The plugin writes only decision, reason and systemMessage, and never exits with 2 (a block with standard error as the prompt); any other exit code is a failed hook that decides nothing.

The message is Claude Code’s, at most about 8,000 characters; Codex’s limits on context a hook adds do not apply to a continuation’s prompt.

The notices are Claude Code’s, in systemMessage, which Codex shows as a warning in the interface or the event stream. Two are Codex’s own.

The news of a gate that passes. Codex can hand the agent a text at turn end only by blocking, and a passing gate is no reason to hold it. So the news goes to you alone, first among the notices: the whole message if it fits in 1,500 characters, otherwise as many whole lines as fit, then ..., a blank line and Full report: <path>.

assay gate: PASS - scope: changed files - 0 blocking, 1 advisory, 1 changed file
Next: nothing is required. What follows is new in this session and does not fail the gate.
Advisory violations in changed files (1 new) - they do not fail the gate
lib/greeting.dart
5:15 no_magic_number: This number has no name: the code does not say what the value stands for.
fix: Declare a constant whose name says what the number is and use the constant here.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-<identifier>.txt

It all counts as handed over, also what a cut notice left out, so the next turn end in the same state passes in silence. The agent is not told of advisory violations, configuration changes or whole-project results: pass them on if you want them fixed. A later block hands the agent the whole message.

The agent was held at eight turn ends with no state to compare:

assay gate: STILL FAILING - 1 blocking, 0 advisory, 1 changed file
The agent was held at 8 turn ends in a row whose change could not be compared with the last one, as the gate did not say what the change holds, and was not held again.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-<identifier>.txt

As under Claude Code, each new state is blocked once, and the first turn end that blocks with nothing changed lets the agent go (Claude Code): in the same turn, when the agent answers the continuation without touching a file, or in a later one.

A block no turn end followed. A block holds the agent only if Codex continues the turn; the next turn end then comes with stop_hook_active true. If the next turn end is instead the first of a later turn, the agent may never have seen the message: another plugin’s Stop hook answered continue: false, which wins over every block, or the continuation ended early, on an interruption or a model error. That turn end holds the agent once more, with the whole message, and the one after lets it go as usual. If no turn end follows that block either, the next turn lets the agent go with the still-failing notice. (Session state: heldInBlockedState.) Codex’s rollout budget never drops a block.

The bound of eight. Codex continues a turn on every block, with no limit of its own. When the result cannot say what the change holds (a changed file cannot be read, or the configuration is in error and git does not name the changed files), every turn end blocks. So under Codex the plugin:

  • holds the agent at eight such turn ends in a row of one turn, and lets it go at the ninth with the notice above, and at every such turn end after it in that turn;
  • starts the count again when the gate passes or blocks in a state it can compare, and at the first turn end of your next turn, so an agent you set to work again is told what fails;
  • leaves the count as it is at a turn end that judged nothing: the gate could not run, assay was missing or unusable, the run was ended, the mark was taken again, or the answer did not get out.

(Session state: blocksWithoutState.) Unlike Claude Code’s limit, which starts again whenever the agent calls a tool, this bound counts the turn ends of one turn whatever the agent did between them: the agent is let go at the ninth even while it is still changing files.

The time limit is the gate’s, as under Claude Code: the standard analysis command is stopped after 300 seconds, and the gate ends as “could not be run”. Codex ends a hook after 600 seconds unless it sets a timeout; the plugin’s hooks set none, so the gate’s own limit comes first.

Case What happens What to do
The hooks are not trusted No hook runs: before you trust them, after an update until you trust them again, never under a policy that admits managed hooks only, and in codex exec (no review) only if trusted before or run with --dangerously-bypass-hook-trust. None runs with features.hooks off (it is on by default). The plugin cannot tell anyone, and .dart_tool/assay_agent/ holds nothing of the session. Trust the hooks at start-up or with /hooks, again after each update.
A file written into the installed plugin, or a symbolic link in it The trust’s digest changes, and no hook runs until you trust it again. Do not edit the installed plugin.
Your login profile prints a line on standard output The line comes before the answer, which is then invalid, and a failing gate does not block. At session start it becomes agent context. Whatever the profile takes is added to every hook. Silence the line.
The session started in a subdirectory The project root is the session’s working directory. Start Codex in the package root.

Everything else from Claude Code’s list holds here too: assay or dart missing, a failed build, a launcher waiting for another’s build, .dart_tool/assay_agent removed during a session, a session left open for more than 14 days, and one started before the plugin was enabled.

The plugin’s hooks for Codex are in hooks/codex.json.

The hooks file, without its description
{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": "exec sh \"${PLUGIN_ROOT}/scripts/run.sh\" codex session-start",
"commandWindows": "powershell -NoProfile -ExecutionPolicy Bypass -File \"${PLUGIN_ROOT}\\scripts\\run.ps1\" codex session-start"
}
]
}
],
"PostToolUse": [
{
"matcher": "apply_patch",
"hooks": [
{
"type": "command",
"command": "exec sh \"${PLUGIN_ROOT}/scripts/run.sh\" codex after-edit",
"commandWindows": "powershell -NoProfile -ExecutionPolicy Bypass -File \"${PLUGIN_ROOT}\\scripts\\run.ps1\" codex after-edit"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "exec sh \"${PLUGIN_ROOT}/scripts/run.sh\" codex turn-end",
"commandWindows": "powershell -NoProfile -ExecutionPolicy Bypass -File \"${PLUGIN_ROOT}\\scripts\\run.ps1\" codex turn-end",
"statusMessage": "assay: judging the change"
}
]
}
]
}
}
  • PostToolUse names apply_patch itself, though Codex also lets Edit and Write match it. statusMessage is what Codex shows while the gate runs.
  • Codex puts the installed plugin’s root in place of ${PLUGIN_ROOT} and runs the command in the session’s working directory with your login shell, $SHELL -lc "<command>" (/bin/sh if SHELL is not set), or on Windows %COMSPEC% /C "<command>" (cmd.exe), which runs the PowerShell launcher scripts/run.ps1 (Windows PowerShell 5.1); Git Bash is not used. The environment is Codex’s, less a fixed list of its own names, plus PLUGIN_ROOT, PLUGIN_DATA, and CLAUDE_PLUGIN_ROOT and CLAUDE_PLUGIN_DATA at the same values.
  • No hook sets a timeout: Codex’s default is 600 seconds, and the gate’s own 300 seconds come first.
  • Codex starts a trusted hook outside its sandbox, so the plugin and assay can write .dart_tool/, the baseline file and the data directory whatever the session’s sandbox allows.
  • Codex refuses a hooks file with any top-level field but description and hooks, and with it every hook; the release checks refuse such a field.

The launchers are Claude Code’s, with the agent as first argument: run.sh codex <event> reads PLUGIN_ROOT and PLUGIN_DATA, never Claude Code’s names, which a Codex started from a Claude Code session inherits. If the data directory is not set:

assay-agent: PLUGIN_DATA is not set, so the plugin has nowhere to build its program: the agent did not set it. Run the plugin from the agent that installed it.

The program then runs as assay-agent codex <session-start|after-edit|turn-end>.

Codex ends such a hook with SIGKILL to its process group, which holds the plugin’s program and assay. Nothing is passed on or written, and the next turn end judges and answers again. Ctrl-C and a request to terminate, where they reach the program, are passed on to assay as under Claude Code.

As under Claude Code, under .dart_tool/assay_agent/. A Codex session identifier, a UUID, is a plain file name. The built program, its build log and the launchers’ markers are in ~/.codex/plugins/data/assay-agent-assay, outside the project and outside the installed plugin that Codex’s trust covers.