Skip to content
Agentic Control Plane

Permissions, approvals and audit for OpenAI Codex CLI

Codex CLI permissions per command: a PreToolUse hook checks every shell command, apply_patch edit and MCP tool call against your rules before it runs. One command installs it. Rules such as Bash.git or Bash.docker are set from the dashboard. Codex’s built-in sandbox and approval settings are covered on the control model page.

Install

macOS · Linux · WSL
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
Windows · PowerShell
irm https://agenticcontrolplane.com/install.ps1 | iex

MIT-licensed and auditable. Read it before you run it.

Local vs cloud. With --local, the hook checks Codex's local tool calls on your machine. That means shell commands and, on current builds, apply_patch edits and MCP tool calls. Decisions come from ~/.acp/policy.json and are logged to ~/.acp/audit.jsonl. The MCP connector gives Codex the acp_check tool for calls the hook can't see (hosted tools such as web search, and every non-shell tool on older builds). It is cloud-only and is skipped locally. For full Codex coverage, run without --local.

The step in the middle is Codex's, not ours: it will not run a hook nobody has read. The rig never writes that trust file.

Three things you get the moment it's running — click any to see it full-size:

ACP tool-surface control table: every tool the agent can call, Allow/Deny per tool
ControlEvery tool Codex can call, one row each — Allow / Ask first / Never per tool. Underneath, the safety floor in every mode: rm -rf on home or system folders always blocked; force-push, destructive SQL, and curl | sh held for your OK. Enforced at the call, outside the model.
ACP cost-per-run distribution for one agent across many runs, log scale
PriceRoute model calls through the proxy and every one is metered — each run split loop-vs-leaf and plotted across runs, so you see which step is the bill and which runs blow the budget.
ACP session trace: per-call timeline of one agent run with cost and decision
AuditEvery tool + model call in a run, in order — what ran, what it returned, the policy decision, and what it cost. Exportable.

See your first governed call →Free up to 5 agents · full install below

What the installer does

Codex CLI ships a Claude-style hook system. It is stable and on by default from 0.145.0, where the old codex_hooks flag was renamed to hooks. On current builds, PreToolUse and PostToolUse cover shell commands, apply_patch edits, MCP tool calls and other local function tools. Earlier releases fired them for the shell tool only. Hosted tools such as web search never reach a hook on any build.

The installer detects Codex (command -v codex, or a ~/.codex/ directory) and sets up three things:

  1. Hooks. It confirms the hooks feature is on ([features].hooks on 0.145+, the older codex_hooks key before that). It writes ~/.codex/hooks.json with PreToolUse and PostToolUse entries that run ~/.acp/govern.mjs, matcher .*.
  2. MCP connector. It adds [mcp_servers.acp] to ~/.codex/config.toml, so Codex can call acp_check and acp_status. This covers hosted tools such as web search, and every non-shell tool on older builds.
  3. AGENTS.md note. It writes a section to ~/.codex/AGENTS.md telling Codex that the hook already checks every local tool call, so it should not call acp_check before each one. acp_check and acp_status stay available for hosted tools and for direct questions.

The MCP block uses a shell substitution (sh -c ... Bearer $(cat ~/.acp/credentials)), so the Authorization header reads your credentials file each time Codex starts the server. No key is needed at install time.

The hook feature flag

From Codex 0.145 the hook engine is on by default as [features].hooks (see the Codex feature flags). Earlier builds shipped it as [features].codex_hooks, off by default. On a current build the old key still works but prints a deprecation warning at every launch. The installer writes only the key your build understands, and asks before it edits ~/.codex/config.toml:

[features]
hooks = true

On a pre-0.145 build, hooks without the flag are silently ignored, with no error and no log line. If they aren’t firing, check the flag first. On a current build, look for a stray codex_hooks line instead.

What gets installed and where

Path Purpose
~/.acp/govern.mjs Hook script, shared with Claude Code and Cursor installs
~/.acp/credentials Bearer token from browser OAuth, written after auth
~/.codex/config.toml Ensures [features].hooks = true (codex_hooks on pre-0.145 builds), adds the [mcp_servers.acp] block, and in workspace mode the [model_providers.acp] block for the cost X-ray. The provider is written but not selected, so plain codex is unaffected
~/.codex/hooks.json PreToolUse and PostToolUse entries that run node $HOME/.acp/govern.mjs
~/.acp/bin/codex-acp Launcher (workspace mode): runs codex -c model_provider=acp for that one invocation, with the workspace key from ~/.acp/credentials passed through the environment

Running the installer again skips entries that already exist. On a machine without Codex, the Codex section does nothing.

The MCP connector

The [mcp_servers.acp] block looks like this:

[mcp_servers.acp]
command = "sh"
args = ["-c", 'exec npx -y mcp-remote https://api.agenticcontrolplane.com/mcp --header "Authorization: Bearer $(cat ~/.acp/credentials)"']

The sh -c wrapper reads ~/.acp/credentials every time Codex launches the server. So there is no API key at install time (hooks install, browser auth saves the credentials, the next Codex restart picks them up). Rotating the key means overwriting the file and restarting Codex. And the literal key never lands in config.toml, which keeps it out of dotfile repos.

What the audit log records

Every Codex tool call, whether it came through the hook or the MCP connector, lands in your ACP activity log with client.name: "codex", the turn_id, the subagent context and the delegation chain. Codex’s SessionSource is finer-grained than Claude Code’s tier.

Limitations

Codex hooks are useful but partial. Read this before you rely on them alone.

Coverage depends on your Codex build

Per OpenAI’s Codex hooks documentation, PreToolUse and PostToolUse fire for:

  • shell commands (unified exec matches as Bash)
  • file edits through apply_patch (matcher aliases Edit and Write; the hook input reports tool_name: "apply_patch")
  • MCP tool calls (mcp__server__tool)
  • other local function tools such as spawn_agent

Hosted tools such as WebSearch do not fire hooks, and OpenAI notes that some specialized tool paths can opt out of the default hook path. Earlier Codex releases fired PreToolUse for the shell tool only.

ACP registers a .* matcher on both events, so whatever your build sends reaches the policy check. The hook still does most of the work, because shell is where most destructive risk lives (rm -rf, gh repo delete, psql DROP TABLE). The MCP connector covers what a hook can’t see: hosted tools, and non-shell tools on older builds. If you’re on a current build and only care about local tools, the hook alone is enough.

Only deny works

Codex’s hook engine parses allow and ask decisions but rejects them. The only response that does anything is permissionDecision: "deny" with a permissionDecisionReason. So on Codex there is no ask: a call is allowed or it is blocked. The safety floor’s holds are blocked on Codex too, and you approve them on the console or from the approval email, then retry.

No redaction or rewriting

Codex’s hook engine rejects updatedInput (PreToolUse) and updatedMCPToolOutput (PostToolUse):

You can watch and deny today. You can’t redact or rewrite through the hook. The MCP connector path supports both.

Only command handlers work

Codex’s schema also defines prompt and agent handler types, but they are parsed and then skipped with a warning. Use command.

Hook layers merge without labels

~/.codex/hooks.json and <repo>/.codex/hooks.json both load, and nothing marks which entries ACP owns. The installer uses a fixed statusMessage: "ACP policy check" so it can find and update its own entries on re-install. If you edit hooks by hand, leave that string alone.

The schema changes often

Codex ships several releases a week, and its wire types use deny_unknown_fields, so a new field can break a strict parser. ACP pins to tested Codex versions and updates the adapter when fields land. On alpha releases, expect things to shift.

What you’ll see in the dashboard

Once the hooks are live, your console shows a codex row with activity split by Codex’s session source: cli, vscode, exec, appServer and subAgent. Subagents carry their subtype (Review, ThreadSpawn, MemoryConsolidation, Compact). Codex also reports parent_thread_id and depth for ThreadSpawn, so you can see who delegated to whom.

Setting up policy

Codex uses the same three kinds of policy as every other client:

  • Tool policies restrict the Bash subcommands Codex can run (Bash.git, Bash.npm, Bash.docker, already classified on the server).
  • Agent policies limit which session sources can do risky things. subAgent.MemoryConsolidation should probably never delete files, for example.
  • User policies limit Codex enterprise installs to specific identities.

Rolling out to a whole ChatGPT Enterprise workspace? Codex’s requirements.toml can carry this hook from a system file, an MDM profile or the workspace’s managed configuration. The full file, the MDM script drop and per-person enrollment are on the Codex enterprise rollout page.

Troubleshooting

The hook isn’t firing. On a pre-0.145 build, check that ~/.codex/config.toml has [features].codex_hooks = true. On current builds hooks are on by default, so check that ~/.codex/hooks.json still lists the ACP entries and that Codex trusts them (the hooks.state table in config.toml).

The hook fires for shell but not for apply_patch or MCP calls. Your Codex build predates the wider hook surface. Update Codex, or use the MCP connector for non-shell tools until you do. Hosted tools such as web search never fire hooks on any build.

Codex says “ACP policy check timed out”. The installer registers the hook with a 5-second timeout in hooks.json, and the hook itself gives up on the gateway after 4 seconds. A timed-out check follows your fail mode: allowed and flagged as unchecked by default, denied if you opted into fail-closed (echo closed > ~/.acp/failmode).

An updatedInput rejection error in Codex logs. Don’t return updatedInput from PreToolUse. Return only permissionDecision: "deny" with a reason. Codex strictly rejects fields it doesn’t support.

Add the cost X-ray

The hook checks and logs tool calls. It doesn’t see the model’s token usage, so it can’t show cost. To meter spend and prompt-cache hit rate, Codex’s model calls have to go through the ACP proxy. In workspace mode the installer sets that up: it writes a [model_providers.acp] block into ~/.codex/config.toml and installs codex-acp. Launch with it instead of codex:

codex-acp

Only that invocation uses the ACP provider. Plain codex is untouched. Codex keeps your existing ChatGPT subscription or API-key login (the provider sets requires_openai_auth = true), your workspace key travels as x-acp-key from the environment, and ACP checks the tool-use blocks the model emits against your policy as a second layer. Who pays for the model does not change.

To wire it by hand, or make it the default for plain codex, see the provider block. Full walkthrough: Turn on Cost X-Ray.

Verify the installer

The installer is open source. Read every line before you run it.

Review before you pipe to bash:
· Source code: github.com/agentic-control-plane/acp-install (MIT, auditable)
· SHA-256: /install.sh.sha256 (compare with the acp-install mirror to verify you got the published version)
· Dry read: curl -sf https://agenticcontrolplane.com/install.sh | less to see every line before running
· License: MIT · Issues: github

Frequently asked questions

How do I control what Codex CLI is allowed to do?

Two layers. A PreToolUse hook checks each local tool call (shell commands, apply_patch edits, MCP tool calls) against your rules before it runs, and blocks it with a reason if a rule says no. An MCP connector gives Codex an acp_check tool for anything the hook doesn’t see. The installer wires both in one command. You set per-command rules such as Bash.git, Bash.npm and Bash.docker from the dashboard.

Are Codex hooks on by default, or does the installer have to enable them?

On current builds (0.145 and later) hooks are a stable feature, on by default under [features].hooks. Older builds kept the engine behind [features].codex_hooks, off by default. The installer detects which key your build understands and writes only that one, and it asks before it edits config.toml.

Does the installer need an API key?

No. Hooks install first, then browser auth writes a bearer token to ~/.acp/credentials. The MCP block reads that file through shell substitution every time Codex starts, so no key ever appears in config.toml. To rotate the key, overwrite the file.

Can hooks see Codex's file edits?

On current builds, yes. PreToolUse fires for shell commands (unified exec included), file edits made through apply_patch, MCP tool calls, and other local function tools such as spawn_agent. Hosted tools such as web search don’t use the hook path. Earlier Codex releases fired it for the shell tool only. ACP registers a .* matcher, so every event your build sends reaches the policy check. In a workspace, apply_patch calls are classified as Edit, so Edit rules apply to them.

What happens if the policy check times out or the service is down?

Your fail mode decides. The default is fail-open: the call is allowed and flagged as unchecked, so an outage can’t brick your agent. If you’d rather block calls when the check can’t run, run echo closed > ~/.acp/failmode on that machine.

How do I set codex cli permissions per command?

Run the installer. It writes a PreToolUse hook into ~/.codex/hooks.json and an MCP connector into ~/.codex/config.toml. Then set rules such as Bash.git, Bash.npm or Bash.docker from the dashboard. A deny blocks the call before it runs and Codex sees the reason.

Do codex cli permissions still apply with --sandbox danger-full-access?

Hook-based rules do. Codex keeps firing hooks in every sandbox mode, including --sandbox danger-full-access and the deprecated --full-auto, so a deny still blocks the call. The sandbox flags change what a command can touch, not whether the hook runs.

  • Codex CLI hooks reference: hooks.json, the payload contract, deny semantics, --full-auto behavior and every known limitation
  • Claude Code: same hook pattern; PreToolUse covers every native tool on every build, web fetch included
  • Cursor: a different IDE with hook-based permissions
  • OpenAI Agents SDK: for building OpenAI-model-backed agents with full A2A delegation chains
  • Agent-to-Agent delegation: how delegation chains carry identity through Codex’s SubAgentSource hops

Protected in 3 steps

Out of the box, ACP records every tool call your agents make. A short safety floor applies in every mode: catastrophic commands (rm -rf on your home or system folders, disk wipes) are always blocked, and force-push, destructive SQL, piping a download into a shell, and deleting outside your project are held for your approval. Your own rules (ask first / never) start applying when you turn on enforce. No rule can loosen the floor; a workspace owner or admin can switch it off on the Policies page (you were asked at install). With --local the always-blocked list is narrower: rm -rf on your home or root, disk wipes, fork bombs.

  1. 1
    Install. One command, then approve this machine in the browser. curl -fsSL https://agenticcontrolplane.com/install.sh | bash
  2. 2
    Turn on your rules. Run /acp-enforce in your agent. The starter rules start applying: rm and keychain reads are held for your approval (you approve on the console Approvals page or from the approval email); everything else keeps running and is recorded. Add your own with /acp-ask Bash.curl, /acp-deny Bash.git.push, /acp-allow Bash.npm, or on the Policies page. With --local there is no mode switch: the rules in ~/.acp/policy.json apply from the first call, and the starter file asks before rm, curl, git push, chmod and chown.
  3. 3
    See it work. Ask your agent to do something risky, for example git push --force on a scratch repo. ACP holds the call for your approval; the call and your answer land in the audit log (/acp-why for the last hold, the console Activity page, or ~/.acp/audit.jsonl with --local). In Codex, a held call shows as a block in the agent; approve it on the console Approvals page or from the approval email, then ask the agent to retry.

Copy-paste rules for the things people are most afraid of (force-push, prod database, rm -rf, a secret in a curl, overnight runs, a cost cap): Rules that stop the scary things.